[binutils-gdb] segv in coff_aarch64_addr32nb_reloc

Alan Modra amodra@sourceware.org
Thu Jan 26 21:53:45 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c37de2981558eb7ba4aa473ab214d8f2fb0c9876

commit c37de2981558eb7ba4aa473ab214d8f2fb0c9876
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Jan 26 18:25:05 2023 +1030

    segv in coff_aarch64_addr32nb_reloc
    
            * coff-aarch64.c (coff_aarch64_addr32nb_reloc): When output_bfd
            is NULL (which it is for objdump -W) get the output bfd via the
            input section.

Diff:
---
 bfd/coff-aarch64.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c
index 12e242e18d0..659cd4f162d 100644
--- a/bfd/coff-aarch64.c
+++ b/bfd/coff-aarch64.c
@@ -189,9 +189,10 @@ coff_aarch64_addr32nb_reloc (bfd *abfd,
 		       + symbol->section->output_section->vma);
       bfd_vma addend = bfd_getl_signed_32 (data + reloc_entry->address);
       relocation += addend;
-      if (bfd_get_flavour (output_bfd) == bfd_target_coff_flavour
-	  && obj_pe (output_bfd))
-	relocation -= pe_data (output_bfd)->pe_opthdr.ImageBase;
+      bfd *obfd = input_section->output_section->owner;
+      if (bfd_get_flavour (obfd) == bfd_target_coff_flavour
+	  && obj_pe (obfd))
+	relocation -= pe_data (obfd)->pe_opthdr.ImageBase;
       else
 	{
 	  *error_message = "unsupported";


More information about the Binutils-cvs mailing list