From nobody Mon Feb 19 22:44:35 2024 X-Original-To: dev-commits-src-main@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 4TdyK01yTMz59dxW; Mon, 19 Feb 2024 22:44:36 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TdyK00nKnz4Y9T; Mon, 19 Feb 2024 22:44:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708382676; 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=Gbet1e9vffYsMXAukC4xeW0vecj4voAYSihpVb+cIXo=; b=cXTAQ7bYsB5uHjtomzVoRa/DupxlgRhyrWPlgQRzAfeiJM9hwqPoxtC4/04/GJJgJXL+Yj GRvvaVOSZYJKhIO1HCL9vAJyI62TOXEm+R1Pt5t+5ay8pHmFJU2h/FIba/QSrHFBQLt7Dz M4unY3+l9carLqUtABnHBB+wPef8kB4dV5Cn88P0S0DxGxWs1nfIdbfdEMZr4zwZ2GsCqg FriJP11fpcEX/IuaeqOUflcEdnCCKEI49hh96GGtBQNM5swsAWJ9TLFUx+QJmzycWiG+l/ QmW+BkZ2jHnWtxNRsgvMDErbY33v54CtQA4zt70pmRUdbBceCcwWje2lccIjCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708382676; 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=Gbet1e9vffYsMXAukC4xeW0vecj4voAYSihpVb+cIXo=; b=xpA38eb8hlyvQwqMlRfwbhw91GQG9YD2/hJzAOE54auFy1/WDc8lnea9J9mlobuILkZl6H yLbHbUmFs2EwLAWeWgEO90PPS0mGebqZIeMdrsX6zu6Vtc6Jrsr9pgDjcly4t9sA6s+AHp 4+qoSKWfiTwFjj2xyNk0JEiP7TIH9fOpPbuHnnfytX+1ZcxEdwq1JvFg7HO43EjCfEoW4+ yvrNfifRCTM+8OlyG5zmGiEsV+hqR6EKG2DZkurqeHqqPAre1dk8w3QgZHnveZzVIiS7YY 5XGAL8enYSTpXM15n6lQwgts8TqlMh786AyUVgZ+Bbs5sqCTYD62QXZt3s+4AA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708382676; a=rsa-sha256; cv=none; b=Fi96bSzFtMTJ+MDBMxXhwY1hk5i3VhZU7lDQW+NxPoH1tdJ11Bwe7EaeT6EL2ouJ+78yIJ wOLMuaYSs8/j1avmvs9IJbaQwciiJBhcdOBDacjzgC5Kahi04kuiBazGZtDq5z7z4RtDkq zJO+VTVteTpkO5vfyxqlSvfwyOnt+XiDFWS+HloYC1DbDAtNiB+JOW4eQY7JRFsZYms1im gK4hL/xk3EEUULKq1hSojo5ZDCN7N6w4mIS3lae9WJr09DixJUD7HTPcGFlA/rOurkBmpb T0kj1Ml89mMGMOK1P8O1Yl7W71AjP5Crj3QX23HLaEj9bzlEjSpJ0pmH/BPPxg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TdyJz6rb8ztCD; Mon, 19 Feb 2024 22:44:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41JMiZoj002752; Mon, 19 Feb 2024 22:44:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41JMiZc2002749; Mon, 19 Feb 2024 22:44:35 GMT (envelope-from git) Date: Mon, 19 Feb 2024 22:44:35 GMT Message-Id: <202402192244.41JMiZc2002749@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: 99ea67573164 - main - lib{c,sys}: move auxargs more firmly into libsys List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 99ea67573164637d633e8051eb0a5d52f1f9488e Auto-Submitted: auto-generated The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=99ea67573164637d633e8051eb0a5d52f1f9488e commit 99ea67573164637d633e8051eb0a5d52f1f9488e Author: Brooks Davis AuthorDate: 2024-02-19 22:44:08 +0000 Commit: Brooks Davis CommitDate: 2024-02-19 22:44:08 +0000 lib{c,sys}: move auxargs more firmly into libsys Continue to filter the public interface (elf_aux_info()), but entierly relocate the private interfaces (_elf_aux_info(), __init_elf_aux_vector(), and __elf_aux_vector) to libsys. This ensures that rtld updates the correct (only) copy of __elf_aux_vector. After 968a18975adc9c2a619bb52aa2f009de99fc9e24 updates were confused and __getosreldate was failing, causing the system to fall back to compat compat12 syscalls in some cases. Return to explicitly linking libc to libsys and link libthr with libc and libsys (in that order). Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D43910 --- lib/libc/Makefile | 1 + lib/libc/tests/ssp/Makefile | 1 + lib/libsys/Makefile | 3 +++ lib/libsys/Makefile.sys | 10 ++++++++-- lib/libsys/Symbol.map | 5 +++++ lib/libsys/Symbol.sys.map | 2 -- lib/libsys/libc_stubs.c | 11 +++++++++++ lib/libthr/Makefile | 2 ++ share/mk/bsd.libnames.mk | 5 ++++- share/mk/src.libnames.mk | 6 +++++- 10 files changed, 40 insertions(+), 6 deletions(-) diff --git a/lib/libc/Makefile b/lib/libc/Makefile index 54748abfeff1..41cf0f6de72a 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -62,6 +62,7 @@ CFLAGS+= -ftls-model=initial-exec # LDFLAGS+= -nodefaultlibs LIBADD+= compiler_rt +LIBADD+= sys LDFLAGS+=-Wl,--auxiliary,libsys.so.7 diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile index c6f850ec1a33..22f48d7dfe54 100644 --- a/lib/libc/tests/ssp/Makefile +++ b/lib/libc/tests/ssp/Makefile @@ -10,6 +10,7 @@ CFLAGS.h_raw+= -fstack-protector-all -Wstack-protector # override the sanitizer runtime libraries to be the ones installed on the # target system. CFLAGS.h_raw+= -fsanitize=bounds +LIBADD+=sys .elif ${COMPILER_TYPE} == "gcc" CFLAGS.h_raw+= --param ssp-buffer-size=1 LDADD+= -lssp diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile index 897e033267a4..598962185dcf 100644 --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -57,6 +57,9 @@ MDASM= MIASM= NOASM= +SYM_MAPS+= ${LIBSYS_SRCTOP}/Symbol.map +SRCS+= auxv.c + .include "${LIBSYS_SRCTOP}/Makefile.sys" SYM_MAPS+= ${LIBSYS_SRCTOP}/Symbol.thr.map diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys index b45aa3cf1aaf..cb9ca1749ba8 100644 --- a/lib/libsys/Makefile.sys +++ b/lib/libsys/Makefile.sys @@ -47,8 +47,6 @@ SRCS+= recv.c recvmmsg.c send.c sendmmsg.c NOASM+= sched_getcpu.o PSEUDO+= _sched_getcpu.o -SRCS+= auxv.c - SRCS+= brk.c SRCS+= closefrom.c SRCS+= pipe.c @@ -58,6 +56,14 @@ SRCS+= POSIX2x_Fork.c SRCS+= compat-stub.c +.if ${LIB} == "c" +# Trapping stubs in dynamic libc to be filtered by libsys. +SOBJS+= libc_stubs.pico + +# Link the full implementation of ELF auxargs for static libc. +STATICOBJS+= auxv.o +.endif + INTERPOSED = \ accept \ accept4 \ diff --git a/lib/libsys/Symbol.map b/lib/libsys/Symbol.map new file mode 100644 index 000000000000..4f72ea204039 --- /dev/null +++ b/lib/libsys/Symbol.map @@ -0,0 +1,5 @@ +FBSDprivate_1.0 { + __elf_aux_vector; + __init_elf_aux_vector; + _elf_aux_info; +}; diff --git a/lib/libsys/Symbol.sys.map b/lib/libsys/Symbol.sys.map index 73a1cf297ca0..d59ac8674669 100644 --- a/lib/libsys/Symbol.sys.map +++ b/lib/libsys/Symbol.sys.map @@ -433,12 +433,10 @@ FBSD_1.8 { FBSDprivate_1.0 { /* Add entries in sort(1) order */ - __elf_aux_vector; __libc_sigwait; __libsys_interposing_slot; __set_error_selector; __sigwait; - _elf_aux_info; gssd_syscall; nlm_syscall; rpctls_syscall; diff --git a/lib/libsys/libc_stubs.c b/lib/libsys/libc_stubs.c new file mode 100644 index 000000000000..41d69a9355c3 --- /dev/null +++ b/lib/libsys/libc_stubs.c @@ -0,0 +1,11 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 SRI International + */ + +#define STUB_FUNC(f) \ + void (f)(void); \ + void (f)(void) { __builtin_trap(); } + +STUB_FUNC(elf_aux_info); diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile index 932650885dea..325a320d55ec 100644 --- a/lib/libthr/Makefile +++ b/lib/libthr/Makefile @@ -7,6 +7,8 @@ PACKAGE= clibs SHLIBDIR?= /lib +LIBADD= c sys + .include MK_SSP= no diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk index 414ae3164066..4177a1ef0e4e 100644 --- a/share/mk/bsd.libnames.mk +++ b/share/mk/bsd.libnames.mk @@ -174,7 +174,7 @@ LIBZFSBOOTENV?= ${LIBDESTDIR}${LIBDIR_BASE}/libzfsbootenv.a LIBZPOOL?= ${LIBDESTDIR}${LIBDIR_BASE}/libzpool.a LIBZUTIL?= ${LIBDESTDIR}${LIBDIR_BASE}/libzutil.a -# enforce the 2 -lpthread and -lc to always be the last in that exact order +# enforce -lpthread, -lc, and -lsys to always be the last in that exact order .if defined(LDADD) .if ${LDADD:M-lpthread} LDADD:= ${LDADD:N-lpthread} -lpthread @@ -182,6 +182,9 @@ LDADD:= ${LDADD:N-lpthread} -lpthread .if ${LDADD:M-lc} LDADD:= ${LDADD:N-lc} -lc .endif +.if ${LDADD:M-lsys} +LDADD:= ${LDADD:N-lsys} -lsys +.endif .endif # Only do this for src builds. diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk index 658dd1c3d699..0fd349d0d00f 100644 --- a/share/mk/src.libnames.mk +++ b/share/mk/src.libnames.mk @@ -394,7 +394,7 @@ _DP_xo= util _DP_ztest= geom m nvpair umem zpool pthread avl zfs_core spl zutil zfs uutil icp # The libc dependencies are not strictly needed but are defined to make the # assert happy. -_DP_c= compiler_rt +_DP_c= compiler_rt sys # Use libssp_nonshared only on i386 and power*. Other archs emit direct calls # to __stack_chk_fail, not __stack_chk_fail_local provided by libssp_nonshared. .if ${MK_SSP} != "no" && \ @@ -410,6 +410,10 @@ _DP_sys= compiler_rt (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "") _DP_sys+= ssp_nonshared .endif +.if !defined(BOOTSTRAPPING) +_DP_thr= c sys +_DP_pthread= ${_DP_thr} +.endif _DP_tacplus= md pam _DP_ncursesw= tinfow _DP_formw= ncursesw