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

43 lines
870 B
Bash
Raw Normal View History

#!/bin/bash
export LC_ALL=C
set -e
CC="${CC:-cc}"
CXX="${CXX:-c++}"
GCC="${GCC:-gcc}"
GXX="${GXX:-g++}"
OBJDUMP="${OBJDUMP:-objdump}"
MACHINE="${MACHINE:-$(uname -m)}"
2022-01-24 04:21:08 +03:00
testname=$(basename "$0" .sh)
echo -n "Testing $testname ... "
cd "$(dirname "$0")"/../..
mold="$(pwd)/mold"
2022-01-07 12:06:53 +03:00
t=out/test/elf/$testname
mkdir -p $t
[ $MACHINE = x86_64 ] || { echo skipped; exit; }
2022-01-07 12:06:53 +03:00
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
2022-01-07 12:06:53 +03:00
$CC -B. -o $t/exe $t/a.o -nostdlib -Wl,-unique='*foo*'
2022-01-07 12:06:53 +03:00
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