PR27493, objcopy --weaken-symbol does not weaken undefined symbols
authorAlan Modra <amodra@gmail.com>
Wed, 3 Mar 2021 04:45:23 +0000 (15:15 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 3 Mar 2021 07:16:52 +0000 (17:46 +1030)
PR 27493
* objcopy.c (filter_symbols): Apply --weaken to undefined symbols.
* NEWS: Mention feature.

binutils/ChangeLog
binutils/NEWS
binutils/objcopy.c

index 3aec667d16af27f848421c377b78c438bb07e12b..10ff1679a4e925f346791514799e58f782ebea5f 100644 (file)
@@ -1,3 +1,9 @@
+2021-03-03  Alan Modra  <amodra@gmail.com>
+
+       PR 27493
+       * objcopy.c (filter_symbols): Apply --weaken to undefined symbols.
+       * NEWS: Mention feature.
+
 2021-03-01  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR binutils/27486
index d66944e95e04582af50104bd63bc4b13515e9aae..461ddab69028b81dbd1110f233ba981f1d0e231b 100644 (file)
@@ -1,5 +1,8 @@
 -*- text -*-
 
+* objcopy --weaken, --weaken-symbol and --weaken-symbols now make undefined
+  symbols weak on targets that support weak symbols.
+
 * Readelf and objdump can now display and use the contents of .debug_sup
   sections.
 
index 041aceaeefe89defdde746ddb86f97bf1ef3b365..99e6cad72e582dd870dc837f08e077f4c11eed82 100644 (file)
@@ -1673,7 +1673,8 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
 
       if (keep)
        {
-         if ((flags & BSF_GLOBAL) != 0
+         if (((flags & BSF_GLOBAL) != 0
+              || undefined)
              && (weaken || is_specified_symbol (name, weaken_specific_htab)))
            {
              sym->flags &= ~ BSF_GLOBAL;