aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-01-24 12:39:07 +1030
committerAlan Modra <amodra@gmail.com>2021-01-24 16:19:53 +1030
commit1aaad1d55d784670f112954fdecbd0261bfdffd7 (patch)
tree5e45c1277c6736dfc886b0f8db4c9c7441a6d213
parent74c1e3df55c9e418e231a1ef36ff706688a3088b (diff)
downloadgdb-1aaad1d55d784670f112954fdecbd0261bfdffd7.zip
gdb-1aaad1d55d784670f112954fdecbd0261bfdffd7.tar.gz
gdb-1aaad1d55d784670f112954fdecbd0261bfdffd7.tar.bz2
PR27228, .reloc wrong symbol emitted for undefined local symbol
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. (cherry picked from commit 68fcee4fa753f6488c9f90610da2f5a5a95d5a1f)
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/write.c4
2 files changed, 9 insertions, 1 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 0c0c1e6..10d9ae3 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -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
diff --git a/gas/write.c b/gas/write.c
index 75ba971..95922bb 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -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