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: Mon,  4 Apr 2022 12:54:58 +0000 (GMT)	[thread overview]
Message-ID: <20220404125458.D3F0F3858025@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=07c0ba705d7b5cb0bead046c6ecaecca94b3aae9

commit 07c0ba705d7b5cb0bead046c6ecaecca94b3aae9
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 most of affected ABIs.

Diff:
---
 include/string.h                                    | 4 ++--
 sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/string.h b/include/string.h
index 21f641a413..44c4049053 100644
--- a/include/string.h
+++ b/include/string.h
@@ -176,8 +176,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/sparc64/localplt.data b/sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data
index 6a216f3a5a..21a5fe65ba 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data
@@ -16,6 +16,9 @@ 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
 # The TLS-enabled version of these functions is interposed from libc.so.
 ld.so: _dl_signal_error


             reply	other threads:[~2022-04-04 12:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 12:54 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-17 20:06 Adhemerval Zanella
2024-04-02 15:52 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-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=20220404125458.D3F0F3858025@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).