Patchwork x86-64: Use IFUNC strncat inside libc.so

login
register
mail settings
Submitter H.J. Lu
Date May 16, 2018, 12:18 p.m.
Message ID <20180516121856.GA12678@gmail.com>
Download mbox | patch
Permalink /patch/27281/
State New
Headers show

Comments

H.J. Lu - May 16, 2018, 12:18 p.m.
Unlike i386, we can call hidden IFUNC functions inside libc.so since
x86-64 PLT is always PIC.

Tested on x86-64.

Any comments?


H.J.
---
	* sysdeps/x86_64/multiarch/strncat-c.c (STRNCAT_PRIMARY): Removed.
	Include <string/strncat.c>.
	* sysdeps/x86_64/multiarch/strncat.c (__strncat): New strong
	alias.
	(__GI___strncat): New hidden alias.
---
 sysdeps/x86_64/multiarch/strncat-c.c | 3 +--
 sysdeps/x86_64/multiarch/strncat.c   | 5 +++++
 2 files changed, 6 insertions(+), 2 deletions(-)
Adhemerval Zanella Netto - May 16, 2018, 2:08 p.m.
On 16/05/2018 09:18, H.J. Lu wrote:
> Unlike i386, we can call hidden IFUNC functions inside libc.so since
> x86-64 PLT is always PIC.
> 
> Tested on x86-64.
> 
> Any comments?
> 

LGTM.

> 
> H.J.
> ---
> 	* sysdeps/x86_64/multiarch/strncat-c.c (STRNCAT_PRIMARY): Removed.
> 	Include <string/strncat.c>.
> 	* sysdeps/x86_64/multiarch/strncat.c (__strncat): New strong
> 	alias.
> 	(__GI___strncat): New hidden alias.
> ---
>  sysdeps/x86_64/multiarch/strncat-c.c | 3 +--
>  sysdeps/x86_64/multiarch/strncat.c   | 5 +++++
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/sysdeps/x86_64/multiarch/strncat-c.c b/sysdeps/x86_64/multiarch/strncat-c.c
> index db8ad9917c..93a7fab7ea 100644
> --- a/sysdeps/x86_64/multiarch/strncat-c.c
> +++ b/sysdeps/x86_64/multiarch/strncat-c.c
> @@ -1,3 +1,2 @@
>  #define STRNCAT __strncat_sse2
> -#define STRNCAT_PRIMARY
> -#include "string/strncat.c"
> +#include <string/strncat.c>
> diff --git a/sysdeps/x86_64/multiarch/strncat.c b/sysdeps/x86_64/multiarch/strncat.c
> index 1267eb4972..841c165565 100644
> --- a/sysdeps/x86_64/multiarch/strncat.c
> +++ b/sysdeps/x86_64/multiarch/strncat.c
> @@ -27,4 +27,9 @@
>  # include "ifunc-unaligned-ssse3.h"
>  
>  libc_ifunc_redirected (__redirect_strncat, strncat, IFUNC_SELECTOR ());
> +strong_alias (strncat, __strncat);
> +# ifdef SHARED
> +__hidden_ver1 (strncat, __GI___strncat, __redirect_strncat)
> +  __attribute__((visibility ("hidden")));
> +# endif
>  #endif
>

Patch

diff --git a/sysdeps/x86_64/multiarch/strncat-c.c b/sysdeps/x86_64/multiarch/strncat-c.c
index db8ad9917c..93a7fab7ea 100644
--- a/sysdeps/x86_64/multiarch/strncat-c.c
+++ b/sysdeps/x86_64/multiarch/strncat-c.c
@@ -1,3 +1,2 @@ 
 #define STRNCAT __strncat_sse2
-#define STRNCAT_PRIMARY
-#include "string/strncat.c"
+#include <string/strncat.c>
diff --git a/sysdeps/x86_64/multiarch/strncat.c b/sysdeps/x86_64/multiarch/strncat.c
index 1267eb4972..841c165565 100644
--- a/sysdeps/x86_64/multiarch/strncat.c
+++ b/sysdeps/x86_64/multiarch/strncat.c
@@ -27,4 +27,9 @@ 
 # include "ifunc-unaligned-ssse3.h"
 
 libc_ifunc_redirected (__redirect_strncat, strncat, IFUNC_SELECTOR ());
+strong_alias (strncat, __strncat);
+# ifdef SHARED
+__hidden_ver1 (strncat, __GI___strncat, __redirect_strncat)
+  __attribute__((visibility ("hidden")));
+# endif
 #endif