ld: Add -Bno-symbolic

PR 27834
	* ldlex.h (enum option_values): Add OPTION_NO_SYMBOLIC.
	* lexsup.c (ld_options): Add -Bno-symbolic.
	(parse_args): Handle -Bno-symbolic.
	* ld.texi: Document -Bno-symbolic.
	* NEWS: Mention -Bno-symbolic.
	* testsuite/ld-elf/shared.exp: Add a test.
This commit is contained in:
Fangrui Song 2021-05-11 23:10:45 -07:00 committed by Alan Modra
parent 4863cddb50
commit cf893b0ef7
6 changed files with 30 additions and 0 deletions

View File

@ -1,3 +1,13 @@
2021-05-13 Fangrui Song <maskray@google.com>
PR 27834
* ldlex.h (enum option_values): Add OPTION_NO_SYMBOLIC.
* lexsup.c (ld_options): Add -Bno-symbolic.
(parse_args): Handle -Bno-symbolic.
* ld.texi: Document -Bno-symbolic.
* NEWS: Mention -Bno-symbolic.
* testsuite/ld-elf/shared.exp: Add a test.
2021-05-12 Richard Earnshaw <rearnsha@arm.com> 2021-05-12 Richard Earnshaw <rearnsha@arm.com>
* testsuite/ld-arm/arm-elf.exp (farcall test for v8-m.mainline): * testsuite/ld-arm/arm-elf.exp (farcall test for v8-m.mainline):

View File

@ -8,6 +8,8 @@
* Add -z start-stop-gc to disable special treatment of __start_*/__stop_* * Add -z start-stop-gc to disable special treatment of __start_*/__stop_*
references when --gc-sections. references when --gc-sections.
* Add -Bno-symbolic to cancel -Bsymbolic and -Bsymbolic-functions.
Changes in 2.36: Changes in 2.36:
* Add libdep plugin, for linking dependencies of static libraries that * Add libdep plugin, for linking dependencies of static libraries that

View File

@ -1633,6 +1633,11 @@ symbols to the definition within the shared library, if any.
This option is only meaningful on ELF platforms which support shared This option is only meaningful on ELF platforms which support shared
libraries. libraries.
@kindex -Bno-symbolic
@item -Bno-symbolic
This option can cancel previously specified @samp{-Bsymbolic} and
@samp{-Bsymbolic-functions}.
@kindex --dynamic-list=@var{dynamic-list-file} @kindex --dynamic-list=@var{dynamic-list-file}
@item --dynamic-list=@var{dynamic-list-file} @item --dynamic-list=@var{dynamic-list-file}
Specify the name of a dynamic list file to the linker. This is Specify the name of a dynamic list file to the linker. This is

View File

@ -54,6 +54,7 @@ enum option_values
OPTION_OFORMAT, OPTION_OFORMAT,
OPTION_RELAX, OPTION_RELAX,
OPTION_NO_RELAX, OPTION_NO_RELAX,
OPTION_NO_SYMBOLIC,
OPTION_RETAIN_SYMBOLS_FILE, OPTION_RETAIN_SYMBOLS_FILE,
OPTION_RPATH, OPTION_RPATH,
OPTION_RPATH_LINK, OPTION_RPATH_LINK,

View File

@ -302,6 +302,8 @@ static const struct ld_option ld_options[] =
'\0', NULL, NULL, ONE_DASH }, '\0', NULL, NULL, ONE_DASH },
{ {"static", no_argument, NULL, OPTION_NON_SHARED}, { {"static", no_argument, NULL, OPTION_NON_SHARED},
'\0', NULL, NULL, ONE_DASH }, '\0', NULL, NULL, ONE_DASH },
{ {"Bno-symbolic", no_argument, NULL, OPTION_NO_SYMBOLIC},
'\0', NULL, N_("Don't bind global references locally"), ONE_DASH },
{ {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC}, { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
'\0', NULL, N_("Bind global references locally"), ONE_DASH }, '\0', NULL, N_("Bind global references locally"), ONE_DASH },
{ {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS}, { {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS},
@ -1301,6 +1303,9 @@ parse_args (unsigned argc, char **argv)
case OPTION_STATS: case OPTION_STATS:
config.stats = true; config.stats = true;
break; break;
case OPTION_NO_SYMBOLIC:
opt_symbolic = symbolic_unset;
break;
case OPTION_SYMBOLIC: case OPTION_SYMBOLIC:
opt_symbolic = symbolic; opt_symbolic = symbolic;
break; break;

View File

@ -618,6 +618,10 @@ set build_tests {
{"Build libdl2k.so with --export-dynamic-symbol-list=dl2.list and -Bsymbolic" {"Build libdl2k.so with --export-dynamic-symbol-list=dl2.list and -Bsymbolic"
"-shared -Wl,--export-dynamic-symbol-list=dl2.list,-Bsymbolic" "-fPIC" "-shared -Wl,--export-dynamic-symbol-list=dl2.list,-Bsymbolic" "-fPIC"
{dl2.c dl2xxx.c} {} "libdl2k.so"} {dl2.c dl2xxx.c} {} "libdl2k.so"}
# Check that -Bno-symbolic cancels -Bsymbolic.
{"Build libdl2l.so with -Bsymbolic -Bno-symbolic and --export-dynamic-symbol=foo"
"-shared -Wl,-Bsymbolic,-Bno-symbolic,--export-dynamic-symbol=foo" "-fPIC"
{dl2.c dl2xxx.c} {} "libdl2l.so"}
{"Build libdl4a.so with --dynamic-list=dl4.list" {"Build libdl4a.so with --dynamic-list=dl4.list"
"-shared -Wl,--dynamic-list=dl4.list" "-fPIC" "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
{dl4.c dl4xxx.c} {} "libdl4a.so"} {dl4.c dl4xxx.c} {} "libdl4a.so"}
@ -1028,6 +1032,9 @@ set run_tests [list \
[list "Run with libdl2k.so" \ [list "Run with libdl2k.so" \
"-Wl,--no-as-needed tmpdir/libdl2k.so" "" \ "-Wl,--no-as-needed tmpdir/libdl2k.so" "" \
{dl2main.c} "dl2k" "dl2a.out" ] \ {dl2main.c} "dl2k" "dl2a.out" ] \
[list "Run with libdl2l.so" \
"-Wl,--no-as-needed tmpdir/libdl2l.so" "" \
{dl2main.c} "dl2l" "dl2b.out" ] \
[list "Run with libdl4a.so" \ [list "Run with libdl4a.so" \
"-Wl,--no-as-needed tmpdir/libdl4a.so" "" \ "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
{dl4main.c} "dl4a" "dl4a.out" "-fPIC"] \ {dl4main.c} "dl4a" "dl4a.out" "-fPIC"] \