2022-01-06 14:17:49 +03:00
|
|
|
#!/bin/bash
|
|
|
|
export LANG=
|
|
|
|
set -e
|
2022-01-07 06:51:36 +03:00
|
|
|
CC="${CC:-cc}"
|
|
|
|
CXX="${CXX:-c++}"
|
2022-01-24 04:21:08 +03:00
|
|
|
testname=$(basename "$0" .sh)
|
2022-01-06 14:17:49 +03:00
|
|
|
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
|
2022-01-06 14:17:49 +03:00
|
|
|
|
2022-01-07 12:06:53 +03:00
|
|
|
echo 'VER1 { foo[12]; }; VER2 {};' > $t/a.ver
|
2022-01-06 14:17:49 +03:00
|
|
|
|
2022-01-07 12:06:53 +03:00
|
|
|
cat <<EOF > $t/b.s
|
2022-01-06 14:17:49 +03:00
|
|
|
.globl foo1, foo2, foo3
|
|
|
|
foo1:
|
|
|
|
nop
|
|
|
|
foo2:
|
|
|
|
nop
|
|
|
|
foo3:
|
|
|
|
nop
|
|
|
|
EOF
|
|
|
|
|
2022-01-07 12:06:53 +03:00
|
|
|
$CC -B. -shared -o $t/c.so -Wl,-version-script,$t/a.ver $t/b.s
|
|
|
|
readelf --dyn-syms $t/c.so > $t/log
|
|
|
|
grep -q ' foo1@@VER1$' $t/log
|
|
|
|
grep -q ' foo2@@VER1$' $t/log
|
|
|
|
! grep -q ' foo3@@VER1$' $t/log || false
|
2022-01-06 14:17:49 +03:00
|
|
|
|
|
|
|
echo OK
|