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: Fix relocation bug


Bo Thorsen <bo@suse.de> writes:

> This bugfix feels wrong, so I would like some feedback on why it is
> necessary and perhaps a better way to fix it.
> 
> The problem was that R_X86_64_PC32 relocations were calculated
> wrong. Replacing the bfd_elf_generic_reloc with zeros in the howto table
> solved it, but it is probably not correct to do this for all entries.
> 
> I'll investigate some of the specialized implementations of this entry,
> but I would appreciate it if someone could shed some light on the possible
> problem here.

That patch was wrong - but it showed the real problem, another hack
that was done in tc-i386.c.

Since I'm touching here code that could (but shouldn't!) effect i386,
I'd like to ask for explicit permission to add this to binutils.

The patch is needed for both branches, otherwise the release branch is
unusable on x86-64.

Andreas

2001-02-28  Andreas Jaeger  <aj@suse.de>, Bo Thorsen  <bo@suse.de>

	* config/tc-i386.c (tc_gen_reloc): Remove ugly hack which is not needed
	anymore since we use bfd_elf_generic_reloc now.
	(md_apply_fix3): Only apply hack for partial_inplace if not using RELA.

============================================================
Index: gas/config/tc-i386.c
--- gas/config/tc-i386.c	2001/02/20 09:48:43	1.86
+++ gas/config/tc-i386.c	2001/02/28 12:03:57
@@ -4197,7 +4197,7 @@
   if ((fixP->fx_r_type == BFD_RELOC_32_PCREL
        || fixP->fx_r_type == BFD_RELOC_16_PCREL
        || fixP->fx_r_type == BFD_RELOC_8_PCREL)
-      && fixP->fx_addsy)
+      && fixP->fx_addsy && !use_rela_relocations)
     {
 #ifndef OBJ_AOUT
       if (OUTPUT_FLAVOR == bfd_target_elf_flavour
@@ -4782,15 +4782,6 @@
   else
     {
       rel->addend = fixp->fx_offset;
-#ifdef OBJ_ELF
-      /* Ohhh, this is ugly.  The problem is that if this is a local global
-         symbol, the relocation will entirely be performed at link time, not
-         at assembly time.  bfd_perform_reloc doesn't know about this sort
-         of thing, and as a result we need to fake it out here.  */
-      if ((S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy))
-	  && !S_IS_COMMON (fixp->fx_addsy))
-	rel->addend -= symbol_get_bfdsym (fixp->fx_addsy)->value;
-#endif
       if (fixp->fx_pcrel)
 	rel->addend -= fixp->fx_size;
     }

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj


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