Copy marker names from binutils for init/fini

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
This commit is contained in:
Callum Farmer 2023-04-30 13:51:32 +01:00
parent b3cc412aad
commit 9c5403e1e6
10 changed files with 44 additions and 44 deletions

View File

@ -48,10 +48,10 @@ SECTIONS
* have NULLs which aren't guaranteed to be at the end. * have NULLs which aren't guaranteed to be at the end.
*/ */
. = ALIGN(16); . = ALIGN(16);
_init_array = .; __init_array_start = .;
*(SORT(.init_array.*)) *(SORT(.init_array.*))
*(.init_array) *(.init_array)
_init_array_end = .; __init_array_end = .;
__CTOR_LIST__ = .; __CTOR_LIST__ = .;
*(SORT(.ctors.*)) *(SORT(.ctors.*))
*(.ctors) *(.ctors)
@ -60,10 +60,10 @@ SECTIONS
*(SORT(.dtors.*)) *(SORT(.dtors.*))
*(.dtors) *(.dtors)
__DTOR_END__ = .; __DTOR_END__ = .;
_fini_array = .; __fini_array_start = .;
*(SORT(.fini_array.*)) *(SORT(.fini_array.*))
*(.fini_array) *(.fini_array)
_fini_array_end = .; __fini_array_end = .;
/* the EFI loader doesn't seem to like a .bss section, so we stick /* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */ it all into .data: */

View File

@ -35,10 +35,10 @@ SECTIONS
* have NULLs which aren't guaranteed to be at the end. * have NULLs which aren't guaranteed to be at the end.
*/ */
. = ALIGN(16); . = ALIGN(16);
_init_array = .; __init_array_start = .;
*(SORT(.init_array.*)) *(SORT(.init_array.*))
*(.init_array) *(.init_array)
_init_array_end = .; __init_array_end = .;
__CTOR_LIST__ = .; __CTOR_LIST__ = .;
*(SORT(.ctors.*)) *(SORT(.ctors.*))
*(.ctors) *(.ctors)
@ -47,10 +47,10 @@ SECTIONS
*(SORT(.dtors.*)) *(SORT(.dtors.*))
*(.dtors) *(.dtors)
__DTOR_END__ = .; __DTOR_END__ = .;
_fini_array = .; __fini_array_start = .;
*(SORT(.fini_array.*)) *(SORT(.fini_array.*))
*(.fini_array) *(.fini_array)
_fini_array_end = .; __fini_array_end = .;
/* the EFI loader doesn't seem to like a .bss section, so we stick /* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */ it all into .data: */

View File

@ -39,10 +39,10 @@ SECTIONS
* have NULLs which aren't guaranteed to be at the end. * have NULLs which aren't guaranteed to be at the end.
*/ */
. = ALIGN(16); . = ALIGN(16);
_init_array = .; __init_array_start = .;
*(SORT(.init_array.*)) *(SORT(.init_array.*))
*(.init_array) *(.init_array)
_init_array_end = .; __init_array_end = .;
__CTOR_LIST__ = .; __CTOR_LIST__ = .;
*(SORT(.ctors.*)) *(SORT(.ctors.*))
*(.ctors) *(.ctors)
@ -51,10 +51,10 @@ SECTIONS
*(SORT(.dtors.*)) *(SORT(.dtors.*))
*(.dtors) *(.dtors)
__DTOR_END__ = .; __DTOR_END__ = .;
_fini_array = .; __fini_array_start = .;
*(SORT(.fini_array.*)) *(SORT(.fini_array.*))
*(.fini_array) *(.fini_array)
_fini_array_end = .; __fini_array_end = .;
/* the EFI loader doesn't seem to like a .bss section, so we stick /* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */ it all into .data: */

View File

