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]
Other format: [Raw text]

Remove a fudge from tc-ppc.c:md_apply_fix3


This gets rid of a kludge in md_apply_fix3 and I think it ought to be
an obvious patch if you understand gas/write.c and all the TC_* macros.
However I'll bet there aren't too many people who fully understand
this code;  I don't.  :-)

So before applying this one, I'm asking for Geoff to review it and
give the OK.  I'm also bootstrapping gcc-3.1 and building glibc
to give some confidence that nothing has broken.

	* config/tc-ppc.c (md_apply_fix3): Rename arg to match comments.
	Don't undo adjustments done by write.c:fixup_segment.
	* config/tc-ppc.h (TC_FIX_ADJUSTABLE): Instead arrange for them
	to not occur in the first place.
	(TC_FORCE_RELOCATION_SECTION): Delete.

TC_FORCE_RELOCATION_SECTION goes because it's only used when fx_subsy
is non-NULL, thus the definition is in practice the same as the
default.

Index: gas/config/tc-ppc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.c,v
retrieving revision 1.46
diff -u -p -r1.46 tc-ppc.c
--- gas/config/tc-ppc.c	2 May 2002 12:41:35 -0000	1.46
+++ gas/config/tc-ppc.c	8 May 2002 05:49:59 -0000
@@ -5099,24 +5099,16 @@ ppc_fix_adjustable (fix)
    fixup.  */
 
 void
-md_apply_fix3 (fixP, valP, seg)
+md_apply_fix3 (fixP, valuep, seg)
      fixS *fixP;
-     valueT * valP;
+     valueT *valuep;
      segT seg ATTRIBUTE_UNUSED;
 {
-  valueT value = * valP;
+  valueT value = *valuep;
 
 #ifdef OBJ_ELF
   if (fixP->fx_addsy != NULL)
     {
-      /* `*valuep' may contain the value of the symbol on which the reloc
-	 will be based; we have to remove it.  */
-      if (symbol_used_in_reloc_p (fixP->fx_addsy)
-	  && S_GET_SEGMENT (fixP->fx_addsy) != absolute_section
-	  && S_GET_SEGMENT (fixP->fx_addsy) != undefined_section
-	  && ! bfd_is_com_section (S_GET_SEGMENT (fixP->fx_addsy)))
-	value -= S_GET_VALUE (fixP->fx_addsy);
-
       /* FIXME: Why '+'?  Better yet, what exactly is '*valuep'
 	 supposed to be?  I think this is related to various similar
 	 FIXMEs in tc-i386.c and tc-sparc.c.  */
Index: gas/config/tc-ppc.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.h,v
retrieving revision 1.13
diff -c -p -r1.13 tc-ppc.h
*** gas/config/tc-ppc.h	15 Nov 2001 21:28:58 -0000	1.13
--- gas/config/tc-ppc.h	8 May 2002 04:57:23 -0000
*************** do {								\
*** 228,238 ****
   || (FIXP)->fx_r_type == BFD_RELOC_VTABLE_INHERIT			\
   || (FIXP)->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
  
- #define TC_FORCE_RELOCATION_SECTION(FIXP,SEC)				\
- (TC_FORCE_RELOCATION (FIXP)						\
-  || ((FIXP)->fx_addsy && !(FIXP)->fx_subsy				\
-      && S_GET_SEGMENT ((FIXP)->fx_addsy) != SEC))
- 
  /* Support for SHF_EXCLUDE and SHT_ORDERED */
  extern int ppc_section_letter PARAMS ((int, char **));
  extern int ppc_section_type PARAMS ((char *, size_t));
--- 228,233 ----
*************** extern const char *ppc_comment_chars;
*** 270,275 ****
--- 265,281 ----
  #define tc_fix_adjustable(fixp) ppc_fix_adjustable (fixp)
  extern int ppc_fix_adjustable PARAMS ((struct fix *));
  
+ /* This arranges for gas/write.c to not apply a relocation if
+    tc_fix_adjustable says it is not adjustable.
+    The "!symbol_used_in_reloc_p" test is there specifically to cover
+    the case of non-global symbols in linkonce sections.  It's the
+    generally correct thing to do though;  If a reloc is going to be
+    emitted against a symbol then we don't want to adjust the fixup by
+    applying the reloc during assembly.  The reloc will be applied by
+    the linker during final link.  */
+ #define TC_FIX_ADJUSTABLE(fixp) \
+   (!symbol_used_in_reloc_p ((fixp)->fx_addsy) && tc_fix_adjustable (fixp))
+ 
  /* We must never ever try to resolve references to externally visible
     symbols in the assembler, because the .o file might go into a shared
     library, and some other shared library might override that symbol.  */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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