From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org,
Richard Henderson <richard.henderson@linaro.org>,
Noah Goldstein <goldstein.w.n@gmail.com>
Subject: [PATCH 2/3] string: Add libc_hidden_proto for memrchr
Date: Tue, 7 Feb 2023 10:12:54 -0300 [thread overview]
Message-ID: <20230207131255.3396143-3-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20230207131255.3396143-1-adhemerval.zanella@linaro.org>
Although static linker can optimize it to local call, it follow the
internal scheme to provide hidden proto and definitions.
---
include/string.h | 1 +
string/memrchr.c | 1 +
sysdeps/aarch64/memrchr.S | 1 +
sysdeps/i386/i686/multiarch/memrchr-sse2.S | 1 +
sysdeps/i386/i686/multiarch/memrchr.c | 2 ++
.../powerpc32/power4/multiarch/memrchr-ppc32.c | 10 ++++++++++
.../powerpc32/power4/multiarch/memrchr.c | 12 ++++++------
sysdeps/powerpc/powerpc32/power7/memrchr.S | 1 +
sysdeps/powerpc/powerpc64/multiarch/memrchr.c | 18 +++++++++---------
sysdeps/powerpc/powerpc64/power7/memrchr.S | 1 +
sysdeps/powerpc/powerpc64/power8/memrchr.S | 1 +
sysdeps/s390/memrchr-c.c | 4 ++++
sysdeps/s390/memrchr.c | 8 +++++---
sysdeps/x86_64/memrchr.S | 1 +
sysdeps/x86_64/multiarch/memrchr.c | 1 +
15 files changed, 45 insertions(+), 18 deletions(-)
diff --git a/include/string.h b/include/string.h
index 6e364e8a67..a9120ff37c 100644
--- a/include/string.h
+++ b/include/string.h
@@ -119,6 +119,7 @@ extern __typeof (memmem) __memmem;
libc_hidden_proto (__memmem)
libc_hidden_proto (__ffs)
libc_hidden_proto (__strerror_l)
+libc_hidden_proto (__memrchr)
#if IS_IN (libc)
/* Avoid hidden reference to IFUNC symbol __explicit_bzero_chk. */
diff --git a/string/memrchr.c b/string/memrchr.c
index b37f2a68c8..3de5ec691c 100644
--- a/string/memrchr.c
+++ b/string/memrchr.c
@@ -75,5 +75,6 @@ __memrchr (const void *s, int c_in, size_t n)
return NULL;
}
#ifndef MEMRCHR
+libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
#endif
diff --git a/sysdeps/aarch64/memrchr.S b/sysdeps/aarch64/memrchr.S
index 621fc65109..af7d847dab 100644
--- a/sysdeps/aarch64/memrchr.S
+++ b/sysdeps/aarch64/memrchr.S
@@ -123,5 +123,6 @@ L(nomatch):
ret
END (__memrchr)
+libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
libc_hidden_builtin_def (memrchr)
diff --git a/sysdeps/i386/i686/multiarch/memrchr-sse2.S b/sysdeps/i386/i686/multiarch/memrchr-sse2.S
index c2c37f7ce1..aa15e7cf24 100644
--- a/sysdeps/i386/i686/multiarch/memrchr-sse2.S
+++ b/sysdeps/i386/i686/multiarch/memrchr-sse2.S
@@ -720,4 +720,5 @@ L(ret_null):
ret
END (__memrchr_sse2)
+strong_alias (__memrchr_sse2, __GI___memrchr)
#endif
diff --git a/sysdeps/i386/i686/multiarch/memrchr.c b/sysdeps/i386/i686/multiarch/memrchr.c
index c820a9d607..80dca18000 100644
--- a/sysdeps/i386/i686/multiarch/memrchr.c
+++ b/sysdeps/i386/i686/multiarch/memrchr.c
@@ -20,8 +20,10 @@
/* Define multiple versions only for the definition in libc. */
#if IS_IN (libc)
# define memrchr __redirect_memrchr
+# define __memrchr __redirect___memrchr
# include <string.h>
# undef memrchr
+# undef __memrchr
# define SYMBOL_NAME memrchr
# include "ifunc-sse2-bsf.h"
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memrchr-ppc32.c b/sysdeps/powerpc/powerpc32/power4/multiarch/memrchr-ppc32.c
index 62e7a12989..038c5f4532 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/memrchr-ppc32.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/memrchr-ppc32.c
@@ -23,3 +23,13 @@ extern void *__memrchr_ppc (const void *, int, size_t);
#endif
#include <string/memrchr.c>
+# if IS_IN (libc)
+# undef __memrchr
+# ifdef SHARED
+__hidden_ver1 (__memrchr_ppc, __GI___memrchr, __memrchr_ppc);
+strong_alias (__memrchr_ppc, __memrchr_ppc1);
+__hidden_ver1 (__memrchr_ppc1, __memrchr, __memrchr_ppc1);
+# else
+strong_alias (__memrchr_ppc, __memrchr)
+# endif
+#endif
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memrchr.c b/sysdeps/powerpc/powerpc32/power4/multiarch/memrchr.c
index 8c1385fe6a..fb0d2c0617 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/memrchr.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/memrchr.c
@@ -17,21 +17,21 @@
<https://www.gnu.org/licenses/>. */
#if IS_IN (libc)
+# define memrchr __redirect_memrchr
# include <string.h>
# include <shlib-compat.h>
# include "init-arch.h"
extern __typeof (__memrchr) __memrchr_ppc attribute_hidden;
extern __typeof (__memrchr) __memrchr_power7 attribute_hidden;
+# undef memrchr
/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
ifunc symbol properly. */
-libc_ifunc (__memrchr,
- (hwcap & PPC_FEATURE_HAS_VSX)
- ? __memrchr_power7
- : __memrchr_ppc);
-
-weak_alias (__memrchr, memrchr)
+libc_ifunc_redirected (__redirect_memrchr, memrchr,
+ (hwcap & PPC_FEATURE_HAS_VSX)
+ ? __memrchr_power7
+ : __memrchr_ppc);
#else
#include <string/memrchr.c>
#endif
diff --git a/sysdeps/powerpc/powerpc32/power7/memrchr.S b/sysdeps/powerpc/powerpc32/power7/memrchr.S
index 9c70517d37..9f0f17fa46 100644
--- a/sysdeps/powerpc/powerpc32/power7/memrchr.S
+++ b/sysdeps/powerpc/powerpc32/power7/memrchr.S
@@ -191,5 +191,6 @@ L(loop_small):
blr
END (__memrchr)
+libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
libc_hidden_builtin_def (memrchr)
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memrchr.c b/sysdeps/powerpc/powerpc64/multiarch/memrchr.c
index 59527a83eb..5e7c00fdce 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memrchr.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memrchr.c
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#if IS_IN (libc)
+# define memrchr __redirect_memrchr
# include <string.h>
# include <shlib-compat.h>
# include "init-arch.h"
@@ -24,18 +25,17 @@
extern __typeof (__memrchr) __memrchr_ppc attribute_hidden;
extern __typeof (__memrchr) __memrchr_power7 attribute_hidden;
extern __typeof (__memrchr) __memrchr_power8 attribute_hidden;
+# undef memrchr
/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
ifunc symbol properly. */
-libc_ifunc (__memrchr,
- (hwcap2 & PPC_FEATURE2_ARCH_2_07
- && hwcap & PPC_FEATURE_HAS_ALTIVEC)
- ? __memrchr_power8 :
- (hwcap & PPC_FEATURE_ARCH_2_06)
- ? __memrchr_power7
- : __memrchr_ppc);
-
-weak_alias (__memrchr, memrchr)
+libc_ifunc_redirected (__redirect_memrchr, memrchr,
+ (hwcap2 & PPC_FEATURE2_ARCH_2_07
+ && hwcap & PPC_FEATURE_HAS_ALTIVEC)
+ ? __memrchr_power8 :
+ (hwcap & PPC_FEATURE_ARCH_2_06)
+ ? __memrchr_power7
+ : __memrchr_ppc);
#else
#include <string/memrchr.c>
#endif
diff --git a/sysdeps/powerpc/powerpc64/power7/memrchr.S b/sysdeps/powerpc/powerpc64/power7/memrchr.S
index 56e79f3cd5..3b0430ccff 100644
--- a/sysdeps/powerpc/powerpc64/power7/memrchr.S
+++ b/sysdeps/powerpc/powerpc64/power7/memrchr.S
@@ -196,5 +196,6 @@ L(loop_small):
blr
END (MEMRCHR)
+libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
libc_hidden_builtin_def (memrchr)
diff --git a/sysdeps/powerpc/powerpc64/power8/memrchr.S b/sysdeps/powerpc/powerpc64/power8/memrchr.S
index fec76cf586..ebe4017968 100644
--- a/sysdeps/powerpc/powerpc64/power8/memrchr.S
+++ b/sysdeps/powerpc/powerpc64/power8/memrchr.S
@@ -332,5 +332,6 @@ L(loop_small):
blr
END (MEMRCHR)
+libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
libc_hidden_builtin_def (memrchr)
diff --git a/sysdeps/s390/memrchr-c.c b/sysdeps/s390/memrchr-c.c
index ce97bc6714..bdf3c7bbe0 100644
--- a/sysdeps/s390/memrchr-c.c
+++ b/sysdeps/s390/memrchr-c.c
@@ -24,4 +24,8 @@
# endif
# include <string/memrchr.c>
+
+# if defined SHARED && IS_IN (libc)
+__hidden_ver1 (__memrchr_c, __GI___memrchr, __memrchr_c);
+# endif
#endif
diff --git a/sysdeps/s390/memrchr.c b/sysdeps/s390/memrchr.c
index 73e75628c1..405990faef 100644
--- a/sysdeps/s390/memrchr.c
+++ b/sysdeps/s390/memrchr.c
@@ -19,18 +19,20 @@
#include <ifunc-memrchr.h>
#if HAVE_MEMRCHR_IFUNC
+# define __memrchr __redirect_memrchr
# include <string.h>
+# undef __memrchr
# include <ifunc-resolve.h>
# if HAVE_MEMRCHR_C
-extern __typeof (__memrchr) MEMRCHR_C attribute_hidden;
+extern __typeof (__redirect_memrchr) MEMRCHR_C attribute_hidden;
# endif
# if HAVE_MEMRCHR_Z13
-extern __typeof (__memrchr) MEMRCHR_Z13 attribute_hidden;
+extern __typeof (__redirect_memrchr) MEMRCHR_Z13 attribute_hidden;
# endif
-s390_libc_ifunc_expr (__memrchr, __memrchr,
+s390_libc_ifunc_expr (__redirect_memrchr, __memrchr,
(HAVE_MEMRCHR_Z13 && (hwcap & HWCAP_S390_VX))
? MEMRCHR_Z13
: MEMRCHR_DEFAULT
diff --git a/sysdeps/x86_64/memrchr.S b/sysdeps/x86_64/memrchr.S
index fe33998111..98a220f3f4 100644
--- a/sysdeps/x86_64/memrchr.S
+++ b/sysdeps/x86_64/memrchr.S
@@ -25,4 +25,5 @@
#include "isa-default-impl.h"
+libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
diff --git a/sysdeps/x86_64/multiarch/memrchr.c b/sysdeps/x86_64/multiarch/memrchr.c
index f7db8b4708..49026538d4 100644
--- a/sysdeps/x86_64/multiarch/memrchr.c
+++ b/sysdeps/x86_64/multiarch/memrchr.c
@@ -27,5 +27,6 @@
# include "ifunc-avx2.h"
libc_ifunc_redirected (__redirect_memrchr, __memrchr, IFUNC_SELECTOR ());
+libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
#endif
--
2.34.1
next prev parent reply other threads:[~2023-02-07 13:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 13:12 [PATCH 0/3] Minor fixes from generic string routines Adhemerval Zanella
2023-02-07 13:12 ` [PATCH 1/3] string: Add libc_hidden_proto for strchrnul Adhemerval Zanella
2023-02-08 17:14 ` Carlos Seo
2023-02-08 19:52 ` Carlos Seo
2023-02-07 13:12 ` Adhemerval Zanella [this message]
2023-02-08 17:15 ` [PATCH 2/3] string: Add libc_hidden_proto for memrchr Carlos Seo
2023-02-08 19:52 ` Carlos Seo
2023-02-07 13:12 ` [PATCH 3/3] string: Disable stack protector in early static initialization Adhemerval Zanella
2023-02-08 17:27 ` Carlos Seo
2023-02-08 19:53 ` Carlos Seo
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=20230207131255.3396143-3-adhemerval.zanella@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=goldstein.w.n@gmail.com \
--cc=libc-alpha@sourceware.org \
--cc=richard.henderson@linaro.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).