From fdaacb9408e871f2bf12c8d1e6fe06e0dffe46d5 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Tue, 27 Feb 2024 17:01:08 +0800 Subject: [PATCH] rv-virt: Add .init_section to linker script Provide _sinit/_einit to make it possible to enable libcxx on rv-virt platform. Signed-off-by: Huang Qi --- .../rv-virt/scripts/ld-kernel32.script | 8 +++++ .../rv-virt/scripts/ld-kernel64.script | 8 +++++ .../risc-v/qemu-rv/rv-virt/scripts/ld.script | 32 +++++-------------- 3 files changed, 24 insertions(+), 24 deletions(-) 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 ae9c92bfb01..7ce1e080168 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 bfab060ee68..514d23efcd8 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 664bbb178f1..e1ab1cfd96e 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 = . ;