1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 00:31:41 +03:00
mold/test/elf/bsymbolic.sh

36 lines
641 B
Bash
Raw Normal View History

2021-03-02 14:24:31 +03:00
#!/bin/bash
export LC_ALL=C
2021-03-02 14:24:31 +03:00
set -e
2022-05-11 11:46:19 +03:00
CC="${TEST_CC:-cc}"
CXX="${TEST_CXX:-c++}"
GCC="${TEST_GCC:-gcc}"
GXX="${TEST_GXX:-g++}"
MACHINE="${MACHINE:-$(uname -m)}"
2022-01-24 04:21:08 +03:00
testname=$(basename "$0" .sh)
echo -n "Testing $testname ... "
t=out/test/elf/$MACHINE/$testname
2022-01-07 12:06:53 +03:00
mkdir -p $t
2021-03-02 14:24:31 +03:00
2022-01-07 12:06:53 +03:00
cat <<EOF | $CC -c -fPIC -o$t/a.o -xc -
2021-03-02 15:47:19 +03:00
int foo = 4;
int get_foo() { return foo; }
2021-03-02 14:24:31 +03:00
EOF
2022-01-07 12:06:53 +03:00
$CC -B. -shared -fPIC -o $t/b.so $t/a.o -Wl,-Bsymbolic
2022-01-07 12:06:53 +03:00
cat <<EOF | $CC -c -o $t/c.o -xc - -fno-PIE
2021-03-02 14:24:31 +03:00
#include <stdio.h>
int foo = 3;
2021-03-02 15:47:19 +03:00
int get_foo();
2021-03-02 14:24:31 +03:00
int main() {
printf("%d %d\n", foo, get_foo());
2021-03-02 14:24:31 +03:00
}
EOF
2022-01-07 12:06:53 +03:00
$CC -B. -no-pie -o $t/exe $t/c.o $t/b.so
$QEMU $t/exe | grep -q '3 4'
2021-03-02 14:24:31 +03:00
echo OK