1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-22 10:27:48 +03:00
mold/test/nocopyreloc.sh
Rui Ueyama 4da18565f5 wip
2021-04-11 14:01:00 +09:00

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