From f4dcdbec0eb4caa7b1830285df302b381e5e0798 Mon Sep 17 00:00:00 2001 From: Stuart Ianna Date: Wed, 19 Apr 2023 16:33:41 +1000 Subject: [PATCH] libelf: Support prioritized init and fini arrays. Add a wildcard operator to gnu-elf.ld to ensure all c++ constructors and destruction are included in partially linked application binaries. --- binfmt/libelf/gnu-elf.ld | 2 ++ 1 file changed, 2 insertions(+) diff --git a/binfmt/libelf/gnu-elf.ld b/binfmt/libelf/gnu-elf.ld index 6ff5ab5fad..81928663ee 100644 --- a/binfmt/libelf/gnu-elf.ld +++ b/binfmt/libelf/gnu-elf.ld @@ -75,6 +75,7 @@ SECTIONS _sctors = . ; *(.ctors) /* Old ABI: Unallocated */ *(.init_array) /* New ABI: Allocated */ + *(SORT(.init_array.*)) _ectors = . ; } @@ -83,6 +84,7 @@ SECTIONS _sdtors = . ; *(.dtors) /* Old ABI: Unallocated */ *(.fini_array) /* New ABI: Allocated */ + *(SORT(.fini_array.*)) _edtors = . ; }