From patchwork Wed May 24 19:17:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lu, Hongjiu" X-Patchwork-Id: 20566 Received: (qmail 23797 invoked by alias); 24 May 2017 19:17:26 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 23787 invoked by uid 89); 24 May 2017 19:17:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:2822 X-HELO: mga02.intel.com X-ExtLoop1: 1 Date: Wed, 24 May 2017 12:17:26 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] Mark __tunables_init hidden and avoid PLT Message-ID: <20170524191726.GA27395@lucon.org> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.0 (2017-02-23) 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)); \ })