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)


On Fri, Oct 05, 2001 at 12:36:51PM +0930, Alan Modra wrote:
> 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.
> 

It seems to pass my testcase. However, I don't believe we should issue
a warning for the time being. Also, people may not want to upgrade gcc
for various reasons. I think we should issue a warning after a future
date and still keep the kludge. I changed your patch a little bit.
I will run more tests after it is in.

Thanks.



H.J.
-----
--- bfd/elflink.h.linkonce	Thu Oct  4 09:35:25 2001
+++ bfd/elflink.h	Fri Oct  5 09:06:46 2001
@@ -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.  */
@@ -6130,6 +6116,50 @@ elf_link_input_bfd (finfo, input_bfd)
 	      && o->reloc_count > 0)
 	    return false;
 
+	  {
+	    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);
+
+#if BFD_VERSION_DATE > 20031005
+			    (*finfo->info->callbacks->warning)
+			      (finfo->info,
+			       _("Relocation against removed section; zeroing"),
+			       0, input_bfd, 0, (bfd_vma) 0);
+#endif
+			  }
+		      }
+		  }
+	      }
+	  }
+
 	  /* Relocate the section by invoking a back end routine.
 
 	     The back end routine is responsible for adjusting the


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