1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-24 17:01:50 +03:00
mold/test/pie.sh
Nehal J Wani 3208ceaac6
[tests] Fix pie test when cc isn't built with --enable-default-pie
mold: /__w/mold/mold/test/tmp/pie/a.o:(.text): R_X86_64_32 relocation
       against symbol `.rodata' can not be used; recompile with -fPIE
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
2021-07-03 01:05:28 -04:00

22 lines
399 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 -o $t/a.o -c -xc -fPIE -
#include <stdio.h>
int main() {
printf("Hello world\n");
return 0;
}
EOF
clang -fuse-ld=`pwd`/../mold -pie -o $t/exe $t/a.o
readelf --file-header $t/exe | grep -q 'Shared object file'
$t/exe | grep -q 'Hello world'
echo OK