Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Jul 2026 15:04:15 +0000
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 83181995593a - main - linker: Recognize SHT_INIT_ARRAY sections as constructor sections
Message-ID:  <6a57a16f.3f37c.1961ba68@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=83181995593ac61796d7be63dcb241f5d80faa73

commit 83181995593ac61796d7be63dcb241f5d80faa73
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-07-15 14:59:22 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
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;


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a57a16f.3f37c.1961ba68>