1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 16:48:04 +03:00
mold/test/elf/canonical-plt.sh

43 lines
653 B
Bash
Raw Normal View History

2021-03-01 17:33:53 +03:00
#!/bin/bash
set -e
cd $(dirname $0)
2021-09-08 13:11:48 +03:00
mold=`pwd`/../../mold
2021-03-01 17:33:53 +03:00
echo -n "Testing $(basename -s .sh $0) ... "
2021-10-12 12:32:20 +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;
}
void *bar() {
return bar;
}
EOF
cat <<EOF | cc -o $t/b.o -c -xc - -fPIC
void *bar();
void *baz() {
return bar;
}
2021-03-01 17:33:53 +03:00
EOF
cat <<EOF | cc -o $t/c.o -c -xc - -fno-PIC
2021-03-01 17:33:53 +03:00
#include <stdio.h>
void *foo();
void *bar();
void *baz();
2021-03-01 17:33:53 +03:00
int main() {
printf("%d %d %d\n", foo == foo(), bar == bar(), bar == baz());
2021-03-01 17:33:53 +03:00
}
EOF
clang -fuse-ld=$mold -no-pie -o $t/exe $t/a.so $t/b.o $t/c.o
$t/exe | grep -q '^1 1 1$'
2021-03-01 17:33:53 +03:00
echo OK