Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 May 2025 23:48:27 GMT
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 387783da979e - main - rtld: get syscall implementations from libsys
Message-ID:  <202505232348.54NNmRG3046778@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=387783da979eb5862f8453e15505c240cbfe28ce

commit 387783da979eb5862f8453e15505c240cbfe28ce
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-05-23 23:33:51 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2025-05-23 23:37:17 +0000

    rtld: get syscall implementations from libsys
    
    When I added libsys I failed to update rtld's reuse of object files
    from libc to use ones from libsys instead.  This would have turned up
    as a broken system in d7847a8d35143, but SHARED_CFLAGS is not being
    applied to assembly files.
    
    PR:             286975
    Reviewed by:    jrtc27, jhb
    Sponsored by:   DARPA, AFRL
    Differential Revision:  https://reviews.freebsd.org/D50475
---
 libexec/rtld-elf/rtld-libc/Makefile.inc | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/libexec/rtld-elf/rtld-libc/Makefile.inc b/libexec/rtld-elf/rtld-libc/Makefile.inc
index 79d68a1e803c..b16f84f398d0 100644
--- a/libexec/rtld-elf/rtld-libc/Makefile.inc
+++ b/libexec/rtld-elf/rtld-libc/Makefile.inc
@@ -52,22 +52,23 @@ CFLAGS.strspn.c+=-Wno-sign-compare
 CFLAGS.strstr.c+=-Wno-cast-qual -Wno-sign-compare
 CFLAGS.strtok.c+=-Wno-cast-qual
 
-# Also use all the syscall .o files from libc_nossp_pic:
-_libc_other_objects= sigsetjmp lstat stat fstat fstatat fstatfs syscall \
+# Also use all the syscall .o files from libsys_pic (libsys is always NO_SSP):
+_libsys_other_objects= fstat fstatat fstatfs syscall \
     cerror geteuid getegid sigfastblock munmap mprotect \
     sysarch __sysctl issetugid __getcwd utrace getpid \
     thr_self thr_kill pread mmap lseek _exit \
     getdirentries _close _fcntl _open _openat _read \
-    _sigprocmask _write readlink ___realpathat _setjmp setjmp setjmperr
+    _sigprocmask _write readlink ___realpathat
+# A few other bits from libc_nossp_pic:
+_libc_other_objects= sigsetjmp lstat stat _setjmp setjmp setjmperr
 
-
-# Finally add additional architecture-dependent libc dependencies
+# Finally add additional architecture-dependent libc and libsys dependencies
 .if ${LIBC_ARCH} == "arm"
 # ARM needs aeabi_unwind_cpp for _setjmp
 _libc_other_objects+=aeabi_unwind_cpp
 .elif ${LIBC_ARCH} == "i386"
 # i386 needs i386_set_gsbase for allocate_initial_tls()
-_libc_other_objects+=i386_set_gsbase
+_libsys_other_objects+=i386_set_gsbase
 .elif ${LIBC_ARCH} == "powerpc" || ${LIBC_ARCH} == "powerpcspe"
 # ppc needs __syncicache and abs for reloc.c
 _libc_other_objects+=syncicache abs
@@ -76,23 +77,30 @@ _libc_other_objects+=syncicache abs
 _libc_other_objects+=syncicache
 .endif
 
-# Extract all the .o files from libc_nossp_pic.a. This ensures that
-# we don't accidentally pull in the interposing table or similar by linking
-# directly against libc_nossp_pic.a
+# Extract all the .o files from libc_nossp_pic.a and libsys_pic.a. This
+# ensures that we don't accidentally pull in the interposing table or
+# similar by linking directly against libc_nossp_pic.a
 _rtld_libc_objs=
 .for _obj in ${_libc_other_objects}
 _rtld_libc_objs+=${_obj}.nossppico
 CLEANFILES+=${_obj}.nossppico
 # LDFLAGS+=	-Wl,--trace-symbol=${_obj}
 .endfor
+_rtld_libsys_objs=
+.for _obj in ${_libsys_other_objects}
+_rtld_libsys_objs+=${_obj}.pico
+CLEANFILES+=${_obj}.pico
+# LDFLAGS+=	-Wl,--trace-symbol=${_obj}
+.endfor
 # LDFLAGS+=	-Wl,--trace
 
 # We insert all the .o files from libc_nossp_pic.a into a new rtld_libc.a file
 # to ensure that only .o files that are actually used end up being included.
-rtld_libc.a: ${LIBC_NOSSP_PIC} ${SRCTOP}/libexec/rtld-elf/rtld-libc/Makefile.inc
+rtld_libc.a: ${LIBC_NOSSP_PIC} ${LIBSYS_PIC} ${SRCTOP}/libexec/rtld-elf/rtld-libc/Makefile.inc
 	@rm -f ${.TARGET}
 	${AR} x ${LIBC_NOSSP_PIC} ${_rtld_libc_objs}
-	${AR} cr ${.TARGET} ${_rtld_libc_objs}
+	${AR} x ${LIBSYS_PIC} ${_rtld_libsys_objs}
+	${AR} cr ${.TARGET} ${_rtld_libc_objs} ${_rtld_libsys_objs}
 CLEANFILES+=rtld_libc.a
 LDADD+=${.OBJDIR}/rtld_libc.a
 beforelinking: rtld_libc.a



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505232348.54NNmRG3046778>