From c62b35a12c13b71316422c1eaca92d9a9cfd8fb2 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Tue, 12 Nov 2024 12:24:34 +0800 Subject: [PATCH] modlib:need add ctors to init_array and dtors to fini_array Signed-off-by: anjiahao --- libs/libc/modlib/gnu-elf.ld | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/libc/modlib/gnu-elf.ld b/libs/libc/modlib/gnu-elf.ld index 357d7356f1..bd5733f335 100644 --- a/libs/libc/modlib/gnu-elf.ld +++ b/libs/libc/modlib/gnu-elf.ld @@ -36,13 +36,16 @@ SECTIONS .init_array : { _sinit = .; - *(.init_array) + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) _einit = .; } .fini_array : { - *(.fini_array) + KEEP (*(.dtors)) + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) } .rodata :