diff --git a/boards/risc-v/qemu-rv/rv-virt/scripts/ld-kernel32.script b/boards/risc-v/qemu-rv/rv-virt/scripts/ld-kernel32.script index ae9c92bfb0..7ce1e08016 100644 --- a/boards/risc-v/qemu-rv/rv-virt/scripts/ld-kernel32.script +++ b/boards/risc-v/qemu-rv/rv-virt/scripts/ld-kernel32.script @@ -65,6 +65,14 @@ SECTIONS _etext = . ; } + .init_section : + { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _einit = ABSOLUTE(.); + } + .rodata : { _srodata = . ; diff --git a/boards/risc-v/qemu-rv/rv-virt/scripts/ld-kernel64.script b/boards/risc-v/qemu-rv/rv-virt/scripts/ld-kernel64.script index bfab060ee6..514d23efcd 100644 --- a/boards/risc-v/qemu-rv/rv-virt/scripts/ld-kernel64.script +++ b/boards/risc-v/qemu-rv/rv-virt/scripts/ld-kernel64.script @@ -65,6 +65,14 @@ SECTIONS _etext = . ; } + .init_section : + { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _einit = ABSOLUTE(.); + } + .rodata : { _srodata = . ; diff --git a/boards/risc-v/qemu-rv/rv-virt/scripts/ld.script b/boards/risc-v/qemu-rv/rv-virt/scripts/ld.script index 664bbb178f..e1ab1cfd96 100644 --- a/boards/risc-v/qemu-rv/rv-virt/scripts/ld.script +++ b/boards/risc-v/qemu-rv/rv-virt/scripts/ld.script @@ -43,6 +43,14 @@ SECTIONS _etext = . ; } + .init_section : + { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _einit = ABSOLUTE(.); + } + .rodata : { _srodata = . ; @@ -78,30 +86,6 @@ SECTIONS _edata = . ; } - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - .bss : { _sbss = . ;