public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86: Make strncmp usable from rtld
@ 2018-06-12 12:47 Florian Weimer
  2018-06-12 12:59 ` Carlos O'Donell
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2018-06-12 12:47 UTC (permalink / raw)
  To: libc-alpha

Due to the way the conditions were written, the rtld build of strncmp
ended up with no definition of the strncmp symbol at all: The
implementations were renamed for use within an IFUNC resolver, but the
IFUNC resolver itself was missing (because rtld does not use IFUNCs).

2018-06-12  Florian Weimer  <fweimer@redhat.com>

	x86: Make strncmp usable from rtld.
	* sysdeps/i386/i686/multiarch/strncmp-c.c: Only rename strncmp to
	__strncmp_ia32 if in libc (and not in rtld).
	* sysdeps/x86_64/multiarch/strncmp-sse2.S: Rename strcmp to
	strncmp if not in libc (and not to __strncmp_sse2).

diff --git a/sysdeps/i386/i686/multiarch/strncmp-c.c b/sysdeps/i386/i686/multiarch/strncmp-c.c
index cc059da494..2e3eca9b2b 100644
--- a/sysdeps/i386/i686/multiarch/strncmp-c.c
+++ b/sysdeps/i386/i686/multiarch/strncmp-c.c
@@ -1,4 +1,4 @@
-#ifdef SHARED
+#if defined (SHARED) && IS_IN (libc)
 # define STRNCMP __strncmp_ia32
 # undef libc_hidden_builtin_def
 # define libc_hidden_builtin_def(name)  \
diff --git a/sysdeps/x86_64/multiarch/strncmp-sse2.S b/sysdeps/x86_64/multiarch/strncmp-sse2.S
index cc5252d826..a5ecb82b13 100644
--- a/sysdeps/x86_64/multiarch/strncmp-sse2.S
+++ b/sysdeps/x86_64/multiarch/strncmp-sse2.S
@@ -18,10 +18,13 @@
 
 #include <sysdep.h>
 
-#define STRCMP	__strncmp_sse2
-
-#undef libc_hidden_builtin_def
-#define libc_hidden_builtin_def(strcmp)
+#if IS_IN (libc)
+# define STRCMP __strncmp_sse2
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(strcmp)
+#else
+# define STRCMP strncmp
+#endif
 
 #define USE_AS_STRNCMP
 #include <sysdeps/x86_64/strcmp.S>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86: Make strncmp usable from rtld
  2018-06-12 12:47 [PATCH] x86: Make strncmp usable from rtld Florian Weimer
@ 2018-06-12 12:59 ` Carlos O'Donell
  0 siblings, 0 replies; 2+ messages in thread
From: Carlos O'Donell @ 2018-06-12 12:59 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

On 06/12/2018 08:46 AM, Florian Weimer wrote:
> Due to the way the conditions were written, the rtld build of strncmp
> ended up with no definition of the strncmp symbol at all: The
> implementations were renamed for use within an IFUNC resolver, but the
> IFUNC resolver itself was missing (because rtld does not use IFUNCs).
> 
> 2018-06-12  Florian Weimer  <fweimer@redhat.com>
> 
> 	x86: Make strncmp usable from rtld.
> 	* sysdeps/i386/i686/multiarch/strncmp-c.c: Only rename strncmp to
> 	__strncmp_ia32 if in libc (and not in rtld).
> 	* sysdeps/x86_64/multiarch/strncmp-sse2.S: Rename strcmp to
> 	strncmp if not in libc (and not to __strncmp_sse2).

This looks good to me.

I tested this on x86_64 and tested by adding code which calls strncmp from
early load.

It allows me to use strncmp in early dl-load.o* to simplify the logic
in is_dst().

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> diff --git a/sysdeps/i386/i686/multiarch/strncmp-c.c b/sysdeps/i386/i686/multiarch/strncmp-c.c
> index cc059da494..2e3eca9b2b 100644
> --- a/sysdeps/i386/i686/multiarch/strncmp-c.c
> +++ b/sysdeps/i386/i686/multiarch/strncmp-c.c
> @@ -1,4 +1,4 @@
> -#ifdef SHARED
> +#if defined (SHARED) && IS_IN (libc)
>  # define STRNCMP __strncmp_ia32
>  # undef libc_hidden_builtin_def
>  # define libc_hidden_builtin_def(name)  \
> diff --git a/sysdeps/x86_64/multiarch/strncmp-sse2.S b/sysdeps/x86_64/multiarch/strncmp-sse2.S
> index cc5252d826..a5ecb82b13 100644
> --- a/sysdeps/x86_64/multiarch/strncmp-sse2.S
> +++ b/sysdeps/x86_64/multiarch/strncmp-sse2.S
> @@ -18,10 +18,13 @@
>  
>  #include <sysdep.h>
>  
> -#define STRCMP	__strncmp_sse2
> -
> -#undef libc_hidden_builtin_def
> -#define libc_hidden_builtin_def(strcmp)
> +#if IS_IN (libc)
> +# define STRCMP __strncmp_sse2
> +# undef libc_hidden_builtin_def
> +# define libc_hidden_builtin_def(strcmp)
> +#else
> +# define STRCMP strncmp
> +#endif
>  
>  #define USE_AS_STRNCMP
>  #include <sysdeps/x86_64/strcmp.S>
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-12 12:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 12:47 [PATCH] x86: Make strncmp usable from rtld Florian Weimer
2018-06-12 12:59 ` Carlos O'Donell

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).