RTEMS: Improve GCC specification
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Mon, 6 Apr 2020 14:34:50 +0000 (16:34 +0200)
committerSebastian Huber <sebastian.huber@embedded-brains.de>
Tue, 5 May 2020 17:47:40 +0000 (19:47 +0200)
Add a start/end file specification if the -qrtems option is present.
Allow targets to customize it.

Support the standard -nodefaultlibs option.

gcc/

* config/rtems.h (RTEMS_STARTFILE_SPEC): Define if undefined.
(RTEMS_ENDFILE_SPEC): Likewise.
(STARTFILE_SPEC): Update comment.  Add RTEMS_STARTFILE_SPEC.
(ENDFILE_SPEC): Add RTEMS_ENDFILE_SPEC.
(LIB_SPECS): Support -nodefaultlibs option.
* config/or1k/rtems.h (RTEMS_STARTFILE_SPEC): Define.
(RTEMS_ENDFILE_SPEC): Likewise.
* config/rs6000/rtems.h (RTEMS_STARTFILE_SPEC): Likewise.
(RTEMS_ENDFILE_SPEC): Likewise.
* config/v850/rtems.h (RTEMS_STARTFILE_SPEC): Likewise.
(RTEMS_ENDFILE_SPEC): Likewise.

gcc/ChangeLog
gcc/config/or1k/rtems.h
gcc/config/rs6000/rtems.h
gcc/config/rtems.h
gcc/config/v850/rtems.h

index 6b4d53da318d88f481569d33c6fa9d074babfe60..995f0aa4d1aadbfc32d516160a36fc826ebd90a0 100644 (file)
@@ -1,3 +1,17 @@
+2020-05-05  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+       * config/rtems.h (RTEMS_STARTFILE_SPEC): Define if undefined.
+       (RTEMS_ENDFILE_SPEC): Likewise.
+       (STARTFILE_SPEC): Update comment.  Add RTEMS_STARTFILE_SPEC.
+       (ENDFILE_SPEC): Add RTEMS_ENDFILE_SPEC.
+       (LIB_SPECS): Support -nodefaultlibs option.
+       * config/or1k/rtems.h (RTEMS_STARTFILE_SPEC): Define.
+       (RTEMS_ENDFILE_SPEC): Likewise.
+       * config/rs6000/rtems.h (RTEMS_STARTFILE_SPEC): Likewise.
+       (RTEMS_ENDFILE_SPEC): Likewise.
+       * config/v850/rtems.h (RTEMS_STARTFILE_SPEC): Likewise.
+       (RTEMS_ENDFILE_SPEC): Likewise.
+
 2020-05-05  Dimitar Dimitrov  <dimitar@dinux.eu>
 
        * config/pru/pru.c (pru_hard_regno_call_part_clobbered): Remove.
index 94731435f4479766c1f0beb6384234215bed0ed2..d4b8fef3dc7103d1f2fadfd14b17e2e853b7675c 100644 (file)
@@ -28,3 +28,6 @@
        builtin_assert ("system=rtems");        \
     }                                          \
   while (0)
+
+#define RTEMS_STARTFILE_SPEC "crtbegin%O%s"
+#define RTEMS_ENDFILE_SPEC "crtend%O%s"
index 6ce05bfc6d6e416afcbdc8853a9e611e95f06f29..40db6606f17f0deddb2cc19bbdd78745453f915d 100644 (file)
   "%{mads|myellowknife|mmvme|msim:%G %L %G;" \
   "!mcall-*|mcall-linux:" GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC ";" \
   ":%G %L %G}"
+
+#define RTEMS_STARTFILE_SPEC "ecrti%O%s rtems_crti%O%s crtbegin%O%s"
+#define RTEMS_ENDFILE_SPEC "crtend%O%s rtems_crtn%O%s ecrtn%O%s"
index 55d568f83b5b308e9d01bbf4ad22370883ae9084..30ad6258949d2aa49554adf5057358addc1ef2eb 100644 (file)
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef RTEMS_STARTFILE_SPEC
+#define RTEMS_STARTFILE_SPEC "crti%O%s crtbegin%O%s"
+#endif
+
+#ifndef RTEMS_ENDFILE_SPEC
+#define RTEMS_ENDFILE_SPEC "crtend%O%s crtn%O%s"
+#endif
+
 /*
- * Dummy start/end specification to let linker work as
- * needed by autoconf scripts using this compiler.
+ * The crt0.o is a dummy start file to let the linker work as needed by
+ * autoconf scripts using this compiler.
  */
 #undef STARTFILE_SPEC
-#define STARTFILE_SPEC "crt0.o%s"
+#define STARTFILE_SPEC "%{!qrtems:crt0%O%s} " \
+"%{qrtems:%{!nostdlib:%{!nostartfiles:" RTEMS_STARTFILE_SPEC "}}}"
 
 #undef ENDFILE_SPEC
-#define ENDFILE_SPEC   ""
+#define ENDFILE_SPEC \
+"%{qrtems:%{!nostdlib:%{!nostartfiles:" RTEMS_ENDFILE_SPEC "}}}"
 
 /*
  * Some targets do not set up LIB_SPECS, override it, here.
 #define STD_LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
 
 #undef LIB_SPEC
-#define LIB_SPEC "%{!qrtems: " STD_LIB_SPEC "} " \
-"%{!nostdlib: %{qrtems: --start-group \
- -lrtemsbsp -lrtemscpu \
- -latomic -lc -lgcc --end-group %{!qnolinkcmds: -T linkcmds%s}}}"
+#define LIB_SPEC "%{!qrtems:" STD_LIB_SPEC "} " \
+"%{qrtems:%{!nostdlib:%{!nodefaultlibs:" \
+"--start-group -lrtemsbsp -lrtemscpu -latomic -lc -lgcc --end-group} " \
+"%{!qnolinkcmds:-T linkcmds%s}}}"
 
 #define TARGET_POSIX_IO
 
index 3f7d39a2cd1e5666eb1a9865283509ab69fd367c..e261ea3b417579c591fffeb9da5811fbc9ccfedf 100644 (file)
@@ -39,3 +39,6 @@
 %{!mv850es:%{!mv850e1:%{mv*:-mv%*}} \
 %{m8byte-align:-m8byte-align} \
 %{mgcc-abi:-mgcc-abi}}"
+
+#define RTEMS_STARTFILE_SPEC ""
+#define RTEMS_ENDFILE_SPEC ""