@ -48,10 +48,10 @@ SECTIONS
* have NULLs which aren't guaranteed to be at the end. * have NULLs which aren't guaranteed to be at the end.
*/ */
. = ALIGN(16); . = ALIGN(16);
_init_array = .; __init_array_start = .;
*(SORT(.init_array.*)) *(SORT(.init_array.*))
*(.init_array) *(.init_array)
_init_array_end = .; __init_array_end = .;
__CTOR_LIST__ = .; __CTOR_LIST__ = .;
*(SORT(.ctors.*)) *(SORT(.ctors.*))
*(.ctors) *(.ctors)
@ -60,10 +60,10 @@ SECTIONS
*(SORT(.dtors.*)) *(SORT(.dtors.*))
*(.dtors) *(.dtors)
__DTOR_END__ = .; __DTOR_END__ = .;
_fini_array = .; __fini_array_start = .;
*(SORT(.fini_array.*)) *(SORT(.fini_array.*))
*(.fini_array) *(.fini_array)
_fini_array_end = .; __fini_array_end = .;
/* the EFI loader doesn't seem to like a .bss section, so we stick /* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */ it all into .data: */

View File

@ -49,10 +49,10 @@ SECTIONS
* have NULLs which aren't guaranteed to be at the end. * have NULLs which aren't guaranteed to be at the end.
*/ */
. = ALIGN(16); . = ALIGN(16);
_init_array = .; __init_array_start = .;
*(SORT(.init_array.*)) *(SORT(.init_array.*))
*(.init_array) *(.init_array)
_init_array_end = .; __init_array_end = .;
__CTOR_LIST__ = .; __CTOR_LIST__ = .;
*(SORT(.ctors.*)) *(SORT(.ctors.*))
*(.ctors) *(.ctors)
@ -61,10 +61,10 @@ SECTIONS
*(SORT(.dtors.*)) *(SORT(.dtors.*))
*(.dtors) *(.dtors)
__DTOR_END__ = .; __DTOR_END__ = .;
_fini_array = .; __fini_array_start = .;
*(SORT(.fini_array.*)) *(SORT(.fini_array.*))
*(.fini_array) *(.fini_array)
_fini_array_end = .; __fini_array_end = .;
/* the EFI loader doesn't seem to like a .bss section, so we stick /* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */ it all into .data: */

View File

@ -36,10 +36,10 @@ SECTIONS
* have NULLs which aren't guaranteed to be at the end. * have NULLs which aren't guaranteed to be at the end.
*/ */
. = ALIGN(16); . = ALIGN(16);
_init_array = .; __init_array_start = .;
*(SORT(.init_array.*)) *(SORT(.init_array.*))
*(.init_array) *(.init_array)
_init_array_end = .; __init_array_end = .;
__CTOR_LIST__ = .; __CTOR_LIST__ = .;
*(SORT(.ctors.*)) *(SORT(.ctors.*))
*(.ctors) *(.ctors)
@ -48,10 +48,10 @@ SECTIONS
*(SORT(.dtors.*)) *(SORT(.dtors.*))
*(.dtors) *(.dtors)
__DTOR_END__ = .; __DTOR_END__ = .;
_fini_array = .; __fini_array_start = .;
*(SORT(.fini_array.*)) *(SORT(.fini_array.*))
*(.fini_array) *(.fini_array)
_fini_array_end = .; __fini_array_end = .;
/* the EFI loader doesn't seem to like a .bss section, so we stick /* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */ it all into .data: */

View File

@ -46,10 +46,10 @@ SECTIONS
* have NULLs which aren't guaranteed to be at the end. * have NULLs which aren't guaranteed to be at the end.
*/ */
. = ALIGN(16); . = ALIGN(16);
_init_array = .; __init_array_start = .;
*(SORT(.init_array.*)) *(SORT(.init_array.*))
*(.init_array) *(.init_array)
_init_array_end = .; __init_array_end = .;
__CTOR_LIST__ = .; __CTOR_LIST__ = .;
*(SORT(.ctors.*)) *(SORT(.ctors.*))
*(.ctors) *(.ctors)
@ -58,10 +58,10 @@ SECTIONS
*(SORT(.dtors.*)) *(SORT(.dtors.*))
*(.dtors) *(.dtors)
__DTOR_END__ = .; __DTOR_END__ = .;
_fini_array = .; __fini_array_start = .;
*(SORT(.fini_array.*)) *(SORT(.fini_array.*))
*(.fini_array) *(.fini_array)
_fini_array_end = .; __fini_array_end = .;
/* the EFI loader doesn't seem to like a .bss section, so we stick /* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */ it all into .data: */

