aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-06-07 11:11:03 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-06-24 17:45:58 -0300
commitbaf2a265c71113a91f6971313ef191be9e77ef6a (patch)
treead894e8766707e8c10e98b6e4c857ab315fa0276 /include
parent5b41b2659d35b72636ab50a28d6815cad9c22a66 (diff)
downloadglibc-baf2a265c71113a91f6971313ef191be9e77ef6a.tar
glibc-baf2a265c71113a91f6971313ef191be9e77ef6a.tar.gz
glibc-baf2a265c71113a91f6971313ef191be9e77ef6a.tar.bz2
glibc-baf2a265c71113a91f6971313ef191be9e77ef6a.zip
misc: Optimize internal usage of __libc_single_threaded
By adding an internal alias to avoid the GOT indirection. On some architecture, __libc_single_thread may be accessed through copy relocations and thus it requires to update also the copies default copy. This is done by adding a new internal macro, libc_hidden_data_{proto,def}, which has an addition argument that specifies the alias name (instead of default __GI_ one). Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Fangrui Song <maskray@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/libc-symbols.h22
-rw-r--r--include/sys/single_threaded.h11
2 files changed, 33 insertions, 0 deletions
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 4bb3d8c7ba..4fde839471 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -534,11 +534,15 @@ for linking")
__attribute__ ((visibility ("hidden"), ##attrs))
# define hidden_proto(name, attrs...) \
__hidden_proto (name, , __GI_##name, ##attrs)
+# define hidden_proto_alias(name, alias, attrs...) \
+ __hidden_proto_alias (name, , alias, ##attrs)
# define hidden_tls_proto(name, attrs...) \
__hidden_proto (name, __thread, __GI_##name, ##attrs)
# define __hidden_proto(name, thread, internal, attrs...) \
extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
__hidden_proto_hiddenattr (attrs);
+# define __hidden_proto_alias(name, thread, internal, attrs...) \
+ extern thread __typeof (name) internal __hidden_proto_hiddenattr (attrs);
# define __hidden_asmname(name) \
__hidden_asmname1 (__USER_LABEL_PREFIX__, name)
# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
@@ -554,7 +558,10 @@ for linking")
# define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
# define hidden_data_ver(local, name) hidden_ver(local, name)
# define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
+# define hidden_def_alias(name, internal) \
+ strong_alias (name, internal)
# define hidden_data_def(name) hidden_def(name)
+# define hidden_data_def_alias(name, alias) hidden_def_alias(name, alias)
# define hidden_tls_def(name) \
__hidden_ver2 (__thread, __GI_##name, name, name);
# define hidden_weak(name) \
@@ -581,9 +588,11 @@ for linking")
hidden_proto doesn't make sense for assembly but the equivalent
is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */
# define hidden_def(name) strong_alias (name, __GI_##name)
+# define hidden_def_alias(name, alias) strong_alias (name, alias)
# define hidden_weak(name) hidden_def (name)
# define hidden_ver(local, name) strong_alias (local, __GI_##name)
# define hidden_data_def(name) strong_data_alias (name, __GI_##name)
+# define hidden_data_def_alias(name, alias) strong_data_alias (name, alias)
# define hidden_tls_def(name) hidden_data_def (name)
# define hidden_data_weak(name) hidden_data_def (name)
# define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
@@ -598,12 +607,17 @@ for linking")
__attribute__ ((visibility ("hidden"), ##attrs))
# define hidden_proto(name, attrs...) \
__hidden_proto (name, , name, ##attrs)
+# define hidden_proto_alias(name, alias, attrs...) \
+ __hidden_proto_alias (name, , alias, ##attrs)
# define hidden_tls_proto(name, attrs...) \
__hidden_proto (name, __thread, name, ##attrs)
# define __hidden_proto(name, thread, internal, attrs...) \
extern thread __typeof (name) name __hidden_proto_hiddenattr (attrs);
+# define __hidden_proto_alias(name, thread, internal, attrs...) \
+ extern thread __typeof (name) internal __hidden_proto_hiddenattr (attrs);
# else
# define hidden_proto(name, attrs...)
+# define hidden_proto_alias(name, alias, attrs...)
# define hidden_tls_proto(name, attrs...)
# endif
# else
@@ -611,9 +625,11 @@ for linking")
# endif /* Not __ASSEMBLER__ */
# define hidden_weak(name)
# define hidden_def(name)
+# define hidden_def_alias(name, alias)
# define hidden_ver(local, name)
# define hidden_data_weak(name)
# define hidden_data_def(name)
+# define hidden_data_def_alias(name, alias)
# define hidden_tls_def(name)
# define hidden_data_ver(local, name)
# define hidden_nolink(name, lib, version)
@@ -621,22 +637,28 @@ for linking")
#if IS_IN (libc)
# define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
+# define libc_hidden_proto_alias(name, alias, attrs...) \
+ hidden_proto_alias (name, alias, ##attrs)
# define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
# define libc_hidden_def(name) hidden_def (name)
+# define libc_hidden_def_alias(name, alias) hidden_def_alias (name, alias)
# define libc_hidden_weak(name) hidden_weak (name)
# define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
# define libc_hidden_ver(local, name) hidden_ver (local, name)
# define libc_hidden_data_def(name) hidden_data_def (name)
+# define libc_hidden_data_def_alias(name, alias) hidden_data_def_alias (name, alias)
# define libc_hidden_tls_def(name) hidden_tls_def (name)
# define libc_hidden_data_weak(name) hidden_data_weak (name)
# define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
#else
# define libc_hidden_proto(name, attrs...)
+# define libc_hidden_proto_alias(name, alias, attrs...)
# define libc_hidden_tls_proto(name, attrs...)
# define libc_hidden_def(name)
# define libc_hidden_weak(name)
# define libc_hidden_ver(local, name)
# define libc_hidden_data_def(name)
+# define libc_hidden_data_def_alias(name, alias)
# define libc_hidden_tls_def(name)
# define libc_hidden_data_weak(name)
# define libc_hidden_data_ver(local, name)
diff --git a/include/sys/single_threaded.h b/include/sys/single_threaded.h
index 18f6972482..2015742be0 100644
--- a/include/sys/single_threaded.h
+++ b/include/sys/single_threaded.h
@@ -1 +1,12 @@
#include <misc/sys/single_threaded.h>
+
+#ifndef _ISOMAC
+
+libc_hidden_proto_alias (__libc_single_threaded,
+ __libc_single_threaded_internal);
+
+#if !defined SHARED || !IS_IN(libc)
+# define __libc_single_threaded_internal __libc_single_threaded
+#endif
+
+#endif