1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-15 14:36:25 +03:00
mold/test/version-script3.sh
2021-07-21 16:27:29 +09:00

54 lines
700 B
Bash
Executable File

#!/bin/bash
set -e
cd $(dirname $0)
mold=`pwd`/../mold
echo -n "Testing $(basename -s .sh $0) ... "
t=$(pwd)/tmp/$(basename -s .sh $0)
mkdir -p $t
cat <<EOF > $t/a.ver
ver1 {
global: f*o;
local: *;
};
ver2 {
global: b*;
};
EOF
cat <<EOF > $t/b.s
.globl foo, bar, baz
foo:
ret
bar:
ret
baz:
ret
EOF
clang -fuse-ld=$mold -shared -o $t/c.so -Wl,-version-script,$t/a.ver $t/b.s
cat <<EOF | clang -xc -c -o $t/d.o -
int foo();
int bar();
int baz();
int main() {
foo();
bar();
baz();
return 0;
}
EOF
clang -fuse-ld=$mold -o $t/exe $t/d.o $t/c.so
$t/exe
readelf --dyn-syms $t/exe > $t/log
fgrep -q 'foo@ver1' $t/log
fgrep -q 'bar@ver2' $t/log
fgrep -q 'baz@ver2' $t/log
echo OK