public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Arm64/ELF: accept relocations against STN_UNDEF
@ 2023-03-23 14:30 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-03-23 14:30 UTC (permalink / raw)
  To: Binutils; +Cc: Richard Earnshaw, Marcus Shawcroft

While only a secondary issue there, the testcase of PR gas/27212 exposes
an oversight in relocation handling: Just like e.g. Arm32, which has a
similar comment and a similar check, relocations against STN_UNDEF have
to be permitted to satisfy the ELF spec.

--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -6779,8 +6779,12 @@ elfNN_aarch64_relocate_section (bfd *out
 
 	  /* An object file might have a reference to a local
 	     undefined symbol.  This is a daft object file, but we
-	     should at least do something about it.  */
+	     should at least do something about it.  NONE and NULL
+	     relocations do not use the symbol and are explicitly
+	     allowed to use an undefined one, so allow those.
+	     Likewise for relocations against STN_UNDEF.  */
 	  if (r_type != R_AARCH64_NONE && r_type != R_AARCH64_NULL
+	      && r_symndx != STN_UNDEF
 	      && bfd_is_und_section (sec)
 	      && ELF_ST_BIND (sym->st_info) != STB_WEAK)
 	    (*info->callbacks->undefined_symbol)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-23 14:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-23 14:30 [PATCH] Arm64/ELF: accept relocations against STN_UNDEF Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).