[binutils-gdb] hppa64: get_opd in elf64_hppa_mark_exported_functions

Alan Modra via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=14de5bdd5f2eecb1e4cb5ef038653cde5be0f127

commit 14de5bdd5f2eecb1e4cb5ef038653cde5be0f127
Author: Alan Modra <[email protected]>
Date:   Mon May 11 09:20:52 2026 +0930

    hppa64: get_opd in elf64_hppa_mark_exported_functions
    
    late_size_sections is too late to be creating a dynamic section, as it
    won't be mapped to an output section.  So don't pretend that this will
    do anything useful, and instead omit the traversal if opd_sec is NULL.
    This bug showed up when using a linker-created dynobj.
    
            * elf64-hppa.c (elf64_hppa_mark_exported_functions): Don't
            attempt to create .opd here.
            (elf64_hppa_late_size_sections): Only mark exported functions
            for space in .opd if .opd exists.
            (elf64_hppa_finalize_dynreloc): Make the test for a discared
            other_rel_sec robust.

Diff:
---
 bfd/elf64-hppa.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 8de91622465..f4b24b294f3 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -1017,10 +1017,6 @@ elf64_hppa_mark_exported_functions (struct elf_link_hash_entry *eh, void *data)
       && eh->root.u.def.section->output_section != NULL
       && eh->type == STT_FUNC)
     {
-      if (! hppa_info->opd_sec
-	  && ! get_opd (hppa_info->root.dynobj, info, hppa_info))
-	return false;
-
       hh->want_opd = 1;
 
       /* Put a flag here for output_symbol_hook.  */
@@ -1646,11 +1642,12 @@ elf64_hppa_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
 
      We have to traverse the main linker hash table since we have to
      find functions which may not have been mentioned in any relocs.  */
-  elf_link_hash_traverse (&hppa_info->root,
-			  (hppa_info->root.dynamic_sections_created
-			   ? elf64_hppa_mark_milli_and_exported_functions
-			   : elf64_hppa_mark_exported_functions),
-			  info);
+  if (hppa_info->opd_sec)
+    elf_link_hash_traverse (&hppa_info->root,
+			    (hppa_info->root.dynamic_sections_created
+			     ? elf64_hppa_mark_milli_and_exported_functions
+			     : elf64_hppa_mark_exported_functions),
+			    info);
 
   if (hppa_info->root.dynamic_sections_created)
     {
@@ -2479,7 +2476,8 @@ elf64_hppa_finalize_dynreloc (struct elf_link_hash_entry *eh,
   if (hppa_info == NULL)
     return false;
 
-  if (discarded_section (hppa_info->other_rel_sec))
+  if (hppa_info->other_rel_sec == NULL
+      || discarded_section (hppa_info->other_rel_sec))
     return true;
 
   if (hh->reloc_entries)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.