1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-05 00:57:08 +03:00
mold/test/elf/bsymbolic-functions.sh

44 lines
667 B
Bash
Raw Normal View History

2021-03-02 16:08:06 +03:00
#!/bin/bash
export LC_ALL=C
2021-03-02 16:08:06 +03:00
set -e
CC="${CC:-cc}"
CXX="${CXX:-c++}"
2022-01-24 04:21:08 +03:00
testname=$(basename "$0" .sh)
echo -n "Testing $testname ... "
cd "$(dirname "$0")"/../..
mold="$(pwd)/mold"
2022-01-07 12:06:53 +03:00
t=out/test/elf/$testname
mkdir -p $t
2021-03-02 16:08:06 +03:00
2022-01-07 12:06:53 +03:00
cat <<EOF | $CC -c -o $t/a.o -fPIC -xc -
2021-03-02 16:08:06 +03:00
int foo = 4;
int get_foo() {
return foo;
}
void *bar() {
return bar;
}
EOF
2022-01-07 12:06:53 +03:00
$CC -B. -shared -o $t/b.so $t/a.o -Wl,-Bsymbolic-functions
2021-03-02 16:57:15 +03:00
2022-01-07 12:06:53 +03:00
cat <<EOF | $CC -c -o $t/c.o -xc - -fno-PIE
2021-03-02 16:08:06 +03:00
#include <stdio.h>
extern int foo;
int get_foo();
void *bar();
int main() {
foo = 3;
printf("%d %d %d\n", foo, get_foo(), bar == bar());
}
EOF
2022-01-07 12:06:53 +03:00
$CC -B. -no-pie -o $t/exe $t/c.o $t/b.so
$t/exe | grep -q '3 3 0'
2021-03-02 16:08:06 +03:00
echo OK