diff options
| author | Mark Johnston <markj@FreeBSD.org> | 2026-07-15 14:59:22 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2026-07-15 14:59:22 +0000 |
| commit | 83181995593ac61796d7be63dcb241f5d80faa73 (patch) | |
| tree | 61efbb3b313d8790ef58703078799d8f976d655d | |
| parent | 4b0ae7e001a97e5449835bb8a2e6c2e6f53aac39 (diff) | |
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
| -rw-r--r-- | sys/kern/link_elf.c | 5 |
1 files 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; |
