1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-11 05:46:58 +03:00

Add -Bsymbolic

This commit is contained in:
Rui Ueyama 2021-03-02 21:47:19 +09:00
parent 398f326901
commit bc0379ecd4
2 changed files with 12 additions and 10 deletions

View File

@ -203,6 +203,8 @@ Config parse_nonpositional_args(std::span<std::string_view> args,
conf.dynamic_linker = arg;
} else if (read_flag(args, "export-dynamic") || read_flag(args, "E")) {
conf.export_dynamic = true;
} else if (read_flag(args, "Bsymbolic")) {
conf.Bsymbolic = true;
} else if (read_flag(args, "no-export-dynamic")) {
conf.export_dynamic = false;
} else if (read_arg(args, arg, "e") || read_arg(args, arg, "entry")) {

View File

@ -6,31 +6,31 @@ t=$(pwd)/tmp/$(basename -s .sh $0)
mkdir -p $t
cat <<EOF | cc -shared -fPIC -o $t/a.so -xc - -Wl,-Bsymbolic
void *foo() {
int foo = 4;
int get_foo() {
return foo;
}
EOF
cat <<EOF | cc -fuse-ld=gold -shared -fPIC -o $t/b.so -xc -
void *bar() __attribute__((visibility("protected")));
void *bar() {
return bar;
}
EOF
cat <<EOF | cc -c -o $t/c.o -xc - -fno-PIE
cat <<EOF | cc -c -o $t/b.o -xc - -fno-PIE
#include <stdio.h>
void *foo();
extern int foo;
int get_foo();
void *bar();
int main() {
printf("%p %p %p %p\n", foo, foo(), bar, bar());
foo = 3;
printf("%d %d %d\n", foo, get_foo(), bar == bar());
}
EOF
cc -fuse-ld=gold -no-pie -o $t/exe $t/c.o $t/a.so $t/b.so
$t/exe
cc -fuse-ld=gold -no-pie -o $t/exe $t/b.o $t/a.so
$t/exe | grep -q '3 4 0'
echo OK