PATCH: Remove __GI_* from libc.a

H.J. Lu hjl.tools@gmail.com
Fri Aug 28 20:59:00 GMT 2009


On Tue, Aug 25, 2009 at 1:15 PM, Ulrich Drepper<drepper@redhat.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> H.J. Lu wrote:
>> In libc.a, before __libc_csu_init, we can't call any IFUNC functions.
>> This patch adds <direct-symbols.h> and include it in files where IFUNC
>> functions are called before __libc_csu_init. The __GI__ version of those
>> functions will be called instead.
>
> This adds lots of ugly code and sources for possible problems.  And for
> what?  For static linking which shouldn't be used in the first place.  I
> reluctantly accepted adding any IFUNC support for static linking so that
> 3rd party code can use it.  But inside libc I really don't want it.  The
> code is complex enough.
>

That is fine with me. Here is a follow-up patch to remove __GI_* from
libc.a.

Thanks.

-- 
H.J.
---
2009-08-28  H.J. Lu  <hongjiu.lu@intel.com>

	* sysdeps/i386/i686/strtok_r.S (__GI___strtok_r): Define only if
	SHARED is defined.
	* sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c (__GI___fxstatat64):
	Likewise.
	* sysdeps/x86_64/strtok_r.S (__GI___strtok_r): Likewise.

	* sysdeps/i386/i686/multiarch/strcspn.S (libc_hidden_builtin_def):
	Redefine only if SHARED is defined.
	* sysdeps/i386/i686/multiarch/strspn.S (libc_hidden_builtin_def):
	Likewise.
	* sysdeps/x86_64/multiarch/rawmemchr.S (libc_hidden_builtin_def):
	Likewise.
	* sysdeps/x86_64/multiarch/strcmp.S (libc_hidden_builtin_def):
	Likewise.
	* sysdeps/x86_64/multiarch/strcpy.S (libc_hidden_builtin_def):
	Likewise.
	(libc_hidden_def): Likewise.
	* sysdeps/x86_64/multiarch/strcspn.S (libc_hidden_builtin_def):
	Likewise.
	* sysdeps/x86_64/multiarch/strspn.S (libc_hidden_builtin_def):
	Likewise.

	* sysdeps/unix/Makefile (stub-syscalls.c): Define __GI_$$call
	only if SHARED is defined.
-------------- next part --------------
2009-08-28  H.J. Lu  <hongjiu.lu@intel.com>

	* sysdeps/i386/i686/strtok_r.S (__GI___strtok_r): Define only if
	SHARED is defined.
	* sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c (__GI___fxstatat64):
	Likewise.
	* sysdeps/x86_64/strtok_r.S (__GI___strtok_r): Likewise.

	* sysdeps/i386/i686/multiarch/strcspn.S (libc_hidden_builtin_def):
	Redefine only if SHARED is defined.
	* sysdeps/i386/i686/multiarch/strspn.S (libc_hidden_builtin_def):
	Likewise.
	* sysdeps/x86_64/multiarch/rawmemchr.S (libc_hidden_builtin_def):
	Likewise.
	* sysdeps/x86_64/multiarch/strcmp.S (libc_hidden_builtin_def):
	Likewise.
	* sysdeps/x86_64/multiarch/strcpy.S (libc_hidden_builtin_def):
	Likewise.
	(libc_hidden_def): Likewise.
	* sysdeps/x86_64/multiarch/strcspn.S (libc_hidden_builtin_def):
	Likewise.
	* sysdeps/x86_64/multiarch/strspn.S (libc_hidden_builtin_def):
	Likewise.

	* sysdeps/unix/Makefile (stub-syscalls.c): Define __GI_$$call
	only if SHARED is defined.

diff --git a/sysdeps/i386/i686/multiarch/strcspn.S b/sysdeps/i386/i686/multiarch/strcspn.S
index 73e7eb4..71f3091 100644
--- a/sysdeps/i386/i686/multiarch/strcspn.S
+++ b/sysdeps/i386/i686/multiarch/strcspn.S
@@ -97,12 +97,15 @@ END(STRCSPN)
 # undef END
 # define END(name) \
 	cfi_endproc; .size STRCSPN_IA32, .-STRCSPN_IA32
-# undef libc_hidden_builtin_def
+
+# ifdef SHARED
+#  undef libc_hidden_builtin_def
 /* IFUNC doesn't work with the hidden functions in shared library since
    they will be called without setting up EBX needed for PLT which is
    used by IFUNC.  */
-# define libc_hidden_builtin_def(name) \
+#  define libc_hidden_builtin_def(name) \
 	.globl __GI_STRCSPN; __GI_STRCSPN = STRCSPN_IA32
