1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 08:37:28 +03:00
mold/test/elf/retain-symbols-file.sh
Rui Ueyama a7f1e20594 [ELF] Emit local symbols for .got, .plt and .plt.got
These symbols are purely informational. They are not used for symbol
resolution. But they are useful for making disassembly readable.
2022-10-02 16:51:45 +08:00

36 lines
639 B
Bash
Executable File

#!/bin/bash
export LC_ALL=C
set -e
CC="${TEST_CC:-cc}"
CXX="${TEST_CXX:-c++}"
GCC="${TEST_GCC:-gcc}"
GXX="${TEST_GXX:-g++}"
MACHINE="${MACHINE:-$(uname -m)}"
testname=$(basename "$0" .sh)
echo -n "Testing $testname ... "
t=out/test/elf/$MACHINE/$testname
mkdir -p $t
cat <<EOF | $CC -c -o $t/a.o -xc -
static void foo() {}
void bar() {}
void baz() {}
int main() { foo(); }
EOF
cat <<EOF > $t/symbols
foo
baz
EOF
$CC -B. -o $t/exe $t/a.o -Wl,--retain-symbols-file=$t/symbols
readelf -W --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