Hi!

The x86_64 RTEMS target doesn't currently have gcc build crti.o and crtn.o. This
surfaces as undefined references to "_fini", which RTEMS references in its
kernel:
https://git.rtems.org/rtems/tree/cpukit/libcsupport/src/newlibc_exit.c#n39

Most other architectures deal with this by adding crti.o to the startfile in
bsp_specs:
https://git.rtems.org/rtems/tree/bsps/i386/pc386/start/bsp_specs#n6

This patch uses GCC's i386's crti.S and crtn.S (since x86_64-*-* targets use
"cpu_type=i386") as the source for the object files:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/config/i386/crti.S;h=c25e8f9e3ab45e935f6287d5ed3a8437a289e059;hb=HEAD

The patch is as follows:

libgcc/ChangeLog:

2018-05-01  Amaan Cheval  <amaan.che...@gmail.com>

        * config.host: Build i386's crti.o and crtn.o for x86_64-*-rtems*

Index: libgcc/config.host
===================================================================
--- libgcc/config.host  (revision 259789)
+++ libgcc/config.host  (working copy)
@@ -611,6 +611,11 @@ i[34567]86-*-elf*)
        ;;
 x86_64-*-elf* | x86_64-*-rtems*)
        tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+       case ${host} in
+       x86_64-*-rtems*)
+         extra_parts="$extra_parts crti.o crtn.o"
+         ;;
+       esac
        ;;
 x86_64-*-fuchsia*)
        tmake_file="$tmake_file t-libgcc-pic"

Reply via email to