bsps/powerpc: Support constructors with priority

Close #3339.
This commit is contained in:
Sebastian Huber
2019-12-19 12:05:45 +01:00
parent 806fe963a2
commit 86abbb6e1e
6 changed files with 59 additions and 115 deletions

View File

@@ -177,31 +177,20 @@ SECTIONS {
/* /*
* BSP: Moved into .data from .ctors * BSP: Moved into .data from .ctors
*/ */
/* gcc uses crtbegin.o to find the start of KEEP (*ecrti.o(.ctors))
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))
KEEP (*crtbegin?.o(.ctors)) KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .ctors))
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 (*(SORT(.ctors.*)))
KEEP (*(.ctors)) KEEP (*(.ctors))
/* /*
* BSP: Moved into .data from .dtors * BSP: Moved into .data from .dtors
*/ */
KEEP (*ecrti.o(.dtors))
KEEP (*crtbegin.o(.dtors)) KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors)) KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .dtors))
KEEP (*(SORT(.dtors.*))) KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors)) KEEP (*(.dtors))

View File

@@ -77,26 +77,18 @@ SECTIONS
*(.fini) *(.fini)
*ecrtn.o(.init) *ecrtn.o(.init)
/* KEEP (*ecrti.o(.ctors))
* C++ constructors and destructors for static objects. KEEP (*crtbegin.o(.ctors))
* PowerPC EABI does not use crtstuff yet, so we build "old-style" KEEP (*crtbegin?.o(.ctors))
* constructor and destructor lists that begin with the list length KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .ctors))
* end terminate with a NULL entry. KEEP (*(SORT(.ctors.*)))
*/ KEEP (*(.ctors))
KEEP (*ecrti.o(.dtors))
PROVIDE (__CTOR_LIST__ = .); KEEP (*crtbegin.o(.dtors))
*crtbegin.o(.ctors) KEEP (*crtbegin?.o(.dtors))
*(.ctors) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .dtors))
*crtend.o(.ctors) KEEP (*(SORT(.dtors.*)))
LONG(0) KEEP (*(.dtors))
PROVIDE (__CTOR_END__ = .);
PROVIDE (__DTOR_LIST__ = .);
*crtbegin.o(.dtors)
*(.dtors)
*crtend.o(.dtors)
LONG(0)
PROVIDE (__DTOR_END__ = .);
/* Exception frame info */ /* Exception frame info */
*(.eh_frame) *(.eh_frame)

View File

@@ -93,28 +93,18 @@ SECTIONS
*(.fini) *(.fini)
*ecrtn.o(.init) *ecrtn.o(.init)
/* KEEP (*ecrti.o(.ctors))
* C++ constructors and destructors for static objects. KEEP (*crtbegin.o(.ctors))
* PowerPC EABI does not use crtstuff yet, so we build "old-style" KEEP (*crtbegin?.o(.ctors))
* constructor and destructor lists that begin with the list length KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .ctors))
* end terminate with a NULL entry. KEEP (*(SORT(.ctors.*)))
*/ KEEP (*(.ctors))
KEEP (*ecrti.o(.dtors))
PROVIDE (__CTOR_LIST__ = .); KEEP (*crtbegin.o(.dtors))
/* LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) */ KEEP (*crtbegin?.o(.dtors))
*crtbegin.o(.ctors) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .dtors))
*(.ctors) KEEP (*(SORT(.dtors.*)))
*crtend.o(.ctors) KEEP (*(.dtors))
LONG(0)
PROVIDE (__CTOR_END__ = .);
PROVIDE (__DTOR_LIST__ = .);
/* LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) */
*crtbegin.o(.dtors)
*(.dtors)
*crtend.o(.dtors)
LONG(0)
PROVIDE (__DTOR_END__ = .);
/* Exception frame info */ /* Exception frame info */
*(.eh_frame) *(.eh_frame)

View File

@@ -77,27 +77,18 @@ SECTIONS
*(.fini) *(.fini)
*ecrtn.o(.init) *ecrtn.o(.init)
/* KEEP (*ecrti.o(.ctors))
* C++ constructors and destructors for static objects. KEEP (*crtbegin.o(.ctors))
* PowerPC EABI does not use crtstuff yet, so we build "old-style" KEEP (*crtbegin?.o(.ctors))
* constructor and destructor lists that begin with the list length KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .ctors))
* end terminate with a NULL entry. KEEP (*(SORT(.ctors.*)))
*/ KEEP (*(.ctors))
PROVIDE (__CTOR_LIST__ = .); KEEP (*ecrti.o(.dtors))
/* LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) */ KEEP (*crtbegin.o(.dtors))
*crtbegin.o(.ctors) KEEP (*crtbegin?.o(.dtors))
*(.ctors) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .dtors))
*crtend.o(.ctors) KEEP (*(SORT(.dtors.*)))
LONG(0) KEEP (*(.dtors))
PROVIDE (__CTOR_END__ = .);
PROVIDE (__DTOR_LIST__ = .);
/* LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) */
*crtbegin.o(.dtors)
*(.dtors)
*crtend.o(.dtors)
LONG(0)
PROVIDE (__DTOR_END__ = .);
/* /*
* Special FreeBSD sysctl sections. * Special FreeBSD sysctl sections.

View File

@@ -161,29 +161,20 @@ SECTIONS
.dynamic : { *(.dynamic) } > RAM .dynamic : { *(.dynamic) } > RAM
.ctors : { /* gcc uses crtbegin.o to find the start of .ctors : {
* the constructors, so we make sure it is KEEP (*ecrti.o(.ctors))
* 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 KEEP (*crtbegin?.o(.ctors))
* the crtend.o file until after the sorted ctors. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .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 (*(SORT(.ctors.*)))
KEEP (*(.ctors)) KEEP (*(.ctors))
} > RAM } > RAM
.dtors : { KEEP (*crtbegin.o(.dtors)) .dtors : {
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors)) KEEP (*ecrti.o(.dtors))
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .dtors))
KEEP (*(SORT(.dtors.*))) KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors)) KEEP (*(.dtors))
} > RAM } > RAM

View File

@@ -161,29 +161,20 @@ SECTIONS
.dynamic : { *(.dynamic) } > RAM .dynamic : { *(.dynamic) } > RAM
.ctors : { /* gcc uses crtbegin.o to find the start of .ctors : {
* the constructors, so we make sure it is KEEP (*ecrti.o(.ctors))
* 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 KEEP (*crtbegin?.o(.ctors))
* the crtend.o file until after the sorted ctors. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .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 (*(SORT(.ctors.*)))
KEEP (*(.ctors)) KEEP (*(.ctors))
} > RAM } > RAM
.dtors : { KEEP (*crtbegin.o(.dtors)) .dtors : {
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors)) KEEP (*ecrti.o(.dtors))
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .dtors))
KEEP (*(SORT(.dtors.*))) KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors)) KEEP (*(.dtors))
} > RAM } > RAM