git: 99ea67573164 - main - lib{c,sys}: move auxargs more firmly into libsys
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 19 Feb 2024 22:44:35 UTC
The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=99ea67573164637d633e8051eb0a5d52f1f9488e commit 99ea67573164637d633e8051eb0a5d52f1f9488e Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2024-02-19 22:44:08 +0000 Commit: Brooks Davis <brooks@FreeBSD.org> 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 <src.opts.mk> 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