View File

@ -44,10 +44,10 @@ SECTIONS
* have NULLs which aren't guaranteed to be at the end. * have NULLs which aren't guaranteed to be at the end.
*/ */
. = ALIGN(16); . = ALIGN(16);
_init_array = .; __init_array_start = .;
*(SORT(.init_array.*)) *(SORT(.init_array.*))
*(.init_array) *(.init_array)
_init_array_end = .; __init_array_end = .;
__CTOR_LIST__ = .; __CTOR_LIST__ = .;
*(SORT(.ctors.*)) *(SORT(.ctors.*))
*(.ctors) *(.ctors)
@ -56,10 +56,10 @@ SECTIONS
*(SORT(.dtors.*)) *(SORT(.dtors.*))
*(.dtors) *(.dtors)
__DTOR_END__ = .; __DTOR_END__ = .;
_fini_array = .; __fini_array_start = .;
*(SORT(.fini_array.*)) *(SORT(.fini_array.*))
*(.fini_array) *(.fini_array)
_fini_array_end = .; __fini_array_end = .;
/* the EFI loader doesn't seem to like a .bss section, so we stick /* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */ it all into .data: */

View File

@ -10,11 +10,11 @@
*/ */
.section .init_array, "aw", @init_array .section .init_array, "aw", @init_array
.p2align 3, 0 .p2align 3, 0
.globl _init_array .globl __init_array_start
_init_array: __init_array_start:
.p2align 3, 0 .p2align 3, 0
.globl _init_array_end .globl __init_array_end
_init_array_end: __init_array_end:
.long 0 .long 0
.section .ctors, "aw", @progbits .section .ctors, "aw", @progbits
.p2align 3, 0 .p2align 3, 0
@ -34,11 +34,11 @@ __DTOR_END__:
.long 0 .long 0
.section .fini_array, "aw", @fini_array .section .fini_array, "aw", @fini_array
.p2align 3, 0 .p2align 3, 0
.globl _fini_array .globl __fini_array_start
_fini_array: __fini_array_start:
.p2align 3, 0 .p2align 3, 0
.globl _fini_array_end .globl __fini_array_end
_fini_array_end: __fini_array_end:
.long 0 .long 0
#if defined(__ELF__) && defined(__linux__) #if defined(__ELF__) && defined(__linux__)

View File

@ -13,16 +13,16 @@
* end/END definitions, and the fact that they're mergeable, they can also * end/END definitions, and the fact that they're mergeable, they can also
* have NULLs which aren't guaranteed to be at the end. * have NULLs which aren't guaranteed to be at the end.
*/ */
extern UINTN _init_array, _init_array_end; extern UINTN __init_array_start, __init_array_end;
extern UINTN __CTOR_LIST__, __CTOR_END__; extern UINTN __CTOR_LIST__, __CTOR_END__;
extern UINTN _fini_array, _fini_array_end; extern UINTN __fini_array_start, __fini_array_end;
extern UINTN __DTOR_LIST__, __DTOR_END__; extern UINTN __DTOR_LIST__, __DTOR_END__;
typedef void (*funcp)(void); typedef void (*funcp)(void);
static void ctors(void) static void ctors(void)
{ {
for (funcp *location = (void *)&_init_array; location < (funcp *)&_init_array_end; location++) { for (funcp *location = (void *)&__init_array_start; location < (funcp *)&__init_array_end; location++) {
funcp func = *location; funcp func = *location;
if (location != NULL) if (location != NULL)
func(); func();
@ -43,7 +43,7 @@ static void dtors(void)
func(); func();
} }
for (funcp *location = (void *)&_fini_array; location < (funcp *)&_fini_array_end; location++) { for (funcp *location = (void *)&__fini_array_start; location < (funcp *)&__fini_array_end; location++) {
funcp func = *location; funcp func = *location;
if (location != NULL) if (location != NULL)
func(); func();