1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 16:48:04 +03:00
mold/test/elf/unique.sh

35 lines
724 B
Bash
Raw Normal View History

#!/bin/bash
export LANG=
set -e
testname=$(basename -s .sh "$0")
echo -n "Testing $testname ... "
cd "$(dirname "$0")"/../..
mold="$(pwd)/mold"
t="$(pwd)/out/test/elf/$testname"
mkdir -p "$t"
cat <<EOF | cc -c -o "$t"/a.o -x assembler -
2021-06-19 06:34:20 +03:00
.section .data.foo.1,"aw",@progbits
.ascii "a"
2021-06-19 06:34:20 +03:00
.section .data.foo.1,"aw",@progbits
.ascii "b"
2021-06-19 06:34:20 +03:00
.section .data.foo.2,"aw",@progbits
.ascii "c"
2021-06-19 06:34:20 +03:00
.section .data.bar.1,"aw",@progbits
.ascii "d"
2021-06-19 06:34:20 +03:00
.section .data.bar.2,"aw",@progbits
.ascii "e"
.text
.globl _start
_start:
nop
EOF
clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.o -nostdlib -Wl,-unique='*foo*'
readelf -x .data.foo.1 "$t"/exe | grep -q ab
readelf -x .data.foo.2 "$t"/exe | grep -q c
readelf -x .data "$t"/exe | grep -q de
echo OK