[binutils-gdb] score howto special_function final linking output bfd access
Alan Modra
amodra@sourceware.org
Fri Apr 3 22:30:46 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c9c059cbf331df15fc8f55a69757a0c5eda417e3
commit c9c059cbf331df15fc8f55a69757a0c5eda417e3
Author: Alan Modra <amodra@gmail.com>
Date: Sat Apr 4 08:43:06 2026 +1030
score howto special_function final linking output bfd access
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:
---
bfd/elf32-score.c | 4 ++++
bfd/elf32-score7.c | 2 ++
2 files changed, 6 insertions(+)
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);
More information about the Binutils-cvs
mailing list