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: Linking libstdc++ with gcc-3.0.2 prerelease fails on IA64


On Mon, Oct 15, 2001 at 06:23:12PM -0700, H . J . Lu wrote:
> 
> 	* elflink.h (elf_link_input_bfd): Set type to BFD_RELOC_NONE
> 	for relocations against discarded link-once section.
> 
> --- elflink.h.weak	Mon Oct 15 16:51:51 2001
> +++ elflink.h	Mon Oct 15 17:02:03 2001
> @@ -6327,8 +6327,10 @@ elf_link_input_bfd (finfo, input_bfd)
>  			    && (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);
> +			    reloc_howto_type *howto
> +			      =  bfd_reloc_type_lookup (output_bfd,
> +							BFD_RELOC_NONE);
> +			    rel->r_info = ELF_R_INFO (0, howto->type);
>  
>  #if BFD_VERSION_DATE > 20021005
>  			    (*finfo->info->callbacks->warning)

Hmm, I wondered whether I was doing the right thing leaving the relocation
type as it was.  Why not just do

rel->r_info = 0;

After all, we rely on R_*_NONE being zero in other places.  In fact, it's
probably safest to zero the entire reloc, like this:

Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.114
diff -u -p -r1.114 elflink.h
--- elflink.h	2001/10/10 19:32:02	1.114
+++ elflink.h	2001/10/16 02:01:31
@@ -6120,13 +6120,12 @@ elf_link_input_bfd (finfo, input_bfd)
 	  {
 	    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.  */
+	       symbols from removed link-once sections.  Zero any such
+	       relocs.  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++)
@@ -6146,15 +6145,13 @@ elf_link_input_bfd (finfo, input_bfd)
 			    && (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 > 20021005
 			    (*finfo->info->callbacks->warning)
 			      (finfo->info,
 			       _("warning: relocation against removed section; zeroing"),
 			       NULL, input_bfd, o, rel->r_offset);
 #endif
+			    memset (rel, 0, sizeof (*rel));
 			  }
 		      }
 		  }


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