From nobody Fri Nov 21 13:33:59 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dCblq1w42z6HCVx for ; Fri, 21 Nov 2025 13:33:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dCblq15pVz3X9s for ; Fri, 21 Nov 2025 13:33:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763732039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fmUqAbdvl3hWiEVaDkQcJzWLH5Fg+hzw3n9JvL7aTPY=; b=UNUln9KirkmN0W/Ysd0H3+Zs7JqVSKvOmig9nA+dm8+9KxDVx7zysqiTV8USinWNQ0GgyG 5SYUWYT0PM68GEVsVgkITBKpJ50iXfG6WDGBTVbTi0l4Q6rvr6KFrhzDOEsMiTUDcFvqtL xUq963cfWV3jfUnrRsjrQexggHhXwBznn9JN7QSAIA4XYapEMEzTGD0oIKLFmVP7uYxrem 1nqvAOBQgdkUyipikySnB4K7tjoqPziNO1E6sYMRmQQlnhutWTx0mww6w7+wqDmrCU0TyM oLr4YZ0Xr9l1L2gDXEZSsT0vVPm3XSinMwRRx/8X0ZAESGQRJkeIYZmYdeA2ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763732039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fmUqAbdvl3hWiEVaDkQcJzWLH5Fg+hzw3n9JvL7aTPY=; b=mv+uNL/+slByUOamB4zsTOmBywaRCuWFTscfnSEC766pg1rw9RJj9j3ebYC7/XgZPH2XGA hCRKgDz9Wm8NRrSUalaN0TaB/CPguFUOJpEW2TDl5SYA/AHWqDrDHa3wgzomRCh5hCCHnm H1TjSCk+XAiuDdUleThPiXN46YVlCIiRNc/uawlFj2OTN0x27pz5UObvubxMCVaRXn0VIn am+J0oEMey6QU9B+XDamHyXQPzLSNVVUc3ibqL1nYnOrUk3OGi/SM3549CtOXHmFTVcGa+ miEyAVhT6+XKK0PXki9d8EoeWJAeeAhRrn98rmQMez2P24qbbL40wZ8ytXvZRA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1763732039; a=rsa-sha256; cv=none; b=dS6OHDivzp+vKgOrr0lEypRwZUhT/lEgyibH9utF2vtvJPq6X08gl1qQhyYS7ZVPjw8J/h cvxY2ClD3aHmtZJASXEyfkTCfpeD1XZx5v5yjpVC8nb9KnzRiGufw00pujcr8+l6/xMCQ+ 2NZvpTXTc0zU3UuuLyTCgYJKawPg/MDB+a6dakJ6OQvp85kmRlTn1a5jbXhsyIAM6TYzRs A2msr6AtFQcwRwCcn4sDhJkXC86uztGHUb+708Qk9gjZJez+5zuDEd1C3JnuAfjUc1qpxj cFgoprdHTRhOhWeX9Sw78NEJJ/c6rIAZtTVqFLvT/eJMi7hDqJ3PcxAXTnLEYw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dCblq0fkVzGx for ; Fri, 21 Nov 2025 13:33:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27746 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 21 Nov 2025 13:33:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b2b3d2a962eb - main - rtld-elf: move powerpc-specific auxv compat code into arch hook List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b2b3d2a962eb00005641546fbe672b95e5d0672a Auto-Submitted: auto-generated Date: Fri, 21 Nov 2025 13:33:59 +0000 Message-Id: <69206a47.27746.245d9408@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b2b3d2a962eb00005641546fbe672b95e5d0672a commit b2b3d2a962eb00005641546fbe672b95e5d0672a Author: Konstantin Belousov AuthorDate: 2025-11-18 11:06:04 +0000 Commit: Konstantin Belousov CommitDate: 2025-11-21 13:33:17 +0000 rtld-elf: move powerpc-specific auxv compat code into arch hook Tested by: Timothy Pearson (tpearson_raptorengineering.com) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D53801 --- libexec/rtld-elf/aarch64/rtld_machdep.h | 2 ++ libexec/rtld-elf/amd64/rtld_machdep.h | 2 ++ libexec/rtld-elf/arm/rtld_machdep.h | 2 ++ libexec/rtld-elf/i386/rtld_machdep.h | 2 ++ libexec/rtld-elf/powerpc/reloc.c | 26 ++++++++++++++++++++++++++ libexec/rtld-elf/powerpc/rtld_machdep.h | 2 ++ libexec/rtld-elf/powerpc64/reloc.c | 26 ++++++++++++++++++++++++++ libexec/rtld-elf/powerpc64/rtld_machdep.h | 2 ++ libexec/rtld-elf/riscv/rtld_machdep.h | 2 ++ libexec/rtld-elf/rtld.c | 25 +------------------------ 10 files changed, 67 insertions(+), 24 deletions(-) diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h index 3cc1339fcad4..d689ae354c49 100644 --- a/libexec/rtld-elf/aarch64/rtld_machdep.h +++ b/libexec/rtld-elf/aarch64/rtld_machdep.h @@ -52,6 +52,8 @@ bool arch_digest_dynamic(struct Struct_Obj_Entry *obj, const Elf_Dyn *dynp); bool arch_digest_note(struct Struct_Obj_Entry *obj, const Elf_Note *note); +#define arch_fix_auxv(a, ai) do {} while (0) + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h index 1797d13c847d..2ee63d566bed 100644 --- a/libexec/rtld-elf/amd64/rtld_machdep.h +++ b/libexec/rtld-elf/amd64/rtld_machdep.h @@ -47,6 +47,8 @@ Elf_Dyn *rtld_dynamic_addr(void); /* No architecture specific notes */ #define arch_digest_note(obj, note) false +#define arch_fix_auxv(a, ai) do {} while (0) + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *obj, const struct Struct_Obj_Entry *refobj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h index f59b30028a3b..88fa18a0c07a 100644 --- a/libexec/rtld-elf/arm/rtld_machdep.h +++ b/libexec/rtld-elf/arm/rtld_machdep.h @@ -47,6 +47,8 @@ struct Struct_Obj_Entry; /* No architecture specific notes */ #define arch_digest_note(obj, note) false +#define arch_fix_auxv(a, ai) do {} while (0) + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h index 581f1dfb002d..079991f913d6 100644 --- a/libexec/rtld-elf/i386/rtld_machdep.h +++ b/libexec/rtld-elf/i386/rtld_machdep.h @@ -60,6 +60,8 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, #define call_init_pointer(obj, target) \ (((InitArrFunc)(target))(main_argc, main_argv, environ)) +#define arch_fix_auxv(a, ai) do {} while (0) + extern uint32_t cpu_feature; extern uint32_t cpu_feature2; extern uint32_t cpu_stdext_feature; diff --git a/libexec/rtld-elf/powerpc/reloc.c b/libexec/rtld-elf/powerpc/reloc.c index 8932c2c21278..a38cadfe76ba 100644 --- a/libexec/rtld-elf/powerpc/reloc.c +++ b/libexec/rtld-elf/powerpc/reloc.c @@ -840,3 +840,29 @@ __tls_get_addr(tls_index* ti) return (tls_get_addr_common(_tcb_get(), ti->ti_module, ti->ti_offset + TLS_DTV_OFFSET)); } + +void +arch_fix_auxv(Elf_Auxinfo *aux, Elf_Auxinfo *aux_info[]) +{ + Elf_Auxinfo *aux; + bool old_auxv_format; + + old_auxv_format = true; + for (auxp = aux; auxp->a_type != AT_NULL; auxp++) { + if (auxp->a_type == 23) /* AT_STACKPROT */ + return; + } + + /* Remap from old-style auxv numbers. */ + aux_info[23] = aux_info[21]; /* AT_STACKPROT */ + aux_info[21] = aux_info[19]; /* AT_PAGESIZESLEN */ + aux_info[19] = aux_info[17]; /* AT_NCPUS */ + aux_info[17] = aux_info[15]; /* AT_CANARYLEN */ + aux_info[15] = aux_info[13]; /* AT_EXECPATH */ + aux_info[13] = NULL; /* AT_GID */ + + aux_info[20] = aux_info[18]; /* AT_PAGESIZES */ + aux_info[18] = aux_info[16]; /* AT_OSRELDATE */ + aux_info[16] = aux_info[14]; /* AT_CANARY */ + aux_info[14] = NULL; /* AT_EGID */ +} diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h index ec470f238991..de6a894ac1f5 100644 --- a/libexec/rtld-elf/powerpc/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc/rtld_machdep.h @@ -46,6 +46,8 @@ bool arch_digest_dynamic(struct Struct_Obj_Entry *, const Elf_Dyn *); /* No architecture specific notes */ #define arch_digest_note(obj, note) false +void arch_fix_auxv(Elf_Auxinfo *aux, Elf_Auxinfo *aux_info[]); + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/powerpc64/reloc.c b/libexec/rtld-elf/powerpc64/reloc.c index 9ea14f63b5c7..29c52d8fc19f 100644 --- a/libexec/rtld-elf/powerpc64/reloc.c +++ b/libexec/rtld-elf/powerpc64/reloc.c @@ -737,3 +737,29 @@ __tls_get_addr(tls_index* ti) return (tls_get_addr_common(_tcb_get(), ti->ti_module, ti->ti_offset + TLS_DTV_OFFSET)); } + +void +arch_fix_auxv(Elf_Auxinfo *aux, Elf_Auxinfo *aux_info[]) +{ + Elf_Auxinfo *aux; + bool old_auxv_format; + + old_auxv_format = true; + for (auxp = aux; auxp->a_type != AT_NULL; auxp++) { + if (auxp->a_type == 23) /* AT_STACKPROT */ + return; + } + + /* Remap from old-style auxv numbers. */ + aux_info[23] = aux_info[21]; /* AT_STACKPROT */ + aux_info[21] = aux_info[19]; /* AT_PAGESIZESLEN */ + aux_info[19] = aux_info[17]; /* AT_NCPUS */ + aux_info[17] = aux_info[15]; /* AT_CANARYLEN */ + aux_info[15] = aux_info[13]; /* AT_EXECPATH */ + aux_info[13] = NULL; /* AT_GID */ + + aux_info[20] = aux_info[18]; /* AT_PAGESIZES */ + aux_info[18] = aux_info[16]; /* AT_OSRELDATE */ + aux_info[16] = aux_info[14]; /* AT_CANARY */ + aux_info[14] = NULL; /* AT_EGID */ +} diff --git a/libexec/rtld-elf/powerpc64/rtld_machdep.h b/libexec/rtld-elf/powerpc64/rtld_machdep.h index d628e776bae9..06eb6d884101 100644 --- a/libexec/rtld-elf/powerpc64/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc64/rtld_machdep.h @@ -46,6 +46,8 @@ bool arch_digest_dynamic(struct Struct_Obj_Entry *, const Elf_Dyn *); /* No architecture specific notes */ #define arch_digest_note(obj, note) false +void arch_fix_auxv(Elf_Auxinfo *aux, Elf_Auxinfo *aux_info[]); + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/riscv/rtld_machdep.h b/libexec/rtld-elf/riscv/rtld_machdep.h index c6600b583612..1f4fe2e928fe 100644 --- a/libexec/rtld-elf/riscv/rtld_machdep.h +++ b/libexec/rtld-elf/riscv/rtld_machdep.h @@ -60,6 +60,8 @@ uint64_t set_gp(struct Struct_Obj_Entry *obj); /* No architecture specific notes */ #define arch_digest_note(obj, note) false +#define arch_fix_auxv(a, ai) do {} while (0) + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index d27af520c21d..bdfff7361e96 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -521,9 +521,6 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) char buf[MAXPATHLEN]; int argc, fd, i, mib[4], old_osrel, osrel, phnum, rtld_argc; size_t sz; -#ifdef __powerpc__ - int old_auxv_format = 1; -#endif bool dir_enable, dir_ignore, direct_exec, explicit_fd, search_in_path; /* @@ -549,28 +546,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) for (auxp = aux; auxp->a_type != AT_NULL; auxp++) { if (auxp->a_type < AT_COUNT) aux_info[auxp->a_type] = auxp; -#ifdef __powerpc__ - if (auxp->a_type == 23) /* AT_STACKPROT */ - old_auxv_format = 0; -#endif - } - -#ifdef __powerpc__ - if (old_auxv_format) { - /* Remap from old-style auxv numbers. */ - aux_info[23] = aux_info[21]; /* AT_STACKPROT */ - aux_info[21] = aux_info[19]; /* AT_PAGESIZESLEN */ - aux_info[19] = aux_info[17]; /* AT_NCPUS */ - aux_info[17] = aux_info[15]; /* AT_CANARYLEN */ - aux_info[15] = aux_info[13]; /* AT_EXECPATH */ - aux_info[13] = NULL; /* AT_GID */ - - aux_info[20] = aux_info[18]; /* AT_PAGESIZES */ - aux_info[18] = aux_info[16]; /* AT_OSRELDATE */ - aux_info[16] = aux_info[14]; /* AT_CANARY */ - aux_info[14] = NULL; /* AT_EGID */ } -#endif + arch_fix_auxv(aux, aux_info); /* Initialize and relocate ourselves. */ assert(aux_info[AT_BASE] != NULL);