From f5b2b822952b36c817106f65dfe2c96a1a3a0c3b Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 22 Jul 2024 10:39:23 +0900 Subject: [PATCH] Skip a test if LD_PRELOAD doesn't work May be related to the following issues: https://github.com/rui314/mold/issues/1305 https://github.com/rui314/mold/issues/1309 --- test/elf/shared-abs-sym.sh | 45 ++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/test/elf/shared-abs-sym.sh b/test/elf/shared-abs-sym.sh index f462130c47..40ebdbc83c 100755 --- a/test/elf/shared-abs-sym.sh +++ b/test/elf/shared-abs-sym.sh @@ -1,31 +1,52 @@ #!/bin/bash . $(dirname $0)/common.inc -cat < +int foo(); +int main() { printf("foo=%d\n", foo()); } +EOF + +$CC -o $t/exe1 -pie $t/c.o $t/a.so +$QEMU $t/exe1 | grep -q 'foo=3' +LD_PRELOAD=$t/b.so $QEMU $t/exe1 | grep -q 'foo=5' || skip + +# If LD_PRELOAD works, continue +cat < extern char foo; int main() { printf("foo=%p\n", &foo); } EOF # This test fails with older glibc -$CC -B. -o $t/exe1 -pie $t/c.o $t/a.so 2> /dev/null || skip -$QEMU $t/exe1 | grep -q 'foo=0x3' || skip -LD_PRELOAD=$t/b.so $QEMU $t/exe1 | grep -q 'foo=0x5' - -$CC -B. -o $t/exe2 -pie $t/c.o $t/a.so -$QEMU $t/exe2 | grep -q 'foo=0x3' -LD_PRELOAD=$t/b.so $QEMU $t/exe2 | grep -q 'foo=0x5' +$CC -B. -o $t/exe2 -pie $t/f.o $t/d.so 2> /dev/null || skip +$QEMU $t/exe2 | grep -q 'foo=0x3' || skip +LD_PRELOAD=$t/e.so $QEMU $t/exe2 | grep -q 'foo=0x5' -$CC -B. -o $t/exe3 -no-pie $t/c.o $t/a.so +$CC -B. -o $t/exe3 -pie $t/f.o $t/d.so $QEMU $t/exe3 | grep -q 'foo=0x3' -LD_PRELOAD=$t/b.so $QEMU $t/exe3 | grep -q 'foo=0x5' +LD_PRELOAD=$t/e.so $QEMU $t/exe3 | grep -q 'foo=0x5' + +$CC -B. -o $t/exe4 -no-pie $t/f.o $t/d.so +$QEMU $t/exe4 | grep -q 'foo=0x3' +LD_PRELOAD=$t/e.so $QEMU $t/exe4 | grep -q 'foo=0x5'