This commit is contained in:
Rui Ueyama committed 2026-10-19 10:54:16 +09:00
1 parent 72f728c20b
commit 77d78b9a0e
1 file changed
+8 -4
+8 -4
View File
@@ -3,7 +3,11 @@
# A statically-linked executable that exports symbols has .dynamic and
# .dynsym.
test_cflags -static || skip
test_cflags -static -no-pie || skip
# FreeBSD's libc assumes that a program is dynamically linked if _DYNAMIC
# is defined, so it doesn't support a static executable with .dynamic.
[ "$(uname)" = FreeBSD ] && skip
cat <<EOF | $CC -o $t/a.o -c -xc -
#include <stdio.h>
@@ -13,14 +17,14 @@ int main() {
}
EOF
$CC -B. -o $t/exe1 $t/a.o -static -Wl,--export-dynamic
$CC -B. -o $t/exe1 $t/a.o -static -no-pie -Wl,--export-dynamic
readelf -W --dyn-syms $t/exe1 | grep -w foo
$QEMU $t/exe1 | grep 'Hello world'
echo '{ foo; };' > $t/dyn
$CC -B. -o $t/exe2 $t/a.o -static -Wl,--dynamic-list=$t/dyn
$CC -B. -o $t/exe2 $t/a.o -static -no-pie -Wl,--dynamic-list=$t/dyn
readelf -W --dyn-syms $t/exe2 | grep -w foo
$QEMU $t/exe2 | grep 'Hello world'
$CC -B. -o $t/exe3 $t/a.o -static
$CC -B. -o $t/exe3 $t/a.o -static -no-pie
readelf -WS $t/exe3 | not grep -F .dynamic