The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=83181995593ac61796d7be63dcb241f5d80faa73
commit 83181995593ac61796d7be63dcb241f5d80faa73 Author: Mark Johnston <[email protected]> AuthorDate: 2026-07-15 14:59:22 +0000 Commit: Mark Johnston <[email protected]> CommitDate: 2026-07-15 14:59:22 +0000 linker: Recognize SHT_INIT_ARRAY sections as constructor sections We do this already for ET_REL files, but it was missed here. Note that this function operates only on dynamically loaded files, not on preloaded files. Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D58245 --- sys/kern/link_elf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 3a1bec6b09b5..613dfe0133d4 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -1306,8 +1306,9 @@ link_elf_load_file(linker_class_t cls, const char* filename, if (shdr[i].sh_type == SHT_SYMTAB) { symtabindex = i; symstrindex = shdr[i].sh_link; - } else if (shstrs != NULL && shdr[i].sh_name != 0 && - strcmp(shstrs + shdr[i].sh_name, ".ctors") == 0) { + } else if ((shstrs != NULL && shdr[i].sh_name != 0 && + strcmp(shstrs + shdr[i].sh_name, ".ctors") == 0) || + shdr[i].sh_type == SHT_INIT_ARRAY) { /* Record relocated address and size of .ctors. */ lf->ctors_addr = mapbase + shdr[i].sh_addr - base_vaddr; lf->ctors_size = shdr[i].sh_size;
