summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc/erc32/startup/linkcmds
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-03-02 17:27:54 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-03-02 17:27:54 +0000
commit27d29e18b838b53eaab9fb6f6c9cab20bd52950e (patch)
tree05ebf4d4ba44cc582b161b0df444621e2915af23 /c/src/lib/libbsp/sparc/erc32/startup/linkcmds
parent2009-03-02 Ray Xu <rayx.cn@gmail.com> (diff)
downloadrtems-27d29e18b838b53eaab9fb6f6c9cab20bd52950e.tar.bz2
2009-03-02 Daniel Hellstrom <daniel@gaisler.com>
PR 1390/bsps * startup/linkcmds: Fix sections so C++ global constructors and destructors work with late model (>= 4.3) gcc versions.
Diffstat (limited to 'c/src/lib/libbsp/sparc/erc32/startup/linkcmds')
-rw-r--r--c/src/lib/libbsp/sparc/erc32/startup/linkcmds35
1 files changed, 23 insertions, 12 deletions
diff --git a/c/src/lib/libbsp/sparc/erc32/startup/linkcmds b/c/src/lib/libbsp/sparc/erc32/startup/linkcmds
index 2ea6cd8bbd..65b31a7b6c 100644
--- a/c/src/lib/libbsp/sparc/erc32/startup/linkcmds
+++ b/c/src/lib/libbsp/sparc/erc32/startup/linkcmds
@@ -94,13 +94,11 @@ SECTIONS
.text :
{
CREATE_OBJECT_SYMBOLS
- start = .;
text_start = .;
_text_start = .;
*(.text*)
. = ALIGN (16);
-
/*
* Special FreeBSD sysctl sections.
*/
@@ -119,16 +117,29 @@ SECTIONS
/*
* C++ constructors
*/
- __CTOR_LIST__ = .;
- LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
- *(.ctors)
- LONG(0)
- __CTOR_END__ = .;
- __DTOR_LIST__ = .;
- LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
- *(.dtors)
- LONG(0)
- __DTOR_END__ = .;
+ /* 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))
+ KEEP (*crtbegin?.o(.ctors))
+ /* We don't want to include the .ctor section 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 *crtend?.o ) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*crtbegin?.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
_rodata_start = . ;
*(.rodata*)