1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-22 10:27:48 +03:00
mold/test/version-script3.sh
2021-03-17 16:56:37 +09:00

53 lines
697 B
Bash
Executable File

#!/bin/bash
set -e
cd $(dirname $0)
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=`pwd`/../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=`pwd`/../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