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'