score howto special_function final linking output bfd access

Message ID adA-4JQN6nbYMO_Q@squeak.grove.modra.org
State New
Headers
Series score howto special_function final linking output bfd access |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Alan Modra April 3, 2026, 10:27 p.m. UTC
  Like commit 804439b4d7a8, avoid segfaults when the hack to access
the output bfd won't work, eg. when the sym is absolute.

	* elf32-score.c (score_elf_gprel15_reloc): Return bfd_reloc_undefined
	when output_bfd cannot be determined from the symbol.
	(score_elf_gprel32_reloc): Likewise.
	* elf32-score7.c (score_elf_gprel32_reloc): Likewise.
  

Patch

diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 125b2cc804b..b21992a4a6b 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -545,6 +545,8 @@  score_elf_gprel15_reloc (bfd *abfd,
     {
       relocateable = false;
       output_bfd = symbol->section->output_section->owner;
+      if (output_bfd == NULL)
+	return bfd_reloc_undefined;
     }
 
   ret = score_elf_final_gp (output_bfd, symbol, relocateable, error_message, &gp);
@@ -583,6 +585,8 @@  score_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
     {
       relocatable = false;
       output_bfd = symbol->section->output_section->owner;
+      if (output_bfd == NULL)
+	return bfd_reloc_undefined;
     }
 
   ret = score_elf_final_gp (output_bfd, symbol, relocatable, error_message, &gp);
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index 387421f18ff..e0220a27f8b 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -485,6 +485,8 @@  score_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
     {
       relocatable = false;
       output_bfd = symbol->section->output_section->owner;
+      if (output_bfd == NULL)
+	return bfd_reloc_undefined;
     }
 
   ret = score_elf_final_gp (output_bfd, symbol, relocatable, error_message, &gp);