+# endif
 #endif
 
 #endif /* HAVE_SSE4_SUPPORT */
diff --git a/sysdeps/i386/i686/multiarch/strspn.S b/sysdeps/i386/i686/multiarch/strspn.S
index f306d2d..93f7113 100644
--- a/sysdeps/i386/i686/multiarch/strspn.S
+++ b/sysdeps/i386/i686/multiarch/strspn.S
@@ -82,12 +82,15 @@ END(strspn)
 # undef END
 # define END(name) \
 	cfi_endproc; .size __strspn_ia32, .-__strspn_ia32
-# undef libc_hidden_builtin_def
+
+# ifdef SHARED
+#  undef libc_hidden_builtin_def
 /* IFUNC doesn't work with the hidden functions in shared library since
    they will be called without setting up EBX needed for PLT which is
    used by IFUNC.  */
-# define libc_hidden_builtin_def(name) \
+#  define libc_hidden_builtin_def(name) \
 	.globl __GI_strspn; __GI_strspn = __strspn_ia32
+# endif
 #endif
 
 #endif /* HAVE_SSE4_SUPPORT */
diff --git a/sysdeps/i386/i686/strtok_r.S b/sysdeps/i386/i686/strtok_r.S
index 1c24ca8..15a8a48 100644
--- a/sysdeps/i386/i686/strtok_r.S
+++ b/sysdeps/i386/i686/strtok_r.S
@@ -2,4 +2,6 @@
 #define USE_AS_STRTOK_R	1
 #include <sysdeps/i386/i686/strtok.S>
 weak_alias (BP_SYM (__strtok_r), BP_SYM (strtok_r))
+#ifdef SHARED
 strong_alias (BP_SYM (__strtok_r), BP_SYM (__GI___strtok_r))
+#endif
diff --git a/sysdeps/unix/Makefile b/sysdeps/unix/Makefile
index f714088..adba772 100644
--- a/sysdeps/unix/Makefile
+++ b/sysdeps/unix/Makefile
@@ -295,7 +295,9 @@ $(objpfx)stub-syscalls.c: $(common-objpfx)sysd-syscalls \
 		 echo "symbol_version ($${call}_$${ver}, $$call, $$ver);" ;; \
 	   *) echo "weak_alias (_no_syscall, $$call)"; \
 	      echo "stub_warning ($$call)"; \
-	      echo "weak_alias (_no_syscall, __GI_$$call)" ;; \
+	      echo "#ifdef SHARED" ; \
+	      echo "weak_alias (_no_syscall, __GI_$$call)" ; \
+	      echo "#endif" ;; \
 	   esac; \
 	 echo '#include <stub-tag.h>'; \
 	 done) > $@T
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
index 8b1c932..7732af4 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
@@ -106,4 +106,6 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 libc_hidden_def (__fxstatat)
 #undef __fxstatat64
 strong_alias (__fxstatat, __fxstatat64);
+#ifdef SHARED
 strong_alias (__fxstatat64, __GI___fxstatat64)
+#endif
diff --git a/sysdeps/x86_64/multiarch/rawmemchr.S b/sysdeps/x86_64/multiarch/rawmemchr.S
index 08fd876..d743f9d 100644
--- a/sysdeps/x86_64/multiarch/rawmemchr.S
+++ b/sysdeps/x86_64/multiarch/rawmemchr.S
@@ -84,12 +84,15 @@ __rawmemchr_sse42:
 # undef END
 # define END(name) \
 	cfi_endproc; .size __rawmemchr_sse2, .-__rawmemchr_sse2
-# undef libc_hidden_builtin_def
+
+# ifdef SHARED
+#  undef libc_hidden_builtin_def
 /* It doesn't make sense to send libc-internal rawmemchr calls through a PLT.
    The speedup we get from using SSE4.2 instruction is likely eaten away
    by the indirect call in the PLT.  */
-# define libc_hidden_builtin_def(name) \
+#  define libc_hidden_builtin_def(name) \
 	.globl __GI___rawmemchr; __GI___rawmemchr = __rawmemchr_sse2
+# endif
 #endif
 
 #include "../rawmemchr.S"
diff --git a/sysdeps/x86_64/multiarch/strcmp.S b/sysdeps/x86_64/multiarch/strcmp.S
index 05adf1e..8e5ce16 100644
--- a/sysdeps/x86_64/multiarch/strcmp.S
+++ b/sysdeps/x86_64/multiarch/strcmp.S
@@ -1528,12 +1528,15 @@ LABEL(unaligned_table_sse4_2):
 # undef END
 # define END(name) \
 	cfi_endproc; .size STRCMP_SSE2, .-STRCMP_SSE2
