[binutils-gdb] hppa64: Add code to intialize __data_seg section symbol

John David Anglin danglin@sourceware.org
Thu Oct 30 20:30:37 GMT 2025


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

commit de9efc361bb999903909280462e81edd73cf8c7e
Author: John David Anglin <danglin@gcc.gnu.org>
Date:   Thu Oct 30 16:15:31 2025 -0400

    hppa64: Add code to intialize __data_seg section symbol
    
    2025-10-30  John David Anglin  <danglin@gcc.gnu.org>
    
    bfd/ChangeLog:
    
            * elf64-hppa.c (struct elf64_hppa_link_hash_table): Add
            data_segment field.
            (allocate_global_data_opd): Move code to initialize text
            segment section symbol to elf64_hppa_late_size_sections.
            (elf64_hppa_late_size_sections): Add code to setup
            __data_seg section symbol.

Diff:
---
 bfd/elf64-hppa.c | 76 +++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 50 insertions(+), 26 deletions(-)

diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index e2e5e8ea081..cc4c64fda53 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -137,8 +137,9 @@ struct elf64_hppa_link_hash_table
   bfd_vma text_segment_base;
   bfd_vma data_segment_base;
 
-  /* Hash entry for __text_seg.  */
+  /* Hash entries for __text_seg and __data_seg.  */
   struct elf_link_hash_entry *text_segment;
+  struct elf_link_hash_entry *data_segment;
 
   /* We build tables to map from an input section back to its
      symbol index.  This is the BFD for which we currently have
@@ -1123,31 +1124,6 @@ allocate_global_data_opd (struct elf_link_hash_entry *eh, void *data)
 		return false;
 	    }
 
-	  /* Add __text_seg symbol to dynamic table.  */
-	  if (bfd_link_pic (x->info) && !hppa_info->text_segment)
-	    {
-	      struct elf_link_hash_entry *nh;
-
-	      nh = elf_link_hash_lookup (elf_hash_table (x->info),
-					 "__text_seg", true, false, false);
-	      if (nh != NULL)
-		{
-		  asection *s;
-
-		  s = bfd_get_section_by_name (x->info->output_bfd,
-					       ".dynamic");
-
-		  nh->type = STT_SECTION;
-		  nh->root.type = bfd_link_hash_defined;
-		  nh->root.u.def.value = 0;
-		  nh->root.u.def.section = s;
-		  nh->forced_local = 1;
-		  nh->other = STV_DEFAULT;
-		  bfd_elf_link_record_dynamic_symbol (x->info, nh);
-		  hppa_info->text_segment = nh;
-		}
-	    }
-
 	  hh->opd_offset = x->ofs;
 	  x->ofs += OPD_ENTRY_SIZE;
 	}
@@ -1733,6 +1709,54 @@ elf64_hppa_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
 	}
     }
 
+  /* Add __text_seg section symbol to dynamic table.  */
+  if (bfd_link_pic (info) && !hppa_info->text_segment)
+    {
+      struct elf_link_hash_entry *nh;
+
+      nh = elf_link_hash_lookup (elf_hash_table (info),
+				 "__text_seg", true, false, false);
+      if (nh != NULL)
+	{
+	  asection *s;
+
+	  s = bfd_get_section_by_name (info->output_bfd, ".dynamic");
+
+	  nh->type = STT_SECTION;
+	  nh->root.type = bfd_link_hash_defined;
+	  nh->root.u.def.value = 0;
+	  nh->root.u.def.section = s;
+	  nh->forced_local = 1;
+	  nh->other = STV_DEFAULT;
+	  bfd_elf_link_record_dynamic_symbol (info, nh);
+	  hppa_info->text_segment = nh;
+	}
+    }
+
+  /* Add __data_seg section symbol to dynamic table.  */
+  if (bfd_link_pic (info) && !hppa_info->data_segment)
+    {
+      struct elf_link_hash_entry *nh;
+
+      nh = elf_link_hash_lookup (elf_hash_table (info),
+				 "__data_seg", true, false, false);
+      if (nh != NULL)
+	{
+	  asection *s;
+
+	  s = bfd_get_section_by_name (info->output_bfd, ".data");
+
+	  nh->type = STT_SECTION;
+	  nh->root.type = bfd_link_hash_defined;
+	  nh->root.u.def.value = 0;
+	  nh->root.u.def.section = s;
+	  nh->forced_local = 1;
+	  nh->other = STV_DEFAULT;
+	  bfd_elf_link_record_dynamic_symbol (info, nh);
+	  hppa_info->data_segment = nh;
+	}
+    }
+
   /* Allocate the GOT entries.  */
 
   data.info = info;


More information about the Binutils-cvs mailing list