Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Aug 2026 15:01:28 +0000
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 984a3970b16f - stable/15 - stand: Recognize SHT_INIT_ARRAY sections as constructor sections
Message-ID:  <6a74a1c8.46d10.55d5854b@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=984a3970b16fd603bba7554b4a4c7449550bd5cb

commit 984a3970b16fd603bba7554b4a4c7449550bd5cb
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-07-15 14:58:32 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-08-06 12:52:28 +0000

    stand: Recognize SHT_INIT_ARRAY sections as constructor sections
    
    Pass such a section to the kernel using modinfo, otherwise link_elf.c
    won't execute constructors for the file.  This is required for KASAN,
    otherwise redzones for global buffers are not poisoned during boot.
    
    Reviewed by:    kib
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D58244
    
    (cherry picked from commit 4b0ae7e001a97e5449835bb8a2e6c2e6f53aac39)
---
 stand/common/load_elf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c
index b9f55a21e403..1b5f1daded09 100644
--- a/stand/common/load_elf.c
+++ b/stand/common/load_elf.c
@@ -725,7 +725,8 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_t ef, uint64_t off)
 		if (shstr) {
 			for (i = 0; i < ehdr->e_shnum; i++) {
 				if (strcmp(shstr + shdr[i].sh_name,
-				    ".ctors") != 0)
+				    ".ctors") != 0 &&
+				    shdr[i].sh_type != SHT_INIT_ARRAY)
 					continue;
 				ctors = shdr[i].sh_addr;
 				file_addmetadata(fp, MODINFOMD_CTORS_ADDR,


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a74a1c8.46d10.55d5854b>