From 6c142a6df484318b52fc90d0e8190d58b1b5d203 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Sat, 20 May 2023 19:13:14 +0100 Subject: [PATCH] riscv64 lds: fix ctors/dtors Signed-off-by: Callum Farmer --- gnuefi/elf_riscv64_efi.lds | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/gnuefi/elf_riscv64_efi.lds b/gnuefi/elf_riscv64_efi.lds index d5153e9..5cb3d85 100644 --- a/gnuefi/elf_riscv64_efi.lds +++ b/gnuefi/elf_riscv64_efi.lds @@ -31,6 +31,34 @@ SECTIONS { *(.got.plt) *(.got) + /* + * Note that these aren't the using the GNU "CONSTRUCTOR" output section + * command, so they don't start with a size. Because of p2align and the + * end/END definitions, and the fact that they're mergeable, they can also + * have NULLs which aren't guaranteed to be at the end. + */ + . = ALIGN(16); + __init_array_start = .; + *(SORT(.init_array.*)) + *(.init_array) + __init_array_end = .; + . = ALIGN(16); + __CTOR_LIST__ = .; + *(SORT(.ctors.*)) + *(.ctors) + __CTOR_END__ = .; + . = ALIGN(16); + __DTOR_LIST__ = .; + *(SORT(.dtors.*)) + *(.dtors) + __DTOR_END__ = .; + . = ALIGN(16); + __fini_array_start = .; + *(SORT(.fini_array.*)) + *(.fini_array) + __fini_array_end = .; + + /* the EFI loader doesn't seem to like a .bss section, so we stick it all into .data: */ . = ALIGN(16); @@ -52,10 +80,10 @@ SECTIONS { *(.rela.got) *(.rela.dyn) *(.rela.stab) - *(.rela.init_array) - *(.rela.fini_array) - *(.rela.ctors) - *(.rela.dtors) + *(.rela.init_array*) + *(.rela.fini_array*) + *(.rela.ctors*) + *(.rela.dtors*) } . = ALIGN(4096); .rela.plt : { *(.rela.plt) }