Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Jul 2023 15:42:44 GMT
From:      Robert Clausecker <fuz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: c1e63e352e34 - main - libexec/rtld-elf/rtld-libc/Makefile.inc: do not use machdep string functions
Message-ID:  <202307161542.36GFgiFE096190@gitrepo.freebsd.org>

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

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

commit c1e63e352e34b55ad577011fa4729f0638fb3fdf
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-06-28 17:18:15 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-07-16 15:41:55 +0000

    libexec/rtld-elf/rtld-libc/Makefile.inc: do not use machdep string functions
    
    With ifunc based SIMD dispatch, we cannot use the amd64 assembly
    implementations of string functions.  Modify rtld to instead use
    the generic functions.  To avoid an architecture-specific special
    case, this change is applied to all architectures.
    
    This change is a prerequisite to and formerly part of D40693.
    
    Sponsored by:   FreeBSD Foundation
    Approved by:    kib
    See also:       D40693
    Differential Revision: https://reviews.freebsd.org/D41050
---
 libexec/rtld-elf/rtld-libc/Makefile.inc | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/libexec/rtld-elf/rtld-libc/Makefile.inc b/libexec/rtld-elf/rtld-libc/Makefile.inc
index 99da16d06509..5033b2207e32 100644
--- a/libexec/rtld-elf/rtld-libc/Makefile.inc
+++ b/libexec/rtld-elf/rtld-libc/Makefile.inc
@@ -38,11 +38,21 @@ SRCS+=	errlst.c getcwd.c getprogname.c raise.c sigsetops.c sysctlnametomib.c \
 # errlst.c needs the errlst.h header from libc:
 CFLAGS.errlst.c+=-I${LIBC_SRCTOP}/include
 
-# Use the string and memory .o files from libc instead of rebuilding them (they
-# might be using optimized assembly and duplicating that logic here is awkward).
-_libc_string_objects=	bcmp bcopy bzero memset memchr memcmp memcpy memmove \
-    stpncpy strcat strchr strchrnul strcmp stpcpy strcpy strcspn strdup \
-    strlcat strlcpy strlen strncmp strncpy strrchr strsep strspn strstr strtok
+# use generic versions of string functions to avoid potential ifunc dispatch
+.PATH: ${LIBC_SRCTOP}/string
+SRCS+=	bcopy.c bzero.c memchr.c memcmp.c memcpy.c memmove.c memset.c strcat.c \
+    strchr.c strchrnul.c strcmp.c strcpy.c strcspn.c strdup.c strlcat.c \
+    strlcpy.c strlen.c strncmp.c strncpy.c strrchr.c strsep.c strspn.c \
+    strstr.c strtok.c
+CFLAGS.memchr.c+=-Wno-cast-qual
+CFLAGS.strchr.c+=-Wno-cast-qual
+CFLAGS.strchrnul.c+=-Wno-cast-qual
+CFLAGS.strcspn.c+=-Wno-sign-compare
+CFLAGS.strrchr.c+=-Wno-cast-qual
+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 \
     cerror geteuid getegid sigfastblock munmap mprotect \
@@ -71,7 +81,7 @@ _libc_other_objects+=syncicache
 # 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} ${_libc_string_objects}
+.for _obj in ${_libc_other_objects}
 _rtld_libc_objs+=${_obj}.nossppico
 CLEANFILES+=${_obj}.nossppico
 # LDFLAGS+=	-Wl,--trace-symbol=${_obj}



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