Message ID | 20240521143733.3285523-1-hjl.tools@gmail.com |
---|---|
State | New |
Headers | show |
Series | aarch64: Don't define memchr/strlen when used in IFUNC [BZ #31777] | expand |
On 21/05/24 11:37, H.J. Lu wrote: > Fix BZ #31777 by not defining memchr/strlen aliases when used in IFUNC. > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com> > --- > sysdeps/aarch64/memchr.S | 3 +++ > sysdeps/aarch64/strlen.S | 3 +++ > 2 files changed, 6 insertions(+) > > diff --git a/sysdeps/aarch64/memchr.S b/sysdeps/aarch64/memchr.S > index a9fa40519c..6aa93a344b 100644 > --- a/sysdeps/aarch64/memchr.S > +++ b/sysdeps/aarch64/memchr.S > @@ -28,6 +28,7 @@ > > #ifndef MEMCHR > # define MEMCHR __memchr > +# define NEED_memchr > #endif > > #define srcin x0 > @@ -124,5 +125,7 @@ L(nomatch): > ret > > END (MEMCHR) > +#ifdef NEED_memchr > weak_alias (MEMCHR, memchr) > +#endif > libc_hidden_builtin_def (memchr) The aarch64 memchr_generic.S already redefine libc_hidden_builtin_def to avoid a similar issue, so I think it would be better to fix it on the same place (and it is similar to how other ports do): diff --git a/sysdeps/aarch64/multiarch/memchr_generic.S b/sysdeps/aarch64/multiarch/memchr_generic.S index 0ed5811745..8d554275ba 100644 --- a/sysdeps/aarch64/multiarch/memchr_generic.S +++ b/sysdeps/aarch64/multiarch/memchr_generic.S @@ -24,6 +24,9 @@ # undef libc_hidden_builtin_def # define libc_hidden_builtin_def(name) +# undef weak_alias +# define weak_alias(a, b) + /* Add a hidden definition for use within libc.so. */ # ifdef SHARED .globl __GI_memchr; __GI_memchr = __memchr_generic > diff --git a/sysdeps/aarch64/strlen.S b/sysdeps/aarch64/strlen.S > index ab2a576cdb..ef8db695e6 100644 > --- a/sysdeps/aarch64/strlen.S > +++ b/sysdeps/aarch64/strlen.S > @@ -26,6 +26,7 @@ > > #ifndef STRLEN > # define STRLEN __strlen > +# define NEED_strlen > #endif > > #define srcin x0 > @@ -89,5 +90,7 @@ L(loop_end): > ret > > END (STRLEN) > +#ifdef NEED_strlen > weak_alias (STRLEN, strlen) > +#endif > libc_hidden_builtin_def (strlen)
On Tue, May 21, 2024 at 10:23 AM Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> wrote: > > > > On 21/05/24 11:37, H.J. Lu wrote: > > Fix BZ #31777 by not defining memchr/strlen aliases when used in IFUNC. > > > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com> > > --- > > sysdeps/aarch64/memchr.S | 3 +++ > > sysdeps/aarch64/strlen.S | 3 +++ > > 2 files changed, 6 insertions(+) > > > > diff --git a/sysdeps/aarch64/memchr.S b/sysdeps/aarch64/memchr.S > > index a9fa40519c..6aa93a344b 100644 > > --- a/sysdeps/aarch64/memchr.S > > +++ b/sysdeps/aarch64/memchr.S > > @@ -28,6 +28,7 @@ > > > > #ifndef MEMCHR > > # define MEMCHR __memchr > > +# define NEED_memchr > > #endif > > > > #define srcin x0 > > @@ -124,5 +125,7 @@ L(nomatch): > > ret > > > > END (MEMCHR) > > +#ifdef NEED_memchr > > weak_alias (MEMCHR, memchr) > > +#endif > > libc_hidden_builtin_def (memchr) > > The aarch64 memchr_generic.S already redefine libc_hidden_builtin_def to > avoid a similar issue, so I think it would be better to fix it on the > same place (and it is similar to how other ports do): I am dropping my patch. > diff --git a/sysdeps/aarch64/multiarch/memchr_generic.S b/sysdeps/aarch64/multiarch/memchr_generic.S > index 0ed5811745..8d554275ba 100644 > --- a/sysdeps/aarch64/multiarch/memchr_generic.S > +++ b/sysdeps/aarch64/multiarch/memchr_generic.S > @@ -24,6 +24,9 @@ > # undef libc_hidden_builtin_def > # define libc_hidden_builtin_def(name) > > +# undef weak_alias > +# define weak_alias(a, b) > + > /* Add a hidden definition for use within libc.so. */ > # ifdef SHARED > .globl __GI_memchr; __GI_memchr = __memchr_generic > > > diff --git a/sysdeps/aarch64/strlen.S b/sysdeps/aarch64/strlen.S > > index ab2a576cdb..ef8db695e6 100644 > > --- a/sysdeps/aarch64/strlen.S > > +++ b/sysdeps/aarch64/strlen.S > > @@ -26,6 +26,7 @@ > > > > #ifndef STRLEN > > # define STRLEN __strlen > > +# define NEED_strlen > > #endif > > > > #define srcin x0 > > @@ -89,5 +90,7 @@ L(loop_end): > > ret > > > > END (STRLEN) > > +#ifdef NEED_strlen > > weak_alias (STRLEN, strlen) > > +#endif > > libc_hidden_builtin_def (strlen)
diff --git a/sysdeps/aarch64/memchr.S b/sysdeps/aarch64/memchr.S index a9fa40519c..6aa93a344b 100644 --- a/sysdeps/aarch64/memchr.S +++ b/sysdeps/aarch64/memchr.S @@ -28,6 +28,7 @@ #ifndef MEMCHR # define MEMCHR __memchr +# define NEED_memchr #endif #define srcin x0 @@ -124,5 +125,7 @@ L(nomatch): ret END (MEMCHR) +#ifdef NEED_memchr weak_alias (MEMCHR, memchr) +#endif libc_hidden_builtin_def (memchr) diff --git a/sysdeps/aarch64/strlen.S b/sysdeps/aarch64/strlen.S index ab2a576cdb..ef8db695e6 100644 --- a/sysdeps/aarch64/strlen.S +++ b/sysdeps/aarch64/strlen.S @@ -26,6 +26,7 @@ #ifndef STRLEN # define STRLEN __strlen +# define NEED_strlen #endif #define srcin x0 @@ -89,5 +90,7 @@ L(loop_end): ret END (STRLEN) +#ifdef NEED_strlen weak_alias (STRLEN, strlen) +#endif libc_hidden_builtin_def (strlen)
Fix BZ #31777 by not defining memchr/strlen aliases when used in IFUNC. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> --- sysdeps/aarch64/memchr.S | 3 +++ sysdeps/aarch64/strlen.S | 3 +++ 2 files changed, 6 insertions(+)