PATCH: correct usage of startfile/endfile
Peter S. Mazinger
ps.m@gmx.net
Mon Nov 22 21:21:00 GMT 2004
Hello!
ChangeLog:
* config/linux.h, config/alpha/elf.h, config/ia64/linux.h,
config/sparc/linux.h, config/sparc/linux64.h
(STARTFILE_SPEC): Don't support pie if HAVE_LD_PIE is undefined.
(ENDFILE_SPEC): Add missing entry if HAVE_LD_PIE is undefined.
* config/arm/linux-elf.h (STARTFILE_SPEC): add pie support
(ENDFILE_SPEC): add pie support
* config/gcc/rs6000/sysv4.h (ENDFILE_SPEC): add pie support
(STARTFILE_SPEC): Don't support pie if HAVE_LD_PIE is undefined.
* config/gcc/rs6000/linux64.h (ASM_SPEC32): add fPIE|fpie to
enable -K PIC.
Please apply, thanks, Peter
--
Peter S. Mazinger <ps dot m at gmx dot net> ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08 BB6E C389 975E A5F0 59F2
-------------- next part --------------
Index: gcc/config/linux.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/linux.h,v
retrieving revision 1.29
diff -u -p -r1.29 linux.h
--- gcc/config/linux.h 5 Aug 2004 09:12:11 -0000 1.29
+++ gcc/config/linux.h 22 Nov 2004 15:40:57 -0000
@@ -46,7 +46,7 @@ Boston, MA 02111-1307, USA. */
#else
#define STARTFILE_SPEC \
"%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+ crti.o%s %{static:crtbeginT.o%s;shared:crtbeginS.o%s;:crtbegin.o%s}"
#endif
/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
@@ -56,8 +56,13 @@ Boston, MA 02111-1307, USA. */
GNU/Linux "finalizer" file, `crtn.o'. */
#undef ENDFILE_SPEC
+#ifdef HAVE_LD_PIE
#define ENDFILE_SPEC \
"%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#else
+#define ENDFILE_SPEC \
+ "%{shared:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#endif
/* This is for -profile to use -lc_p instead of -lc. */
#ifndef CC1_SPEC
Index: gcc/config/alpha/elf.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/alpha/elf.h,v
retrieving revision 1.75
diff -u -p -r1.75 elf.h
--- gcc/config/alpha/elf.h 25 Dec 2003 15:17:34 -0000 1.75
+++ gcc/config/alpha/elf.h 22 Nov 2004 15:40:58 -0000
@@ -399,7 +399,7 @@ void FN (void) \
#else
#define STARTFILE_SPEC \
"%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+ crti.o%s %{static:crtbeginT.o%s;shared:crtbeginS.o%s;:crtbegin.o%s}"
#endif
/* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
@@ -408,9 +408,15 @@ void FN (void) \
`main', followed by a normal ELF "finalizer" file, `crtn.o'. */
#undef ENDFILE_SPEC
+#ifdef HAVE_LD_PIE
#define ENDFILE_SPEC \
"%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#else
+#define ENDFILE_SPEC \
+ "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+ %{shared:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#endif
/* We support #pragma. */
#define HANDLE_SYSV_PRAGMA 1
Index: gcc/config/arm/linux-elf.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/arm/linux-elf.h,v
retrieving revision 1.51
diff -u -p -r1.51 linux-elf.h
--- gcc/config/arm/linux-elf.h 18 Nov 2004 15:59:47 -0000 1.51
+++ gcc/config/arm/linux-elf.h 22 Nov 2004 15:40:58 -0000
@@ -60,12 +60,15 @@
object constructed before entering `main'. */
#undef STARTFILE_SPEC
+#ifdef HAVE_LD_PIE
+#define STARTFILE_SPEC \
+ "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
+ crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+#else
#define STARTFILE_SPEC \
- "%{!shared: \
- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
- %{!p:%{profile:gcrt1.o%s} \
- %{!profile:crt1.o%s}}}} \
- crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+ "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
+ crti.o%s %{shared:crtbeginS.o%s;:crtbegin.o%s}"
+#endif
/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
the GNU/Linux magical crtend.o file (see crtstuff.c) which
@@ -74,8 +77,13 @@
GNU/Linux "finalizer" file, `crtn.o'. */
#undef ENDFILE_SPEC
+#ifdef HAVE_LD_PIE
#define ENDFILE_SPEC \
- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+ "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#else
+#define ENDFILE_SPEC \
+ "%{shared:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#endif
#undef LINK_SPEC
#define LINK_SPEC "%{h*} %{version:-v} \
Index: gcc/config/ia64/linux.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/ia64/linux.h,v
retrieving revision 1.29
diff -u -p -r1.29 linux.h
--- gcc/config/ia64/linux.h 8 Sep 2004 00:17:14 -0000 1.29
+++ gcc/config/ia64/linux.h 22 Nov 2004 15:41:00 -0000
@@ -25,14 +25,20 @@ do { \
#else
#define STARTFILE_SPEC \
"%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}}\
- crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+ crti.o%s %{shared:crtbeginS.o%s;:crtbegin.o%s}"
#endif
/* Similar to standard Linux, but adding -ffast-math support. */
#undef ENDFILE_SPEC
+#ifdef HAVE_LD_PIE
#define ENDFILE_SPEC \
"%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#else
+#define ENDFILE_SPEC \
+ "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+ %{shared:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#endif
/* Define this for shared library support because it isn't in the main
linux.h file. */
Index: gcc/config/rs6000/linux64.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/rs6000/linux64.h,v
retrieving revision 1.73
diff -u -p -r1.73 linux64.h
--- gcc/config/rs6000/linux64.h 27 Oct 2004 01:29:42 -0000 1.73
+++ gcc/config/rs6000/linux64.h 22 Nov 2004 15:41:01 -0000
@@ -149,7 +149,7 @@ extern int dot_symbols;
#endif
#define ASM_SPEC32 "-a32 %{n} %{T} %{Ym,*} %{Yd,*} \
-%{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
+%{mrelocatable} %{mrelocatable-lib} %{fpic|fPIC|fpie|fPIE:-K PIC} \
%{memb} %{!memb: %{msdata: -memb} %{msdata=eabi: -memb}} \
%{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
%{mcall-freebsd: -mbig} \
Index: gcc/config/rs6000/sysv4.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/rs6000/sysv4.h,v
retrieving revision 1.155
diff -u -p -r1.155 sysv4.h
--- gcc/config/rs6000/sysv4.h 29 Oct 2004 17:09:05 -0000 1.155
+++ gcc/config/rs6000/sysv4.h 22 Nov 2004 15:41:02 -0000
@@ -1121,11 +1121,18 @@ extern int fixuplabelno;
#define STARTFILE_LINUX_SPEC "\
%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
%{mnewlib:ecrti.o%s;:crti.o%s} \
-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+%{static:crtbeginT.o%s;shared:crtbeginS.o%s;:crtbegin.o%s}"
#endif
-#define ENDFILE_LINUX_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s} \
+#ifdef HAVE_LD_PIE
+#define ENDFILE_LINUX_SPEC "\
+%{shared|pie:crtendS.o%s;:crtend.o%s} \
%{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}"
+#else
+#define ENDFILE_LINUX_SPEC "\
+%{shared:crtendS.o%s;:crtend.o%s} \
+%{mnewlib: ecrtn.o%s} %{!mnewlib: crtn.o%s}"
+#endif
#define LINK_START_LINUX_SPEC ""
Index: gcc/config/sparc/linux.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/sparc/linux.h,v
retrieving revision 1.65
diff -u -p -r1.65 linux.h
--- gcc/config/sparc/linux.h 11 Nov 2004 03:18:01 -0000 1.65
+++ gcc/config/sparc/linux.h 22 Nov 2004 15:41:02 -0000
@@ -49,14 +49,14 @@ Boston, MA 02111-1307, USA. */
object constructed before entering `main'. */
#undef STARTFILE_SPEC
-#if defined HAVE_LD_PIE
+#ifdef HAVE_LD_PIE
#define STARTFILE_SPEC \
"%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
#else
#define STARTFILE_SPEC \
"%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+ crti.o%s %{static:crtbeginT.o%s;shared:crtbeginS.o%s;:crtbegin.o%s}"
#endif
/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
@@ -66,9 +66,15 @@ Boston, MA 02111-1307, USA. */
GNU/Linux "finalizer" file, `crtn.o'. */
#undef ENDFILE_SPEC
+#ifdef HAVE_LD_PIE
#define ENDFILE_SPEC \
"%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#else
+#define ENDFILE_SPEC \
+ "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+ %{shared:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#endif
/* This is for -profile to use -lc_p instead of -lc. */
#undef CC1_SPEC
Index: gcc/config/sparc/linux64.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/sparc/linux64.h,v
retrieving revision 1.87
diff -u -p -r1.87 linux64.h
--- gcc/config/sparc/linux64.h 11 Nov 2004 03:18:02 -0000 1.87
+++ gcc/config/sparc/linux64.h 22 Nov 2004 15:41:02 -0000
@@ -80,7 +80,7 @@ Boston, MA 02111-1307, USA. */
#else
#define STARTFILE_SPEC \
"%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\
- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
+ crti.o%s %{static:crtbeginT.o%s;shared:crtbeginS.o%s;:crtbeginS.o%s}"
#endif
/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
@@ -90,10 +90,15 @@ Boston, MA 02111-1307, USA. */
GNU/Linux "finalizer" file, `crtn.o'. */
#undef ENDFILE_SPEC
-
+#ifdef HAVE_LD_PIE
#define ENDFILE_SPEC \
"%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
+#else
+#define ENDFILE_SPEC \
+ "%{shared:crtendS.o%s;:crtend.o%s} crtn.o%s\
+ %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
+#endif
/* The GNU C++ standard library requires that these macros be defined. */
#undef CPLUSPLUS_CPP_SPEC
More information about the Gcc-patches
mailing list