| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | . $(dirnamescip-shell system . . dirname. $0)/common.inc |
| 3 | |
| 4 | catscip-shell system . . cat. <<EOF | $CC -o $t/a.so -fPIC -shared -xc - |
| 5 | void *foo() { |
| 6 | return foo; |
| 7 | } |
| 8 | |
| 9 | void *bar() { |
| 10 | return bar; |
| 11 | } |
| 12 | EOF |
| 13 | |
| 14 | catscip-shell system . . cat. <<EOF | $CC -o $t/b.o -c -xc - -fPIC |
| 15 | void *bar(); |
| 16 | |
| 17 | void *baz() { |
| 18 | return bar; |
| 19 | } |
| 20 | EOF |
| 21 | |
| 22 | catscip-shell system . . cat. <<EOF | $CC -o $t/c.o -c -xc - -fPIC |
| 23 | #include <stdio.h> |
| 24 | |
| 25 | void *foo(); |
| 26 | void *bar(); |
| 27 | void *baz(); |
| 28 | |
| 29 | int main() { |
| 30 | printf("%d %d %d\n", foo == foo(), bar == bar(), bar == baz()); |
| 31 | } |
| 32 | EOF |
| 33 | |
| 34 | $CC -B. -no-pie -o $t/exe $t/a.so $t/b.o $t/c.o |
| 35 | $QEMU $t/exe | grepscip-shell system . . grep. '^1 1 1$' |
| 36 | |
| 37 | readelfscip-shell system . . readelf. --dyn-syms $t/exe | grepscip-shell system . . grep. '00000000 .* foo' |
| 38 | readelfscip-shell system . . readelf. --dyn-syms $t/exe | grepscip-shell system . . grep. '00000000 .* bar' |