2021-03-18 13:54:56 +03:00
|
|
|
#!/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 | cc -shared -o $t/a.so -xc -
|
|
|
|
int foo = 3;
|
|
|
|
int bar = 5;
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF | cc -fno-PIC -c -o $t/b.o -xc -
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
extern int foo;
|
|
|
|
extern int bar;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
printf("%d %d\n", foo, bar);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.so $t/b.o
|
|
|
|
$t/exe | grep -q '3 5'
|
|
|
|
|
|
|
|
! clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.so $t/b.o \
|
2021-04-11 07:58:49 +03:00
|
|
|
-Wl,-z,nocopyreloc 2> $t/log || false
|
2021-03-18 13:54:56 +03:00
|
|
|
|
|
|
|
grep -q 'recompile with -fPIE' $t/log
|
|
|
|
|
|
|
|
echo OK
|