From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id C469E385828E; Wed, 7 Feb 2024 14:06:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C469E385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707314787; bh=2RxPn5yDqKDOqiSAVIZfqRg+Cyj37PuPzl5SM3N5/nw=; h=From:To:Subject:Date:From; b=FbVM77un1tZNfoq2rrPGzB6RsPp1e9cthNtQRJo9c6JQCNVG5b0BuGSckhv6jh5rU u07TIyPmX7AlbH/Qoog+CPquS1aUXf2WkXI5IP9q+nnvngRmsOj7XKYxO0yqGZ3a6/ haxehDYtJwHeeHPvC/e5i7ExKv/2IakClP+Jjv7c= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] string: Use asm alias instead of symbol redirections for stpcpy and mempcpy X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: 2b3f273490f35a5984dae212ad25f0d5d4884393 X-Git-Newrev: 72170b200a13688e37d3d14c648e3ce70d5ba8b8 Message-Id: <20240207140627.C469E385828E@sourceware.org> Date: Wed, 7 Feb 2024 14:06:27 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=72170b200a13688e37d3d14c648e3ce70d5ba8b8 commit 72170b200a13688e37d3d14c648e3ce70d5ba8b8 Author: Adhemerval Zanella Date: Tue Mar 15 08:41:43 2022 -0300 string: Use asm alias instead of symbol redirections for stpcpy and mempcpy Commit 939da411433 added symbols redirections to handle ISO C namespace, however some compiler does not support to redeclare the function prototype. Moving these defintions to exported header it not a good practice (it exposes a internal implementation and it would require to add macros to define it only internally). Instead this patch replaces the symbol redirections by direct asm aliases, as done to handle libcall generation done by compiler on some loop optimizations. The only issue is sparc binutils generates an extra __mempcpy plt not called anywhere in the code, which indicates a binutils issue (this is added in the localplt.data for now). Checked on all affected ABIs. Diff: --- include/string.h | 4 ++-- sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data | 3 +++ sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/string.h b/include/string.h index 3b4c6007d7..082865caad 100644 --- a/include/string.h +++ b/include/string.h @@ -179,8 +179,8 @@ extern __typeof (strsep) strsep attribute_hidden; && !defined NO_MEMPCPY_STPCPY_REDIRECT /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call __mempcpy and __stpcpy if not inlined. */ -extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy"); -extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy"); +__asm__ ("mempcpy = __mempcpy"); +__asm__ ("stpcpy = __stpcpy"); #endif extern void *__memcpy_chk (void *__restrict __dest, diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data b/sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data index b5fc6d9c3a..327276d9c2 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data @@ -17,4 +17,7 @@ libc.so: calloc libc.so: free libc.so: malloc libc.so: realloc +# Unreferenced PLT created by the symbols aliases used to redirect +# the compiler generated mempcpy/stpcyp calls done by builtin usage. +libc.so: __mempcpy libm.so: matherr diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data b/sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data index 15c0f8ccf7..e7ab61dcbe 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data @@ -17,4 +17,7 @@ libc.so: calloc libc.so: free libc.so: malloc libc.so: realloc +# Unreferenced PLT created by the symbols aliases used to redirect +# the compiler generated mempcpy/stpcyp calls done by builtin usage. +libc.so: __mempcpy libm.so: matherr