-# undef libc_hidden_builtin_def
+
+# ifdef SHARED
+#  undef libc_hidden_builtin_def
 /* It doesn't make sense to send libc-internal strcmp calls through a PLT.
    The speedup we get from using SSE4.2 instruction is likely eaten away
    by the indirect call in the PLT.  */
-# define libc_hidden_builtin_def(name) \
+#  define libc_hidden_builtin_def(name) \
 	.globl __GI_STRCMP; __GI_STRCMP = STRCMP_SSE2
+# endif
 #endif
 
 #include "../strcmp.S"
diff --git a/sysdeps/x86_64/multiarch/strcpy.S b/sysdeps/x86_64/multiarch/strcpy.S
index 7e400a9..7db981d 100644
--- a/sysdeps/x86_64/multiarch/strcpy.S
+++ b/sysdeps/x86_64/multiarch/strcpy.S
@@ -1895,15 +1895,18 @@ LABEL(unaligned_table):
 # undef END
 # define END(name) \
 	cfi_endproc; .size STRCPY_SSE2, .-STRCPY_SSE2
-# undef libc_hidden_builtin_def
+
+# ifdef SHARED
+#  undef libc_hidden_builtin_def
 /* It doesn't make sense to send libc-internal strcpy calls through a PLT.
    The speedup we get from using SSSE3 instruction is likely eaten away
    by the indirect call in the PLT.  */
-# define libc_hidden_builtin_def(name) \
+#  define libc_hidden_builtin_def(name) \
 	.globl __GI_STRCPY; __GI_STRCPY = STRCPY_SSE2
-# undef libc_hidden_def
-# define libc_hidden_def(name) \
+#  undef libc_hidden_def
+#  define libc_hidden_def(name) \
 	.globl __GI___STRCPY; __GI___STRCPY = STRCPY_SSE2
+# endif
 #endif
 
 #ifndef USE_AS_STRNCPY
diff --git a/sysdeps/x86_64/multiarch/strcspn.S b/sysdeps/x86_64/multiarch/strcspn.S
index cc75ab7..6266011 100644
--- a/sysdeps/x86_64/multiarch/strcspn.S
+++ b/sysdeps/x86_64/multiarch/strcspn.S
@@ -65,12 +65,15 @@ END(STRCSPN)
 # undef END
 # define END(name) \
 	cfi_endproc; .size STRCSPN_SSE2, .-STRCSPN_SSE2
-# undef libc_hidden_builtin_def
+
+# ifdef SHARED
+#  undef libc_hidden_builtin_def
 /* It doesn't make sense to send libc-internal strcspn calls through a PLT.
    The speedup we get from using SSE4.2 instruction is likely eaten away
    by the indirect call in the PLT.  */
-# define libc_hidden_builtin_def(name) \
+#  define libc_hidden_builtin_def(name) \
 	.globl __GI_STRCSPN; __GI_STRCSPN = STRCSPN_SSE2
+# endif
 #endif
 
 #endif /* HAVE_SSE4_SUPPORT */
diff --git a/sysdeps/x86_64/multiarch/strspn.S b/sysdeps/x86_64/multiarch/strspn.S
index 4183a2c..d4819a1 100644
--- a/sysdeps/x86_64/multiarch/strspn.S
+++ b/sysdeps/x86_64/multiarch/strspn.S
@@ -50,12 +50,15 @@ END(strspn)
 # undef END
 # define END(name) \
 	cfi_endproc; .size __strspn_sse2, .-__strspn_sse2
-# undef libc_hidden_builtin_def
+
+# ifdef SHARED
+#  undef libc_hidden_builtin_def
 /* It doesn't make sense to send libc-internal strspn calls through a PLT.
    The speedup we get from using SSE4.2 instruction is likely eaten away
    by the indirect call in the PLT.  */
-# define libc_hidden_builtin_def(name) \
+#  define libc_hidden_builtin_def(name) \
 	.globl __GI_strspn; __GI_strspn = __strspn_sse2
+# endif
 #endif
 
 #endif /* HAVE_SSE4_SUPPORT */
diff --git a/sysdeps/x86_64/strtok_r.S b/sysdeps/x86_64/strtok_r.S
index 8ce0089..707153d 100644
--- a/sysdeps/x86_64/strtok_r.S
+++ b/sysdeps/x86_64/strtok_r.S
@@ -2,4 +2,6 @@
 #define USE_AS_STRTOK_R	1
 #include <sysdeps/x86_64/strtok.S>
 weak_alias (BP_SYM (__strtok_r), BP_SYM (strtok_r))
+#ifdef SHARED
 strong_alias (BP_SYM (__strtok_r), BP_SYM (__GI___strtok_r))
+#endif


More information about the Libc-alpha mailing list