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

41 lines
680 B
Bash
Raw Normal View History

2021-03-02 14:24:31 +03:00
#!/bin/bash
export LANG=
2021-03-02 14:24:31 +03:00
set -e
cd "$(dirname "$0")"
2021-09-08 13:11:48 +03:00
mold=`pwd`/../../mold
echo -n "Testing $(basename -s .sh "$0") ... "
t=$(pwd)/../../out/test/elf/$(basename -s .sh "$0")
mkdir -p "$t"
2021-03-02 14:24:31 +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() {
2021-03-02 14:24:31 +03:00
return foo;
}
void *bar() {
return bar;
}
EOF
clang -fuse-ld="$mold" -shared -fPIC -o "$t"/b.so "$t"/a.o -Wl,-Bsymbolic
cat <<EOF | cc -c -o "$t"/c.o -xc - -fno-PIE
2021-03-02 14:24:31 +03:00
#include <stdio.h>
2021-03-02 15:47:19 +03:00
extern int foo;
int get_foo();
2021-03-02 14:24:31 +03:00
void *bar();
int main() {
2021-03-02 15:47:19 +03:00
foo = 3;
printf("%d %d %d\n", foo, get_foo(), bar == bar());
2021-03-02 14:24:31 +03:00
}
EOF
clang -fuse-ld="$mold" -no-pie -o "$t"/exe "$t"/c.o "$t"/b.so
"$t"/exe | grep -q '3 4 0'
2021-03-02 14:24:31 +03:00
echo OK