From 73d1f0799f3b8e8a1d51b60cf5b9d76d7685fbf6 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 2 Mar 2009 17:28:45 +0000 Subject: 2009-03-02 Daniel Hellstrom PR 1390/bsps * startup/linkcmds: Fix sections so C++ global constructors and destructors work with late model (>= 4.3) gcc versions. --- c/src/lib/libbsp/sparc/erc32/ChangeLog | 6 +++++ c/src/lib/libbsp/sparc/erc32/startup/linkcmds | 34 ++++++++++++++++++--------- c/src/lib/libbsp/sparc/leon2/ChangeLog | 6 +++++ c/src/lib/libbsp/sparc/leon2/startup/linkcmds | 33 ++++++++++++++++++-------- c/src/lib/libbsp/sparc/leon3/ChangeLog | 6 +++++ c/src/lib/libbsp/sparc/leon3/startup/linkcmds | 33 ++++++++++++++++++-------- 6 files changed, 87 insertions(+), 31 deletions(-) (limited to 'c/src') diff --git a/c/src/lib/libbsp/sparc/erc32/ChangeLog b/c/src/lib/libbsp/sparc/erc32/ChangeLog index 6dcd9882b9..f747081add 100644 --- a/c/src/lib/libbsp/sparc/erc32/ChangeLog +++ b/c/src/lib/libbsp/sparc/erc32/ChangeLog @@ -1,3 +1,9 @@ +2009-03-02 Daniel Hellstrom + + PR 1390/bsps + * startup/linkcmds: Fix sections so C++ global constructors and + destructors work with late model (>= 4.3) gcc versions. + 2008-12-08 Ralf Corsépius * bsp_specs: Backport from CVS-HEAD. diff --git a/c/src/lib/libbsp/sparc/erc32/startup/linkcmds b/c/src/lib/libbsp/sparc/erc32/startup/linkcmds index ee17597cc2..5f982b101c 100644 --- a/c/src/lib/libbsp/sparc/erc32/startup/linkcmds +++ b/c/src/lib/libbsp/sparc/erc32/startup/linkcmds @@ -99,7 +99,6 @@ SECTIONS *(.text*) . = ALIGN (16); - /* * Special FreeBSD sysctl sections. */ @@ -118,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*) diff --git a/c/src/lib/libbsp/sparc/leon2/ChangeLog b/c/src/lib/libbsp/sparc/leon2/ChangeLog index 8ff5ca4c34..228ee04dd2 100644 --- a/c/src/lib/libbsp/sparc/leon2/ChangeLog +++ b/c/src/lib/libbsp/sparc/leon2/ChangeLog @@ -1,3 +1,9 @@ +2009-03-02 Daniel Hellstrom + + PR 1390/bsps + * startup/linkcmds: Fix sections so C++ global constructors and + destructors work with late model (>= 4.3) gcc versions. + 2008-12-08 Ralf Corsépius * bsp_specs: Backport from CVS-HEAD. diff --git a/c/src/lib/libbsp/sparc/leon2/startup/linkcmds b/c/src/lib/libbsp/sparc/leon2/startup/linkcmds index d62014eb3a..0c4aff72ee 100644 --- a/c/src/lib/libbsp/sparc/leon2/startup/linkcmds +++ b/c/src/lib/libbsp/sparc/leon2/startup/linkcmds @@ -117,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*) diff --git a/c/src/lib/libbsp/sparc/leon3/ChangeLog b/c/src/lib/libbsp/sparc/leon3/ChangeLog index bcee3810aa..ed765731f2 100644 --- a/c/src/lib/libbsp/sparc/leon3/ChangeLog +++ b/c/src/lib/libbsp/sparc/leon3/ChangeLog @@ -1,3 +1,9 @@ +2009-03-02 Daniel Hellstrom + + PR 1390/bsps + * startup/linkcmds: Fix sections so C++ global constructors and + destructors work with late model (>= 4.3) gcc versions. + 2008-12-08 Ralf Corsépius * bsp_specs: Backport from CVS-HEAD. diff --git a/c/src/lib/libbsp/sparc/leon3/startup/linkcmds b/c/src/lib/libbsp/sparc/leon3/startup/linkcmds index d62014eb3a..0c4aff72ee 100644 --- a/c/src/lib/libbsp/sparc/leon3/startup/linkcmds +++ b/c/src/lib/libbsp/sparc/leon3/startup/linkcmds @@ -117,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*) -- cgit v1.2.3