This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Re: hppa64-hp-hpux11.00: invalid string offset for section .dynstr


> 2002-06-21  John David Anglin  <dave@hiauly1.hia.nrc.ca>
> 
> 	* elf64-hppa.c (clobber_millicode_symbols): New function.
> 	(allocate_global_data_dlt):  Don't add millicode symbols to dynamic
> 	symbol table.
> 	(allocate_global_data_opd, allocate_dynrel_entries): Likewise.
> 	(elf64_hppa_size_dynamic_sections): Traverse hash table to keep
> 	millicode symbols out of dynamic symbol table.
> 	(elf64_hppa_finish_dynamic_symbol): Remove code to keep millicode
> 	symbols out of dynamic symbol table.

In thinking more about the above patch, I realized that it's possible
to save one traversal of the hash table by combining the marking of
exported functions and the millicode symbol processing.

Tested with binutils and mainline gcc builds on hppa64-hp-hpux11.00.
No regressions were observed.

Please install if ok.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2002-06-23  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* elf64-hppa.c (elf64_hppa_mark_milli_and_exported_functions): New
	function.
	(allocate_global_data_dlt):  Don't add millicode symbols to dynamic
	symbol table.
	(allocate_global_data_opd, allocate_dynrel_entries): Likewise.
	(elf64_hppa_size_dynamic_sections): Revise to use
	elf64_hppa_mark_milli_and_exported_functions.
	(elf64_hppa_finish_dynamic_symbol): Remove code to keep millicode
	symbols out of dynamic symbol table.

Index: elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.23
diff -u -3 -p -r1.23 elf64-hppa.c
--- elf64-hppa.c	16 Jun 2002 15:32:08 -0000	1.23
+++ elf64-hppa.c	23 Jun 2002 04:06:36 -0000
@@ -195,6 +195,9 @@ static boolean elf64_hppa_create_dynamic
 static boolean elf64_hppa_adjust_dynamic_symbol
   PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
 
+static boolean elf64_hppa_mark_milli_and_exported_functions
+  PARAMS ((struct elf_link_hash_entry *, PTR));
+
 static boolean elf64_hppa_size_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
 
@@ -1073,7 +1076,7 @@ allocate_global_data_dlt (dyn_h, data)
 	     table since we might need to create a dynamic relocation
 	     against it.  */
 	  if (! h
-	      || (h && h->dynindx == -1))
+	      || (h->dynindx == -1 && h->type != STT_PARISC_MILLI))
 	    {
 	      bfd *owner;
 	      owner = (h ? h->root.u.def.section->owner : dyn_h->owner);
@@ -1168,7 +1171,7 @@ allocate_global_data_opd (dyn_h, data)
 	 we have to create an opd descriptor.  */
       else if (x->info->shared
 	       || h == NULL
-	       || h->dynindx == -1
+	       || (h->dynindx == -1 && h->type != STT_PARISC_MILLI)
 	       || (h->root.type == bfd_link_hash_defined
 		   || h->root.type == bfd_link_hash_defweak))
 	{
@@ -1542,7 +1545,8 @@ allocate_dynrel_entries (dyn_h, data)
       /* Make sure this symbol gets into the dynamic symbol table if it is
 	 not already recorded.  ?!? This should not be in the loop since
 	 the symbol need only be added once.  */
-      if (dyn_h->h == 0 || dyn_h->h->dynindx == -1)
+      if (dyn_h->h == 0
+	  || (dyn_h->h->dynindx == -1 && dyn_h->h->type != STT_PARISC_MILLI))
 	if (!_bfd_elf64_link_record_local_dynamic_symbol
 	    (x->info, rent->sec->owner, dyn_h->sym_indx))
 	  return false;
@@ -1610,6 +1614,36 @@ elf64_hppa_adjust_dynamic_symbol (info, 
   return true;
 }
 
+/* This function is called via elf_link_hash_traverse to mark millicode
+   symbols with a dynindx of -1 and to remove the string table reference
+   from the dynamic symbol table.  If the symbol is not a millicode symbol,
+   elf64_hppa_mark_exported_functions is called.  */
+
+static boolean
+elf64_hppa_mark_milli_and_exported_functions (h, data)
+     struct elf_link_hash_entry *h;
+     PTR data;
+{
+  struct bfd_link_info *info = (struct bfd_link_info *)data;
+  struct elf_link_hash_entry *elf = h;
+
+  if (elf->root.type == bfd_link_hash_warning)
+    elf = (struct elf_link_hash_entry *) elf->root.u.i.link;
+
+  if (elf->type == STT_PARISC_MILLI)
+    {
+      if (elf->dynindx != -1)
+	{
+	  elf->dynindx = -1;
+	  _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
+				  elf->dynstr_index);
+	}
+      return true;
+    }
+
+  return elf64_hppa_mark_exported_functions (h, data);
+}
+
 /* Set the final sizes of the dynamic sections and allocate memory for
    the contents of our special sections.  */
 
@@ -1631,6 +1665,19 @@ elf64_hppa_size_dynamic_sections (output
   dynobj = elf_hash_table (info)->dynobj;
   BFD_ASSERT (dynobj != NULL);
 
+  /* Mark each function this program exports so that we will allocate
+     space in the .opd section for each function's FPTR.  If we are
+     creating dynamic sections, change the dynamic index of millicode
+     symbols to -1 and remove them from the string table for .dynstr.
+
+     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 (elf_hash_table (info),
+			  (elf_hash_table (info)->dynamic_sections_created
+			   ? elf64_hppa_mark_milli_and_exported_functions
+			   : elf64_hppa_mark_exported_functions),
+			  info);
+
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
@@ -1675,15 +1722,6 @@ elf64_hppa_size_dynamic_sections (output
       hppa_info->stub_sec->_raw_size = data.ofs;
     }
 
-  /* Mark each function this program exports so that we will allocate
-     space in the .opd section for each function's FPTR.
-
-     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 (elf_hash_table (info),
-			  elf64_hppa_mark_exported_functions,
-			  info);
-
   /* Allocate space for entries in the .opd section.  */
   if (elf64_hppa_hash_table (info)->opd_sec)
     {
@@ -2098,11 +2136,6 @@ elf64_hppa_finish_dynamic_symbol (output
       bfd_put_32 (stub->owner, (bfd_vma) insn,
 		  stub->contents + dyn_h->stub_offset + 8);
     }
-
-  /* Millicode symbols should not be put in the dynamic
-     symbol table under any circumstances.  */
-  if (ELF_ST_TYPE (sym->st_info) == STT_PARISC_MILLI)
-    h->dynindx = -1;
 
   return true;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]