[PATCH] Fix segmentation fault in bfd/elf32-hppa.c

John David Anglin dave.anglin@bell.net
Fri Dec 15 21:13:50 GMT 2023


After retesting, I committed the following change.  Hopefully, there aren't
other types that need handling.

Dave
---

Fix segmentation fault in bfd/elf32-hppa.c

2023-12-15  John David Anglin  <danglin@gcc.gnu.org>

     PR ld/31148

bfd/ChangeLog:

     * elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Output
     relative reloc only when eh->root.type is bfd_link_hash_defined
     or bfd_link_hash_defweak.

diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 44129c80138..d64ca7528a0 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -4216,7 +4216,9 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
           file, we just want to emit a RELATIVE reloc.  The entry
           in the global offset table will already have been
           initialized in the relocate_section function.  */
-      if (!is_dyn)
+      if (!is_dyn
+          && (eh->root.type == bfd_link_hash_defined
+          || eh->root.type == bfd_link_hash_defweak))
          {
            rela.r_info = ELF32_R_INFO (0, R_PARISC_DIR32);
            rela.r_addend = (eh->root.u.def.value



More information about the Binutils mailing list