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]

Clean up platform-specific code in gas/write.c


This patch cleans up a growing chunk of platform-specific code in
gas/write.c, setting a precedent so that people do it right next time.
I'd rather not have to create yet another platform-specific #define,
but at least one other platform compensates for this code elsewhere,
so they'll have to be cleaned up one by one.

I confess I haven't tested this patch on all of the affected
platforms, but I did it on the ones I considered most relevant, and it
worked fine as long as my test went (it wasn't very thorough either
:-(

I'd appreciate if maintainers of the specific platforms could either
test it more thoroughly or ask to have their platform kept out of the
change for now (i.e., the ugly #ifdef would remain in place and the
new #define wouldn't be introduced) until they cleaned it up by
themselves.

That put, ok to install?

Index: gas/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* write.c (fixup_segment) [TC_DONT_FIX_NON_ADJUSTABLE]: Use
	obj_fix_adjustable() and tc_fix_adjustable() to tell whether to
	add a symbol's address.  Removed all target-specific #ifdefs that
	used to accomplished the same.
	* config/tc-v850.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.
	* config/tc-m68k.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.
	* config/tc-arm.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.
	* config/tc-i960.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.
	* config/tc-i386.h (TC_DONT_FIX_NON_ADJUSTABLE): Define.

Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.15
diff -u -p -r1.15 write.c
--- gas/write.c	2000/07/20 20:07:09	1.15
+++ gas/write.c	2000/08/16 19:12:34
@@ -2706,17 +2706,17 @@ fixup_segment (fixP, this_segment_type)
 	      else
 		{
 		  seg_reloc_count++;
-#if !(defined (TC_V850) && defined (OBJ_ELF))
-#if !(defined (TC_M68K) && defined (OBJ_ELF))
-#if !(defined (TC_ARM)  && defined (OBJ_ELF))
-#if !(defined (TC_I960) && defined (OBJ_ELF))
-#if !defined (TC_I386) || !(defined (OBJ_ELF) || defined (OBJ_COFF)) || defined (TE_PE)
-		  add_number += S_GET_VALUE (add_symbolP);
+#ifdef TC_DONT_FIX_NON_ADJUSTABLE
+		  if (1
+#ifdef obj_fix_adjustable
+		      && obj_fix_adjustable (fixP)
 #endif
+#ifdef tc_fix_adjustable
+		      && tc_fix_adjustable (fixP)
 #endif
+		      )
 #endif
-#endif
-#endif
+		    add_number += S_GET_VALUE (add_symbolP);
 		}
 	    }
 	}
Index: gas/config/tc-arm.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.h,v
retrieving revision 1.5
diff -u -p -r1.5 tc-arm.h
--- gas/config/tc-arm.h	1999/10/27 18:12:32	1.5
+++ gas/config/tc-arm.h	2000/08/16 19:12:34
@@ -116,6 +116,10 @@
 #define TC_FIX_TYPE PTR
 #define TC_INIT_FIX_DATA(FIXP) ((FIXP)->tc_fix_data = NULL)
 
+/* This arranges for gas/write.c to not apply a relocation if
+   obj_fix_adjustable() says it is not adjustable.  */
+#define TC_DONT_FIX_NON_ADJUSTABLE 1
+
 #ifdef OBJ_ELF
 #include "write.h"        /* For definition of fixS */
 #define obj_fix_adjustable(fixP) arm_fix_adjustable (fixP)
Index: gas/config/tc-i386.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.h,v
retrieving revision 1.11
diff -u -p -r1.11 tc-i386.h
--- gas/config/tc-i386.h	2000/05/13 09:26:22	1.11
+++ gas/config/tc-i386.h	2000/08/16 19:12:36
@@ -38,6 +38,10 @@ struct fix;
    type.  The idea is that if the original type is already some kind of PIC
    relocation, we leave it alone, otherwise we give it the desired type */
 
+/* This arranges for gas/write.c to not apply a relocation if
+   tc_fix_adjustable() says it is not adjustable.  */
+#define TC_DONT_FIX_NON_ADJUSTABLE 1
+
 #define tc_fix_adjustable(X)  tc_i386_fix_adjustable(X)
 extern int tc_i386_fix_adjustable PARAMS ((struct fix *));
 
Index: gas/config/tc-i960.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i960.h,v
retrieving revision 1.3
diff -u -p -r1.3 tc-i960.h
--- gas/config/tc-i960.h	1999/06/03 00:29:30	1.3
+++ gas/config/tc-i960.h	2000/08/16 19:12:36
@@ -153,6 +153,10 @@ extern int i960_validate_fix PARAMS ((st
        && ! S_IS_COMMON ((FIX)->fx_addsy)))
 #endif
 
+/* This arranges for gas/write.c to not apply a relocation if
+   tc_fix_adjustable() says it is not adjustable.  */
+#define TC_DONT_FIX_NON_ADJUSTABLE 1
+
 #ifndef OBJ_ELF
 #define tc_fix_adjustable(FIXP)		((FIXP)->fx_bsr == 0)
 #else
Index: gas/config/tc-m68k.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.h,v
retrieving revision 1.4
diff -u -p -r1.4 tc-m68k.h
--- gas/config/tc-m68k.h	2000/02/24 01:56:31	1.4
+++ gas/config/tc-m68k.h	2000/08/16 19:12:36
@@ -173,6 +173,10 @@ while (0)
 	     && S_IS_DEFINED ((FIX)->fx_addsy)		\
 	     && ! S_IS_COMMON ((FIX)->fx_addsy)))
 
+/* This arranges for gas/write.c to not apply a relocation if
+   tc_fix_adjustable() says it is not adjustable.  */
+#define TC_DONT_FIX_NON_ADJUSTABLE 1
+
 #define tc_fix_adjustable(X) tc_m68k_fix_adjustable(X)
 extern int tc_m68k_fix_adjustable PARAMS ((struct fix *));
 #define elf_tc_final_processing m68k_elf_final_processing
Index: gas/config/tc-v850.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-v850.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 tc-v850.h
--- gas/config/tc-v850.h	1999/05/03 07:28:43	1.1.1.1
+++ gas/config/tc-v850.h	2000/08/16 19:12:39
@@ -1,5 +1,5 @@
 /* tc-v850.h -- Header file for tc-v850.c.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -36,6 +36,10 @@
 
 #define MD_APPLY_FIX3
 #define md_operand(x)
+
+/* This arranges for gas/write.c to not apply a relocation if
+   obj_fix_adjustable() says it is not adjustable.  */
+#define TC_DONT_FIX_NON_ADJUSTABLE 1
 
 #define obj_fix_adjustable(fixP) v850_fix_adjustable(fixP)
 #define TC_FORCE_RELOCATION(fixp) v850_force_relocation(fixp)

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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