RFC: generalize STARTFILE/ENDFILE_SPEC for linux
Peter S. Mazinger
ps.m@gmx.net
Mon Jan 9 13:38:00 GMT 2006
Hello!
Would the attached patch be acceptable?
The gcc.c patch part should really go to gcc/config/linux.h, but sadly not
all archs include that file.
for HAVE_ENDFILE_MATH and HAVE_NOSTARTFILE_STATIC another possibility
would be
%{static:%:if-exists-else(crtbeginT.o%s crtbegin.o%s)}
%{ffast-math|funsafe-math-optimizations:%:if-exists(crtfastmath.o%s)}
Thanks, Peter
PS: please CC to me, not on ml.
--
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 --------------
--- gcc-4.1/gcc/config/alpha/elf.h.startend~ 2005-09-05 15:42:35 +0200
+++ gcc-4.1/gcc/config/alpha/elf.h 2006-01-09 02:12:01 +0100
@@ -392,25 +392,16 @@
before entering `main'. */
#undef STARTFILE_SPEC
-#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}"
-#endif
+#define STARTFILE_SPEC STARTFILE_PIE_LINUX_SPEC
/* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
magical crtend.o file which provides part of the support for
getting C++ file-scope static object constructed before entering
`main', followed by a normal ELF "finalizer" file, `crtn.o'. */
+#define HAVE_ENDFILE_MATH 1
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
- %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#define ENDFILE_SPEC ENDFILE_PIE_LINUX_SPEC
/* We support #pragma. */
#define HANDLE_SYSV_PRAGMA 1
--- gcc-4.1/gcc/config/arm/uclinux-elf.h.startend~ 2005-11-12 21:35:52 +0100
+++ gcc-4.1/gcc/config/arm/uclinux-elf.h 2006-01-09 02:12:35 +0100
@@ -44,13 +44,9 @@
provides part of the support for getting C++ file-scope static
object constructed before entering `main'. */
+#define HAVE_NOSTARTFILE_STATIC 1
#undef STARTFILE_SPEC
-#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}"
+#define STARTFILE_SPEC STARTFILE_PIE_LINUX_SPEC
/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
the GNU/Linux magical crtend.o file (see crtstuff.c) which
@@ -59,8 +55,7 @@
GNU/Linux "finalizer" file, `crtn.o'. */
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+#define ENDFILE_SPEC ENDFILE_PIE_LINUX_SPEC
#undef CC1_SPEC
#define CC1_SPEC "%{profile:-p}"
--- gcc-4.1/gcc/config/frv/linux.h.startend~ 2006-01-09 02:18:18 +0100
+++ gcc-4.1/gcc/config/frv/linux.h 2006-01-09 02:18:46 +0100
@@ -28,13 +28,10 @@
"%{!mno-fdpic:-mfdpic}",
#undef STARTFILE_SPEC
-#define STARTFILE_SPEC \
- "%{!shared: %{pg|p|profile: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}"
+#define STARTFILE_SPEC STARTFILE_PIE_LINUX_SPEC
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#define ENDFILE_SPEC ENDFILE_PIE_LINUX_SPEC
#undef LINK_SPEC
#define LINK_SPEC "\
--- gcc-4.1/gcc/config/i386/linux.h.startend~ 2006-01-09 02:22:49 +0100
+++ gcc-4.1/gcc/config/i386/linux.h 2006-01-09 02:23:47 +0100
@@ -122,10 +122,8 @@
%{static:-static}}}"
/* Similar to standard Linux, but adding -ffast-math support. */
-#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
- %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#define HAVE_ENDFILE_MATH 1
+#undef ENDFILE_SPEC ENDFILE_PIE_LINUX_SPEC
/* A C statement (sans semicolon) to output to the stdio stream
FILE the assembler definition of uninitialized global DECL named
--- gcc-4.1/gcc/config/ia64/linux.h.startend~ 2004-09-08 02:17:14 +0200
+++ gcc-4.1/gcc/config/ia64/linux.h 2006-01-09 02:11:09 +0100
@@ -16,23 +16,15 @@
builtin_define("_LONGLONG"); \
} while (0)
-/* Need to override linux.h STARTFILE_SPEC, since it has crtbeginT.o in. */
+#define HAVE_NOSTARTFILE_STATIC 1
#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|p|profile:gcrt1.o%s;:crt1.o%s}}\
- crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
-#endif
+#define STARTFILE_SPEC STARTFILE_PIE_LINUX_SPEC
/* Similar to standard Linux, but adding -ffast-math support. */
+
+#define HAVE_ENDFILE_MATH 1
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
- %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#define ENDFILE_SPEC ENDFILE_PIE_LINUX_SPEC
/* Define this for shared library support because it isn't in the main
linux.h file. */
--- gcc-4.1/gcc/config/m32r/linux.h.startend~ 2006-01-09 02:19:28 +0100
+++ gcc-4.1/gcc/config/m32r/linux.h 2006-01-09 02:20:04 +0100
@@ -85,20 +85,10 @@
%{profile:-lc_p} %{!profile: -lc}}"
#undef STARTFILE_SPEC
-#if defined HAVE_LD_PIE
-#define STARTFILE_SPEC \
- "%{!shared: %{pg|p|profile: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:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
- crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
-#endif
+#define STARTFILE_SPEC STARTFILE_PIE_LINUX_SPEC
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#define ENDFILE_SPEC ENDFILE_PIE_LINUX_SPEC
#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC "\
--- gcc-4.1/gcc/config/rs6000/linux64.h.startend~ 2005-09-16 21:02:29 +0200
+++ gcc-4.1/gcc/config/rs6000/linux64.h 2006-01-08 15:24:07 +0100
@@ -152,7 +152,7 @@
#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} \
--- gcc-4.1/gcc/config/rs6000/sysv4.h.startend~ 2005-09-05 15:43:47 +0200
+++ gcc-4.1/gcc/config/rs6000/sysv4.h 2006-01-09 02:15:18 +0100
@@ -1017,21 +1017,11 @@
%{!mnewlib: %{pthread:-lpthread} %{shared:-lc} \
%{!shared: %{profile:-lc_p} %{!profile:-lc}}}"
-#ifdef HAVE_LD_PIE
-#define STARTFILE_LINUX_SPEC "\
-%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
-%{mnewlib:ecrti.o%s;:crti.o%s} \
-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
-#else
-#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}"
-#endif
+#define CRTIFILE_SPEC " %{mnewlib:ecrti.o%s;:crti.o%s} "
+#define STARTFILE_LINUX_SPEC STARTFILE_PIE_LINUX_SPEC
-#define ENDFILE_LINUX_SPEC "\
-%{shared|pie:crtendS.o%s;:crtend.o%s} \
-%{mnewlib:ecrtn.o%s;:crtn.o%s}"
+#define CRTNFILE_SPEC " %{mnewlib:ecrtn.o%s;:crtn.o%s}"
+#define ENDFILE_LINUX_SPEC ENDFILE_PIE_LINUX_SPEC
#define LINK_START_LINUX_SPEC ""
--- gcc-4.1/gcc/config/sparc/linux.h.startend~ 2005-09-05 15:44:03 +0200
+++ gcc-4.1/gcc/config/sparc/linux.h 2006-01-09 02:16:05 +0100
@@ -49,15 +49,7 @@
object constructed before entering `main'. */
#undef STARTFILE_SPEC
-#if defined 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}"
-#endif
+#define STARTFILE_SPEC STARTFILE_PIE_LINUX_SPEC
/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
the GNU/Linux magical crtend.o file (see crtstuff.c) which
@@ -65,10 +57,9 @@
object constructed before entering `main', followed by a normal
GNU/Linux "finalizer" file, `crtn.o'. */
+#define HAVE_ENDFILE_MATH 1
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
- %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#define ENDFILE_SPEC ENDFILE_PIE_LINUX_SPEC
/* This is for -profile to use -lc_p instead of -lc. */
#undef CC1_SPEC
--- gcc-4.1/gcc/config/sparc/linux64.h.startend~ 2005-09-05 15:44:03 +0200
+++ gcc-4.1/gcc/config/sparc/linux64.h 2006-01-09 02:16:52 +0100
@@ -72,16 +72,7 @@
object constructed before entering `main'. */
#undef STARTFILE_SPEC
-
-#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;:crtbeginS.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;:crtbeginS.o%s}"
-#endif
+#define STARTFILE_SPEC STARTFILE_PIE_LINUX_SPEC
/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
the GNU/Linux magical crtend.o file (see crtstuff.c) which
@@ -89,11 +80,9 @@
object constructed before entering `main', followed by a normal
GNU/Linux "finalizer" file, `crtn.o'. */
+#define HAVE_ENDFILE_MATH 1
#undef ENDFILE_SPEC
-
-#define ENDFILE_SPEC \
- "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
- %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
+#define ENDFILE_SPEC ENDFILE_PIE_LINUX_SPEC
/* The GNU C++ standard library requires that these macros be defined. */
#undef CPLUSPLUS_CPP_SPEC
--- gcc-4.1/gcc/config/linux.h.startend~ 2005-09-05 15:42:31 +0200
+++ gcc-4.1/gcc/config/linux.h 2006-01-09 02:28:07 +0100
@@ -37,17 +37,9 @@
the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
provides part of the support for getting C++ file-scope static
object constructed before entering `main'. */
-
+
#undef STARTFILE_SPEC
-#if defined HAVE_LD_PIE
-#define STARTFILE_SPEC \
- "%{!shared: %{pg|p|profile: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|profile:gcrt1.o%s;:crt1.o%s}} \
- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
-#endif
+#define STARTFILE_SPEC STARTFILE_PIE_LINUX_SPEC
/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
the GNU/Linux magical crtend.o file (see crtstuff.c) which
@@ -56,8 +48,7 @@
GNU/Linux "finalizer" file, `crtn.o'. */
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#define ENDFILE_SPEC ENDFILE_PIE_LINUX_SPEC
/* This is for -profile to use -lc_p instead of -lc. */
#ifndef CC1_SPEC
--- gcc-4.1/gcc/gcc.c.startend~ 2006-01-07 19:51:33 +0100
+++ gcc-4.1/gcc/gcc.c 2006-01-09 02:09:58 +0100
@@ -686,6 +686,41 @@
#endif
#endif
+#ifdef HAVE_LD_PIE
+# define CRTFILE_PIE_SPEC "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s} }"
+# ifdef HAVE_NOSTARTFILE_STATIC
+# define STARTFILE_PIE_SPEC "%{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+# else
+# define STARTFILE_PIE_SPEC "%{shared|pie:crtbeginS.o%s;static:crtbeginT.o%s;:crtbegin.o%s}"
+# endif
+# define ENDFILE_PIE_SPEC "%{shared|pie:crtendS.o%s;:crtend.o%s}"
+#else
+# define CRTFILE_PIE_SPEC "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s} }"
+# ifdef HAVE_NOSTARTFILE_STATIC
+# define STARTFILE_PIE_SPEC "%{shared:crtbeginS.o%s;:crtbegin.o%s}"
+# else
+# define STARTFILE_PIE_SPEC "%{shared:crtbeginS.o%s;static:crtbeginT.o%s;:crtbegin.o%s}"
+# endif
+# define ENDFILE_PIE_SPEC "%{shared:crtendS.o%s;:crtend.o%s}"
+#endif
+
+#ifndef CRTIFILE_SPEC
+#define CRTIFILE_SPEC " crti.o%s "
+#endif
+
+#ifndef CRTNFILE_SPEC
+#define CRTNFILE_SPEC " crtn.o%s"
+#endif
+
+#ifdef HAVE_ENDFILE_MATH
+#define ENDFILE_MATH "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} "
+#else
+#define ENDFILE_MATH ""
+#endif
+
+#define STARTFILE_PIE_LINUX_SPEC CRTFILE_PIE_SPEC CRTIFILE_SPEC STARTFILE_PIE_SPEC
+#define ENDFILE_PIE_LINUX_SPEC ENDFILE_LINUX_MATH ENDFILE_PIE_SPEC CRTNFILE_SPEC
+
/* -u* was put back because both BSD and SysV seem to support it. */
/* %{static:} simply prevents an error message if the target machine
doesn't handle -static. */
More information about the Gcc
mailing list