mirror of
https://github.com/rui314/mold.git
synced 2024-11-11 16:58:12 +03:00
34 lines
583 B
Bash
Executable File
34 lines
583 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 | 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 \
|
|
-Wl,-z,nocopyreloc 2> $t/log || false
|
|
|
|
grep -q 'recompile with -fPIE' $t/log
|
|
|
|
echo OK
|