This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: -mrelocatable broken on ppc-linux


On Wed, Jan 21, 2004 at 09:32:26AM -0800, Geoff Keating wrote:
> Right.  I mean specifically -mrelocatable, with .fixup; the part of
> -mrelocatable that's used for -fPIC is of course necessary (since some
> shared libraries are too big for -fpic).

It does seem that the Linux kernel uses -mrelocatable-lib when building
certain boot files..

I think this is what we need to do to resurrect -mrelocatable.  We only
want .fixup to be emitted when -mrelocatable is given, not when
MASK_RELOCATABLE happens to be set for other reasons, ie. when -fpic/PIC
on 32 bit.  Fortunately, target_flags_explicit has this information.

I've also removed the biarch redefine of TARGET_RELOCATABLE in linux64.h
as the simpler define in sysv4.h will do quite well.
SUBSUBTARGET_OVERRIDE_OPTIONS ensures that TARGET_RELOCATABLE is never
true when 64 bit.

	* config/rs6000/rs6000.c (rs6000_assemble_integer): Replace
	#ifdef RELOCATABLE_NEEDS_FIXUP with if.
	* config/rs6000/linux.h (RELOCATABLE_NEEDS_FIXUP): Define in terms
	of target_flags_explicit.
	* config/rs6000/linux64.h (RELOCATABLE_NEEDS_FIXUP): Ditto for biarch
	case.  Define as 0 for non-biarch.
	(TARGET_RELOCATABLE): Don't define for biarch case.

Bootstrap/regression test on powerpc-linux and powerpc64-linux in
progress.

Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.581
diff -u -p -r1.581 rs6000.c
--- gcc/config/rs6000/rs6000.c	20 Jan 2004 16:51:07 -0000	1.581
+++ gcc/config/rs6000/rs6000.c	22 Jan 2004 06:54:45 -0000
@@ -9352,6 +9352,10 @@ print_operand_address (FILE *file, rtx x
     abort ();
 }
 
+#ifndef RELOCATABLE_NEEDS_FIXUP
+#define RELOCATABLE_NEEDS_FIXUP 0
+#endif
+
 /* Target hook for assembling integer objects.  The PowerPC version has
    to handle fixup entries for relocatable code if RELOCATABLE_NEEDS_FIXUP
    is defined.  It also needs to handle DI-mode objects on 64-bit
@@ -9360,9 +9364,8 @@ print_operand_address (FILE *file, rtx x
 static bool
 rs6000_assemble_integer (rtx x, unsigned int size, int aligned_p)
 {
-#ifdef RELOCATABLE_NEEDS_FIXUP
   /* Special handling for SI values.  */
-  if (size == 4 && aligned_p)
+  if (RELOCATABLE_NEEDS_FIXUP && size == 4 && aligned_p)
     {
       extern int in_toc_section (void);
       static int recurse = 0;
@@ -9409,7 +9412,6 @@ rs6000_assemble_integer (rtx x, unsigned
 	  return true;
 	}
     }
-#endif /* RELOCATABLE_NEEDS_FIXUP */
   return default_assemble_integer (x, size, aligned_p);
 }
 
Index: gcc/config/rs6000/linux.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/linux.h,v
retrieving revision 1.42
diff -u -p -r1.42 linux.h
--- gcc/config/rs6000/linux.h	16 Sep 2003 08:04:33 -0000	1.42
+++ gcc/config/rs6000/linux.h	22 Jan 2004 06:54:30 -0000
@@ -86,8 +86,11 @@
 #undef TARGET_64BIT
 #define TARGET_64BIT 0
  
-/* We don't need to generate entries in .fixup.  */
+/* We don't need to generate entries in .fixup, except when
+   -mrelocatable or -mrelocatable-lib is given.  */
 #undef RELOCATABLE_NEEDS_FIXUP
+#define RELOCATABLE_NEEDS_FIXUP \
+  (target_flags & target_flags_explicit & MASK_RELOCATABLE)
 
 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
 
Index: gcc/config/rs6000/linux64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/linux64.h,v
retrieving revision 1.54
diff -u -p -r1.54 linux64.h
--- gcc/config/rs6000/linux64.h	17 Jan 2004 19:48:50 -0000	1.54
+++ gcc/config/rs6000/linux64.h	22 Jan 2004 06:54:30 -0000
@@ -53,8 +53,11 @@
 #undef PROCESSOR_DEFAULT64
 #define PROCESSOR_DEFAULT64 PROCESSOR_PPC630
 
-#undef	TARGET_RELOCATABLE
-#define	TARGET_RELOCATABLE (!TARGET_64BIT && (target_flags & MASK_RELOCATABLE))
+/* We don't need to generate entries in .fixup, except when
+   -mrelocatable or -mrelocatable-lib is given.  */
+#undef RELOCATABLE_NEEDS_FIXUP
+#define RELOCATABLE_NEEDS_FIXUP \
+  (target_flags & target_flags_explicit & MASK_RELOCATABLE)
 
 #undef	RS6000_ABI_NAME
 #define	RS6000_ABI_NAME (TARGET_64BIT ? "aixdesc" : "sysv")
@@ -183,6 +186,8 @@
 #define	TARGET_EABI		0
 #undef	TARGET_PROTOTYPE
 #define	TARGET_PROTOTYPE	0
+#undef RELOCATABLE_NEEDS_FIXUP
+#define RELOCATABLE_NEEDS_FIXUP 0
 
 #endif
 
@@ -206,9 +211,6 @@
 #define NO_PROFILE_COUNTERS TARGET_64BIT
 #define PROFILE_HOOK(LABEL) \
   do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
-
-/* We don't need to generate entries in .fixup.  */
-#undef RELOCATABLE_NEEDS_FIXUP
 
 /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given.  */
 #undef  ADJUST_FIELD_ALIGN

-- 
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]