ld: Add -Bno-symbolic
authorFangrui Song <maskray@google.com>
Wed, 12 May 2021 06:10:45 +0000 (23:10 -0700)
committerAlan Modra <amodra@gmail.com>
Thu, 13 May 2021 03:23:49 +0000 (12:53 +0930)
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.

ld/ChangeLog
ld/NEWS
ld/ld.texi
ld/ldlex.h
ld/lexsup.c
ld/testsuite/ld-elf/shared.exp

index 77b10eb86df8d657750b34cb0590a218daaa7ff5..e9aae885988b39d2716a20a0f3d88993091deaa0 100644 (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>
 
        * testsuite/ld-arm/arm-elf.exp (farcall test for v8-m.mainline):
diff --git a/ld/NEWS b/ld/NEWS
index d1aa3b07000b4d08a53758549ae6c2c6ab343a85..a5ed9058c046ecd9279587dde53e8b0bf50aa221 100644 (file)
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -8,6 +8,8 @@
 * Add -z start-stop-gc to disable special treatment of __start_*/__stop_*
   references when --gc-sections.
 
+* Add -Bno-symbolic to cancel -Bsymbolic and -Bsymbolic-functions.
+
 Changes in 2.36:
 
 * Add libdep plugin, for linking dependencies of static libraries that
index fe653daacd7a02d2becff26cc15bc2542c425be4..29874688a73a427524c1fecc7f5e3898bfa0034c 100644 (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
 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}
 @item --dynamic-list=@var{dynamic-list-file}
 Specify the name of a dynamic list file to the linker.  This is
index 3ce1ad4471643e5d6edeece9ed77d595817b2cc0..e0f0241d9cc92aca972b40cfa4d2fd37490bc729 100644 (file)
@@ -54,6 +54,7 @@ enum option_values
   OPTION_OFORMAT,
   OPTION_RELAX,
   OPTION_NO_RELAX,
+  OPTION_NO_SYMBOLIC,
   OPTION_RETAIN_SYMBOLS_FILE,
   OPTION_RPATH,
   OPTION_RPATH_LINK,
index f6b6b2ec20274bdadd9042020cc8810544dde6c5..dcb2d9d9ab39b8686ee868b79623363f984a0712 100644 (file)
@@ -302,6 +302,8 @@ static const struct ld_option ld_options[] =
     '\0', NULL, NULL, ONE_DASH },
   { {"static", no_argument, NULL, OPTION_NON_SHARED},
     '\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},
     '\0', NULL, N_("Bind global references locally"), ONE_DASH },
   { {"Bsymbolic-functions", no_argument, NULL, OPTION_SYMBOLIC_FUNCTIONS},
@@ -1301,6 +1303,9 @@ parse_args (unsigned argc, char **argv)
        case OPTION_STATS:
          config.stats = true;
          break;
+       case OPTION_NO_SYMBOLIC:
+         opt_symbolic = symbolic_unset;
+         break;
        case OPTION_SYMBOLIC:
          opt_symbolic = symbolic;
          break;
index 6bf49785a5555ff469acebba3bcba8b163255748..d00358e47ef595b9cdf6f87b2613f29fedbf3b99 100644 (file)
@@ -618,6 +618,10 @@ set build_tests {
   {"Build libdl2k.so with --export-dynamic-symbol-list=dl2.list and -Bsymbolic"
    "-shared -Wl,--export-dynamic-symbol-list=dl2.list,-Bsymbolic" "-fPIC"
    {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"
    "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
    {dl4.c dl4xxx.c} {} "libdl4a.so"}
@@ -1028,6 +1032,9 @@ set run_tests [list \
     [list "Run with libdl2k.so" \
      "-Wl,--no-as-needed tmpdir/libdl2k.so" "" \
      {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" \
      "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
      {dl4main.c} "dl4a" "dl4a.out" "-fPIC"] \