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

24 lines
404 B
Bash
Raw Permalink Normal View History

2021-03-02 14:24:31 +03:00
#!/bin/bash
. $(dirname $0)/common.inc
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'