]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
score howto special_function final linking output bfd access
authorAlan Modra <amodra@gmail.com>
Fri, 3 Apr 2026 22:13:06 +0000 (08:43 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 3 Apr 2026 22:22:57 +0000 (08:52 +1030)
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.

bfd/elf32-score.c
bfd/elf32-score7.c

index 125b2cc804ba2566f121fd51ab4fd1a4c65a8ed3..b21992a4a6bcf0b20efea6f90af0d069a7251136 100644 (file)
@@ -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);
index 387421f18ffbbe67ed6a525903f8b0bab30e461e..e0220a27f8b3ddd5ded23d9ad14327664971063a 100644 (file)
@@ -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);