2021-07-10 11:18:35 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
cd $(dirname $0)
|
2021-07-21 08:49:02 +03:00
|
|
|
mold=`pwd`/../mold
|
2021-07-10 11:18:35 +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-07-10 11:18:35 +03:00
|
|
|
mkdir -p $t
|
|
|
|
|
|
|
|
cat <<EOF | cc -shared -o $t/a.so -xc -
|
|
|
|
void fn() {}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF | cc -o $t/b.o -c -xc -
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
void fn();
|
|
|
|
void (*ptr)() = fn;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
printf("%d\n", fn == ptr);
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2021-07-19 18:21:12 +03:00
|
|
|
clang -fuse-ld=$mold -o $t/exe $t/b.o $t/a.so
|
2021-07-10 11:18:35 +03:00
|
|
|
$t/exe | grep -q 1
|
|
|
|
|
|
|
|
echo OK
|