2021-05-26 16:48:53 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
cd $(dirname $0)
|
2021-09-08 13:11:48 +03:00
|
|
|
mold=`pwd`/../../mold
|
2021-05-26 16:48:53 +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-05-26 16:48:53 +03:00
|
|
|
mkdir -p $t
|
|
|
|
|
|
|
|
cat <<EOF | clang -c -o $t/a.o -xc -
|
|
|
|
static void foo() {}
|
|
|
|
void bar() {}
|
|
|
|
void baz() {}
|
|
|
|
int main() {}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF > $t/symbols
|
|
|
|
foo
|
|
|
|
baz
|
|
|
|
EOF
|
|
|
|
|
2021-07-19 18:21:12 +03:00
|
|
|
clang -fuse-ld=$mold -o $t/exe $t/a.o \
|
2021-05-26 16:48:53 +03:00
|
|
|
-Wl,--retain-symbols-file=$t/symbols
|
|
|
|
readelf --symbols $t/exe > $t/log
|
|
|
|
|
|
|
|
! grep -qw foo $t/log || false
|
|
|
|
! grep -qw bar $t/log || false
|
|
|
|
! grep -qw main $t/log || false
|
|
|
|
|
|
|
|
grep -qw baz $t/log
|
|
|
|
|
|
|
|
echo OK
|