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
Rui Ueyama 8b41bb923a [ELF] Fix canonical PLT entry
Previously, an executable linked by mold could fall into an infinite
loop between .plt.got and .got entries. This commit fixes the issue
by creating .plt entries instead of .plt.got.

Fixes https://github.com/rui314/mold/issues/129
2021-11-18 20:53:15 +09:00

43 lines
653 B
Bash
Executable File

#!/bin/bash
set -e
cd $(dirname $0)
mold=`pwd`/../../mold
echo -n "Testing $(basename -s .sh $0) ... "
t=$(pwd)/../../out/test/elf/$(basename -s .sh $0)
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;
}
EOF
cat <<EOF | cc -o $t/c.o -c -xc - -fno-PIC
#include <stdio.h>
void *foo();
void *bar();
void *baz();
int main() {
printf("%d %d %d\n", foo == foo(), bar == bar(), bar == baz());
}
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$'
echo OK