This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Mark __tunables_init hidden and avoid PLT


Since __tunables_init is internal to ld.so, we should mark it hidden
to avoid PLT.  We should also avoid PLT when calling __tunable_set_val
within ld.so.

Any comments?

H.J.
---
	* elf/dl-tunables.c (__tunables_init): Mark hidden.
	(__rtld_tunable_set_val): Add a hidden alias for
	__tunable_set_val.
	* elf/dl-tunables.h (__tunables_init): Mark hidden.
	(__rtld_tunable_set_val): New.
	(DL_TUNABLE_SET_VAL): Likewise.
	(TUNABLE_SET_VAL): Replace __tunable_set_val with
	DL_TUNABLE_SET_VAL.
	(TUNABLE_SET_VAL_WITH_CALLBACK): Likewise.
---
 elf/dl-tunables.c |  5 +++++
 elf/dl-tunables.h | 16 +++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index 8d72e26..d6f3309 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -344,6 +344,7 @@ maybe_enable_malloc_check (void)
 /* Initialize the tunables list from the environment.  For now we only use the
    ENV_ALIAS to find values.  Later we will also use the tunable names to find
    values.  */
+__attribute__ ((visibility ("hidden")))
 void
 __tunables_init (char **envp)
 {
@@ -423,6 +424,10 @@ __tunables_init (char **envp)
     }
 }
 
+extern void __rtld_tunable_set_val (tunable_id_t, void *,
+				    tunable_callback_t)
+  __attribute__ ((alias ("__tunable_set_val"), visibility ("hidden")));
+
 /* Set the tunable value.  This is called by the module that the tunable exists
    in. */
 void
diff --git a/elf/dl-tunables.h b/elf/dl-tunables.h
index f33adfb..713a42e 100644
--- a/elf/dl-tunables.h
+++ b/elf/dl-tunables.h
@@ -66,14 +66,24 @@ typedef struct _tunable tunable_t;
 
 # include "dl-tunable-list.h"
 
-extern void __tunables_init (char **);
+extern void __tunables_init (char **)
+  __attribute__ ((visibility ("hidden")));
 extern void __tunable_set_val (tunable_id_t, void *, tunable_callback_t);
+extern void __rtld_tunable_set_val (tunable_id_t, void *, tunable_callback_t)
+  __attribute__ ((visibility ("hidden")));
+
+/* Avoid PLT when calling __tunable_set_val within ld.so.  */
+#if IS_IN (rtld)
+# define DL_TUNABLE_SET_VAL	__rtld_tunable_set_val
+#else
+# define DL_TUNABLE_SET_VAL	__tunable_set_val
+#endif
 
 /* Check if the tunable has been set to a non-default value and if it is, copy
    it over into __VAL.  */
 # define TUNABLE_SET_VAL(__id,__val) \
 ({									      \
-  __tunable_set_val							      \
+  DL_TUNABLE_SET_VAL							      \
    (TUNABLE_ENUM_NAME (TOP_NAMESPACE, TUNABLE_NAMESPACE, __id), (__val),      \
     NULL);								      \
 })
@@ -81,7 +91,7 @@ extern void __tunable_set_val (tunable_id_t, void *, tunable_callback_t);
 /* Same as TUNABLE_SET_VAL, but also call the callback function __CB.  */
 # define TUNABLE_SET_VAL_WITH_CALLBACK(__id,__val,__cb) \
 ({									      \
-  __tunable_set_val							      \
+  DL_TUNABLE_SET_VAL							      \
    (TUNABLE_ENUM_NAME (TOP_NAMESPACE, TUNABLE_NAMESPACE, __id), (__val),      \
     DL_TUNABLE_CALLBACK (__cb));					      \
 })
-- 
2.9.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]