mirror of
https://github.com/rui314/mold.git
synced 2024-11-11 05:46:58 +03:00
Add -Bsymbolic
This commit is contained in:
parent
398f326901
commit
bc0379ecd4
@ -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")) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user