1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#!/bin/bash
. $(dirname $0)/common.inc
cat <<EOF > $t/a.ver
ver1 {
global: f*o;
local: *;
};
ver2 {
global: b*;
};
EOF
cat <<EOF | $CC -B. -xc -shared -o $t/b.so -Wl,-version-script,$t/a.ver -
void foo() {}
void bar() {}
void baz() {}
EOF
cat <<EOF | $CC -xc -c -o $t/c.o -
void foo();
void bar();
void baz();
int main() {
foo();
bar();
baz();
return 0;
}
EOF
$CC -B. -o $t/exe $t/c.o $t/b.so
$QEMU $t/exe
readelf --dyn-syms $t/exe > $t/log
grep -F 'foo@ver1' $t/log
grep -F 'bar@ver2' $t/log
grep -F 'baz@ver2' $t/log
|