[rtems commit] gensh4: Correct linking for C++

Joel Sherrill joel at rtems.org
Tue Apr 22 20:04:24 UTC 2014


Module:    rtems
Branch:    master
Commit:    25c3208aef2de6df5de36ac62af22ded80d7690e
Changeset: http://git.rtems.org/rtems/commit/?id=25c3208aef2de6df5de36ac62af22ded80d7690e

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Tue Apr 22 13:08:14 2014 -0500

gensh4: Correct linking for C++

---

 c/src/lib/libbsp/sh/gensh4/bsp_specs        |    6 ++-
 c/src/lib/libbsp/sh/gensh4/startup/linkcmds |   44 ++------------------------
 2 files changed, 8 insertions(+), 42 deletions(-)

diff --git a/c/src/lib/libbsp/sh/gensh4/bsp_specs b/c/src/lib/libbsp/sh/gensh4/bsp_specs
index 34d002b..975c0b2 100644
--- a/c/src/lib/libbsp/sh/gensh4/bsp_specs
+++ b/c/src/lib/libbsp/sh/gensh4/bsp_specs
@@ -4,8 +4,10 @@
 
 *startfile:
 %{!qrtems: %(old_startfile)} \
-%{!nostdlib: %{qrtems: start.o%s -e _start}}
+%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e _start}}
 
 *link:
-%(old_link) %{qrtems: -dc -dp -N}
+%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
 
+*endfile:
+%{!qrtems: %(old_endfile)} %{qrtems: crtend.o%s crtn.o%s}
diff --git a/c/src/lib/libbsp/sh/gensh4/startup/linkcmds b/c/src/lib/libbsp/sh/gensh4/startup/linkcmds
index e2e3a99..7ddb95d 100644
--- a/c/src/lib/libbsp/sh/gensh4/startup/linkcmds
+++ b/c/src/lib/libbsp/sh/gensh4/startup/linkcmds
@@ -40,10 +40,6 @@ MEMORY
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
-  .init          : 
-  { 
-    KEEP (*(.init))
-  } =0
   .text      :
   {
     _start = .;
@@ -83,10 +79,10 @@ SECTIONS
     } >ram
   _etext = .;
   PROVIDE (etext = .);
-  .fini      :
-  {
-    KEEP (*(.fini))
-  } =0
+  .init    .  : { KEEP(*(.init))    } > ram =0
+  .fini    .  : { KEEP(*(.fini))    } > ram =0
+  .ctors   .  : { KEEP(*(.ctors))    } > ram =0
+  .dtors   .  : { KEEP(*(.dtors))    } > ram =0
   .rodata   : 
   { 
     *(.rodata) 
@@ -109,38 +105,6 @@ SECTIONS
   __TLS_BSS_size = __TLS_BSS_end - __TLS_BSS_begin;
   __TLS_Size = __TLS_BSS_end - __TLS_Data_begin;
   __TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
-  .ctors   : 
-  {
-    ___ctors = .;
-    /* gcc uses crtbegin.o to find the start of
-       the constructors, so we make sure it is
-       first.  Because this is a wildcard, it
-       doesn't matter if the user does not
-       actually link against crtbegin.o; the
-       linker won't look for a file to match a
-       wildcard.  The wildcard also means that it
-       doesn't matter which directory crtbegin.o
-       is in.  */
-    KEEP (*crtbegin.o(.ctors))
-    /* We don't want to include the .ctor section from
-       from the crtend.o file until after the sorted ctors.
-       The .ctor section from the crtend file contains the
-       end of ctors marker and it must be last */
-    KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
-    KEEP (*(SORT(.ctors.*)))
-    KEEP (*(.ctors))
-    ___ctors_end = .;
-  } > ram
-   .dtors         :
-  {
-    ___dtors = .;
-    KEEP (*crtbegin.o(.dtors))
-    KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
-    KEEP (*(SORT(.dtors.*)))
-    KEEP (*(.dtors))
-    ___dtors_end = .;
-    copy_start_in_rom = .;
-  } > ram
 
   /* Adjust the address for the data segment.  We want to adjust up to
      the same address within the page on the next page up.  */




More information about the vc mailing list