]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - ld/scripttempl/elfd10v.sc
import gdb-1999-08-09 snapshot
[thirdparty/binutils-gdb.git] / ld / scripttempl / elfd10v.sc
index 0356f1d51674becb3cca1ac805d5c78fc39ef5f4..322eef49e29468a11de766393c5b440aacc83b6d 100644 (file)
@@ -29,6 +29,44 @@ test "$LD_FLAG" = "N" && DATA_ADDR=.
 INTERP=".interp   ${RELOCATING-0} : { *(.interp)       }"
 PLT=".plt    ${RELOCATING-0} : { *(.plt)       }"
 
+
+CTOR=".ctors ${CONSTRUCTING-0} : 
+  {
+    ${CONSTRUCTING+${CTOR_START}}
+    /* 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))
+    ${CONSTRUCTING+${CTOR_END}}
+  }"
+
+DTOR=" .dtors       ${CONSTRUCTING-0} :
+  {
+    ${CONSTRUCTING+${DTOR_START}}
+    KEEP (*crtbegin.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+    ${CONSTRUCTING+${DTOR_END}}
+  }"
+
+
 # if this is for an embedded system, don't add SIZEOF_HEADERS.
 if [ -z "$EMBEDDED" ]; then
    test -z "${READONLY_BASE_ADDRESS}" && READONLY_BASE_ADDRESS="${READONLY_START_ADDR} + SIZEOF_HEADERS"
@@ -91,25 +129,14 @@ SECTIONS
   {
     ${RELOCATING+${DATA_START_SYMBOLS}}
     *(.data)
+    *(.data.*)
     *(.gnu.linkonce.d*)
     ${CONSTRUCTING+CONSTRUCTORS}
   }
   .data1 ${RELOCATING-0} : { *(.data1) }
   ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
-  .ctors       ${RELOCATING-0} :
-  {
-    ${CONSTRUCTING+${CTOR_START}}
-    *(SORT(.ctors.*))
-    *(.ctors)
-    ${CONSTRUCTING+${CTOR_END}}
-  }
-  .dtors       ${RELOCATING-0} :
-  {
-    ${CONSTRUCTING+${DTOR_START}}
-    *(SORT(.dtors.*))
-    *(.dtors)
-    ${CONSTRUCTING+${DTOR_END}}
-  }
+  ${RELOCATING+${CTOR}}
+  ${RELOCATING+${DTOR}}
   .got         ${RELOCATING-0} : { *(.got.plt) *(.got) }
   .dynamic     ${RELOCATING-0} : { *(.dynamic) }
   ${DATA_PLT+${PLT}}
@@ -185,9 +212,10 @@ SECTIONS
   .text    ${RELOCATING+${TEXT_START_ADDR}} :
   {
     ${RELOCATING+${TEXT_START_SYMBOLS}}
-    *(.init)
-    *(.fini)
+    KEEP (*(.init))
+    KEEP (*(.fini))
     *(.text)
+    *(.text.*)
     /* .gnu.warning sections are handled specially by elf32.em.  */
     *(.gnu.warning)
     *(.gnu.linkonce.t*)