segv in coff_aarch64_addr32nb_reloc
authorAlan Modra <amodra@gmail.com>
Thu, 26 Jan 2023 07:55:05 +0000 (18:25 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 26 Jan 2023 21:48:45 +0000 (08:18 +1030)
* 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.

bfd/coff-aarch64.c

index 12e242e18d050d2dbdefd105d52cd5cff451ed82..659cd4f162d1c920cfa38040093188020e4af701 100644 (file)
@@ -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";