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: binutils is broken on ELF/mips (Re: binutils is broken on Linux/alpha)


H.J.,
  Please try this kludge.  In future, it would be a lot more useful if
you post some details of your failing test cases, even if that is only
"compiling current glibc for ..., I get a failure in ..".  That way, I
and others will get a better feel for the problem, and can at least test
any work-arounds.

	* elflink.h (elf_link_input_bfd): Don't fudge discarded link-once
	section sym values.  Instead fudge any relocs against them.

If this trick works, I'll commit it, probably with an improved warning
message.

-- 
Alan

Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.111
diff -u -p -r1.111 elflink.h
--- elflink.h	2001/10/03 08:33:18	1.111
+++ elflink.h	2001/10/05 02:56:22
@@ -5993,20 +5993,6 @@ elf_link_input_bfd (finfo, input_bfd)
 
       if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
 	{
-	  /* If this is a discarded link-once section symbol, set its
-	     value to 0.  We should really undefine it, and 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,
-	     and it turns out to be hard to remove the .eh_frame entry
-	     too.  FIXME.  */
-	  if (isec != NULL
-	      && (bfd_get_section_flags (input_bfd, isec) & SEC_LINK_ONCE) != 0
-	      && bfd_is_abs_section (isec->output_section))
-	    {
-	      isym->st_value = 0;
-	    }
-
 	  /* We never output section symbols.  Instead, we use the
 	     section symbol of the corresponding section in the output
 	     file.  */
@@ -6129,6 +6115,52 @@ elf_link_input_bfd (finfo, input_bfd)
 	  if (internal_relocs == NULL
 	      && o->reloc_count > 0)
 	    return false;
+
+#if BFD_VERSION_DATE < 20031005
+	  {
+	    Elf_Internal_Rela *rel, *relend;
+	    /* Run through the relocs looking for any against section
+	       symbols from removed link-once sections.  Set any such
+	       relocs to be against 0.  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,
+	       and it turns out to be hard to remove the .eh_frame entry
+	       too.  FIXME.  */
+	    rel = internal_relocs;
+	    relend = rel + o->reloc_count * bed->s->int_rels_per_ext_rel;
+	    for ( ; rel < relend; rel++)
+	      {
+		unsigned long r_symndx = ELF_R_SYM (rel->r_info);
+
+		if (r_symndx < locsymcount
+		    && (!elf_bad_symtab (input_bfd)
+			|| finfo->sections[r_symndx] != NULL))
+		  {
+		    isym = finfo->internal_syms + r_symndx;
+		    if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
+		      {
+			asection *sec = finfo->sections[r_symndx];
+
+			if (sec != NULL
+			    && (sec->flags & SEC_LINK_ONCE) != 0
+			    && bfd_is_abs_section (sec->output_section))
+			  {
+			    long r_type = ELF_R_TYPE (rel->r_info);
+			    rel->r_info = ELF_R_INFO (0, r_type);
+
+			    (*finfo->info->callbacks->warning)
+			      (finfo->info,
+			       _("Relocation against removed section; zeroing"),
+			       0, input_bfd, 0, (bfd_vma) 0);
+			  }
+		      }
+		  }
+	      }
+	  }
+#else
+#error "This kludge ought to be fixed properly in gcc by now"
+#endif
 
 	  /* Relocate the section by invoking a back end routine.
 


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