score howto special_function final linking output bfd access
Alan Modra
amodra@gmail.com
Fri Apr 3 22:27:44 GMT 2026
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.
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);
--
Alan Modra
More information about the Binutils
mailing list