public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/azanella/clang] string: Use asm alias instead of symbol redirections for stpcpy and mempcpy
Date: Tue,  2 Apr 2024 15:52:56 +0000 (GMT)	[thread overview]
Message-ID: <20240402155256.52346385841B@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=54c56fb6716cf641a6a3d05a0daf017233c255a1

commit 54c56fb6716cf641a6a3d05a0daf017233c255a1
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
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

             reply	other threads:[~2024-04-02 15:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02 15:52 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-17 20:06 Adhemerval Zanella
2024-02-09 17:31 Adhemerval Zanella
2024-02-07 14:06 Adhemerval Zanella
2024-01-29 17:56 Adhemerval Zanella
2023-12-21 18:53 Adhemerval Zanella
2023-09-28 17:51 Adhemerval Zanella
2023-08-30 12:36 Adhemerval Zanella
2023-02-09 19:48 Adhemerval Zanella
2022-10-28 17:41 Adhemerval Zanella
2022-10-04 12:59 Adhemerval Zanella
2022-06-09 21:20 Adhemerval Zanella
2022-06-09 13:17 Adhemerval Zanella
2022-06-03 14:06 Adhemerval Zanella
2022-05-13 14:20 Adhemerval Zanella
2022-05-12 19:34 Adhemerval Zanella
2022-05-10 18:24 Adhemerval Zanella
2022-04-29 14:04 Adhemerval Zanella
2022-04-04 12:54 Adhemerval Zanella
2022-03-31 19:07 Adhemerval Zanella
2022-03-29 20:30 Adhemerval Zanella
2022-03-16 18:04 Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240402155256.52346385841B@sourceware.org \
    --to=azanella@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).