1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-05 00:57:08 +03:00
mold/test/elf/retain-symbols-file.sh

32 lines
546 B
Bash
Raw Normal View History

2021-05-26 16:48:53 +03:00
#!/bin/bash
set -e
cd $(dirname $0)
2021-09-08 13:11:48 +03:00
mold=`pwd`/../../mold
2021-05-26 16:48:53 +03:00
echo -n "Testing $(basename -s .sh $0) ... "
2021-09-08 13:11:48 +03:00
t=$(pwd)/../..//out/test/elf/$(basename -s .sh $0)
2021-05-26 16:48:53 +03:00
mkdir -p $t
cat <<EOF | clang -c -o $t/a.o -xc -
static void foo() {}
void bar() {}
void baz() {}
int main() {}
EOF
cat <<EOF > $t/symbols
foo
baz
EOF
clang -fuse-ld=$mold -o $t/exe $t/a.o \
2021-05-26 16:48:53 +03:00
-Wl,--retain-symbols-file=$t/symbols
readelf --symbols $t/exe > $t/log
! grep -qw foo $t/log || false
! grep -qw bar $t/log || false
! grep -qw main $t/log || false
grep -qw baz $t/log
echo OK