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]

Re: segfault in ld


On Tue, Nov 06, 2001 at 06:51:26PM -0800, Eric M. Christopher wrote:
> This patch:
> 
> 2001-11-06  H.J. Lu  (hjl@gnu.org)
> 
> 	* elflink.h (elf_link_input_bfd): Complain relocs against
> 	discarded sections.
> 
> causes ld to segfault for the mips-elf target when linking executables.
> Please fix this or revert this patch.

Applying..

	* elflink.h (elf_link_input_bfd <removed linkonce relocs>): Fix
	bad symtab segfault.  Formatting and warning fixes.  Improve
	error message for internationalisation.

-- 
Alan Modra

Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.120
diff -u -p -r1.120 elflink.h
--- elflink.h	2001/11/06 17:49:38	1.120
+++ elflink.h	2001/11/07 03:55:57
@@ -6123,9 +6123,9 @@ elf_link_input_bfd (finfo, input_bfd)
 	    Elf_Internal_Rela *rel, *relend;
 	    /* Run through the relocs looking for any against symbols
 	       from discarded sections and section symbols from
-	       removed link-once sections. Complain about relocs
-	       against discarded sections. Zero relocs against removed
-	       link-once sections. We should really complain if
+	       removed link-once sections.  Complain about relocs
+	       against discarded sections.  Zero relocs against removed
+	       link-once sections.  We should really complain if
 	       anything in the final link tries to use it, but
 	       DWARF-based exception handling might have an entry in
 	       .eh_frame to describe a routine in the linkonce section,
@@ -6143,16 +6143,18 @@ elf_link_input_bfd (finfo, input_bfd)
 		  {
 		    struct elf_link_hash_entry *h;
 
-		    h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+		    h = sym_hashes[r_symndx - extsymoff];
 		    while (h->root.type == bfd_link_hash_indirect
 			   || h->root.type == bfd_link_hash_warning)
 		      h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
 		    /* Complain if the definition comes from a
 		       discarded section.  */
 		    if ((h->root.type == bfd_link_hash_defined
 			 || h->root.type == bfd_link_hash_defweak)
 			&& ! bfd_is_abs_section (h->root.u.def.section)
-			&& bfd_is_abs_section (h->root.u.def.section->output_section))
+			&& bfd_is_abs_section (h->root.u.def.section
+					       ->output_section))
 		      {
 #if BFD_VERSION_DATE < 20031005
 			if ((o->flags & SEC_DEBUGGING) != 0)
@@ -6194,7 +6196,7 @@ elf_link_input_bfd (finfo, input_bfd)
 #if BFD_VERSION_DATE > 20021005
 				(*finfo->info->callbacks->warning)
 				  (finfo->info,
-				   _("warning: relocation against removed section; zeroing"),
+				   _("warning: relocation against removed section"),
 				   NULL, input_bfd, o, rel->r_offset);
 #endif
 				memset (rel, 0, sizeof (*rel));
@@ -6203,21 +6205,21 @@ elf_link_input_bfd (finfo, input_bfd)
 #endif
 			      {
 				boolean ok;
-				const char *msg =
-				  _("local symbols in discarded section");
-				char *buf
-				  = (char *) bfd_malloc
-				      (strlen (sec->name) + 3
-				       + strlen (msg));
+				const char *msg
+				  = _("local symbols in discarded section %s");
+				bfd_size_type amt
+				  = strlen (sec->name) + strlen (msg) - 1;
+				char *buf = (char *) bfd_malloc (amt);
+
 				if (buf != NULL)
-				  sprintf (buf, "%s: %s", msg,
-					   sec->name);
+				  sprintf (buf, msg, sec->name);
 				else
 				  buf = (char *) sec->name;
-				ok = (*finfo->info->callbacks->undefined_symbol)
-				       (finfo->info, buf,
-					input_bfd, o, rel->r_offset,
-					true);
+				ok = (*finfo->info->callbacks
+				      ->undefined_symbol) (finfo->info, buf,
+							   input_bfd, o,
+							   rel->r_offset,
+							   true);
 				if (buf != sec->name)
 				  free (buf);
 				if (!ok)


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