+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):
 
 * 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
 
 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
 
   OPTION_OFORMAT,
   OPTION_RELAX,
   OPTION_NO_RELAX,
+  OPTION_NO_SYMBOLIC,
   OPTION_RETAIN_SYMBOLS_FILE,
   OPTION_RPATH,
   OPTION_RPATH_LINK,
 
     '\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},
        case OPTION_STATS:
          config.stats = true;
          break;
+       case OPTION_NO_SYMBOLIC:
+         opt_symbolic = symbolic_unset;
+         break;
        case OPTION_SYMBOLIC:
          opt_symbolic = symbolic;
          break;
 
   {"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"}
     [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"] \