1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-15 14:36:25 +03:00
mold/test/tls-gd2.sh
Rui Ueyama c50dd18881 Fix an issue that local symbols are exported
We sometimes put local symbols into .dynsym, but if they are
global symbols hidden by a version script, they were exported
from .dynsym. This patch correctly makes them local symbols.
2021-08-29 13:04:23 +09:00

34 lines
631 B
Bash
Executable File

#!/bin/bash
set -e
cd $(dirname $0)
mold=`pwd`/../mold
echo -n "Testing $(basename -s .sh $0) ... "
t=$(pwd)/tmp/$(basename -s .sh $0)
mkdir -p $t
if [ $(uname -m) = x86_64 ]; then
dialect=gnu
elif [ $(uname -m) = aarch64 ]; then
dialect=trad
else
echo skipped
exit 0
fi
echo '{ global: bar; local: *; };' > $t/a.ver
cat <<EOF | gcc -mtls-dialect=$dialect -fPIC -c -o $t/b.o -xc -
_Thread_local int foo;
int bar() {
return foo;
}
EOF
clang -fuse-ld=$mold -shared -o $t/c.so $t/b.o -Wl,--version-script=$t/a.ver \
-Wl,--no-relax
readelf -W --dyn-syms $t/c.so | grep -Pq 'TLS LOCAL DEFAULT \d+ foo'
echo OK