PR27228, .reloc wrong symbol emitted for undefined local symbol
authorAlan Modra <amodra@gmail.com>
Sun, 24 Jan 2021 02:09:07 +0000 (12:39 +1030)
committerAlan Modra <amodra@gmail.com>
Sun, 24 Jan 2021 05:46:45 +0000 (16:16 +1030)
Local symbols are of course supposed to be defined by their object
file, but in other cases a local symbol is promoted to global by gas
if undefined and referenced.  This patch stops gas wrongly replacing a
local undefined symbol with the undefined section symbol, resulting in
a .reloc undefined local symbol being emitted as global.

PR 27228
* write.c (resolve_reloc_expr_symbols): Don't assume local symbol
is defined.

gas/ChangeLog
gas/write.c

index 74185318b17eca1ee544e279589e775d5b0fdb41..4ac29870e630a139b42d54b71013374165c3d45b 100644 (file)
@@ -1,3 +1,9 @@
+2021-01-24  Alan Modra  <amodra@gmail.com>
+
+       PR 27228
+       * write.c (resolve_reloc_expr_symbols): Don't assume local symbol
+       is defined.
+
 2021-01-21  Alan Modra  <amodra@gmail.com>
 
        PR 27221
index 75ba971eb4bbde408b505110c5ae817b9486134a..95922bb25a0cc52220ff7d59847a95f7d04b4469 100644 (file)
@@ -737,7 +737,9 @@ resolve_reloc_expr_symbols (void)
                 prevent the offset from overflowing the relocated field,
                 unless it has enough bits to cover the whole address
                 space.  */
-             if (S_IS_LOCAL (sym) && !symbol_section_p (sym)
+             if (S_IS_LOCAL (sym)
+                 && S_IS_DEFINED (sym)
+                 && !symbol_section_p (sym)
                  && (sec->use_rela_p
                      || (howto->partial_inplace
                          && (!howto->pc_relative