2021-03-27 09:25:45 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
cd $(dirname $0)
|
2021-09-08 13:11:48 +03:00
|
|
|
mold=`pwd`/../../mold
|
2021-03-27 09:25:45 +03:00
|
|
|
echo -n "Testing $(basename -s .sh $0) ... "
|
2021-09-08 13:11:48 +03:00
|
|
|
t=$(pwd)/../..//out/test/elf/$(basename -s .sh $0)
|
2021-03-27 09:25:45 +03:00
|
|
|
mkdir -p $t
|
|
|
|
|
|
|
|
cat <<EOF > $t/a.ver
|
|
|
|
{
|
|
|
|
global:
|
|
|
|
extern "C++" {
|
|
|
|
foo::bar;
|
|
|
|
};
|
|
|
|
|
|
|
|
local: *;
|
|
|
|
};
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF | c++ -fPIC -c -o $t/b.o -x c++ -
|
|
|
|
int bar = 5;
|
|
|
|
namespace foo {
|
|
|
|
int bar = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2021-07-19 18:21:12 +03:00
|
|
|
clang -fuse-ld=$mold -shared -o $t/c.so -Wl,-version-script,$t/a.ver $t/b.o
|
2021-03-27 09:25:45 +03:00
|
|
|
|
|
|
|
readelf --dyn-syms $t/c.so > $t/log
|
|
|
|
fgrep -q _ZN3foo3barE $t/log
|
2021-04-11 07:58:49 +03:00
|
|
|
! fgrep -q ' bar' $t/log || false
|
2021-03-27 09:25:45 +03:00
|
|
|
|
|
|
|
echo OK
|