2021-03-01 17:33:53 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
cd $(dirname $0)
|
2021-07-21 08:49:02 +03:00
|
|
|
mold=`pwd`/../mold
|
2021-03-01 17:33:53 +03:00
|
|
|
echo -n "Testing $(basename -s .sh $0) ... "
|
2021-09-08 13:08:51 +03:00
|
|
|
t=$(pwd)/../out/test/elf/$(basename -s .sh $0)
|
2021-03-01 17:33:53 +03:00
|
|
|
mkdir -p $t
|
|
|
|
|
|
|
|
cat <<EOF | cc -o $t/a.so -fPIC -shared -xc -
|
|
|
|
void *foo() {
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF | cc -o $t/b.o -c -xc - -fno-PIC
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
void *foo();
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
printf("%d\n", foo == foo());
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2021-07-19 18:21:12 +03:00
|
|
|
clang -fuse-ld=$mold -no-pie -o $t/exe $t/a.so $t/b.o
|
2021-03-02 14:24:31 +03:00
|
|
|
$t/exe | grep -q 1
|
2021-03-01 17:33:53 +03:00
|
|
|
|
|
|
|
echo OK
|