Add a way to bypass the PLT when calling getauxval

Message ID 1495654883-24546-1-git-send-email-tuliom@linux.vnet.ibm.com
State Superseded
Delegated to: Joseph Myers
Headers

Commit Message

Tulio Magno Quites Machado Filho May 24, 2017, 7:41 p.m. UTC
  Add __libc_getauxval as an internal libc symbol allowing internal libc
calls to bypass the PLT.

This is leaving the ABI as it was: getauxval continues to be exported as a
weak symbol and __getauxval as a global symbol.

2017-05-24  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>

	* include/sys/auxv.h: Add a prototype for __libc_getauxval.
	* misc/getauxval.c (__getauxval): Rename to __libc_getauxval and
	add the strong alias __getauxval to __libc_getauxval.
---
 include/sys/auxv.h | 2 ++
 misc/getauxval.c   | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
  

Comments

Joseph Myers May 24, 2017, 7:51 p.m. UTC | #1
On Wed, 24 May 2017, Tulio Magno Quites Machado Filho wrote:

> Add __libc_getauxval as an internal libc symbol allowing internal libc
> calls to bypass the PLT.

Why add this alias instead of simply doing libc_hidden_proto (__getauxval) 
/ libc_hidden_def (__getauxval)?
  
Tulio Magno Quites Machado Filho May 24, 2017, 9:43 p.m. UTC | #2
Joseph Myers <joseph@codesourcery.com> writes:

> On Wed, 24 May 2017, Tulio Magno Quites Machado Filho wrote:
>
>> Add __libc_getauxval as an internal libc symbol allowing internal libc
>> calls to bypass the PLT.
>
> Why add this alias instead of simply doing libc_hidden_proto (__getauxval) 
> / libc_hidden_def (__getauxval)?

Because I made a wrong assumption about those macros.
I'll fix my patch and re-submit.

Thanks!
  

Patch

diff --git a/include/sys/auxv.h b/include/sys/auxv.h
index dede2c3..7b6ad3b 100644
--- a/include/sys/auxv.h
+++ b/include/sys/auxv.h
@@ -1 +1,3 @@ 
 #include <misc/sys/auxv.h>
+
+extern __typeof (getauxval) __libc_getauxval;
diff --git a/misc/getauxval.c b/misc/getauxval.c
index c83fbce..ff3e0ba 100644
--- a/misc/getauxval.c
+++ b/misc/getauxval.c
@@ -21,7 +21,8 @@ 
 
 
 unsigned long int
-__getauxval (unsigned long int type)
+attribute_hidden
+__libc_getauxval (unsigned long int type)
 {
 #ifdef HAVE_AUX_VECTOR
   ElfW(auxv_t) *p;
@@ -42,4 +43,5 @@  __getauxval (unsigned long int type)
   return 0;
 }
 
-weak_alias (__getauxval, getauxval)
+weak_alias (__libc_getauxval, getauxval)
+strong_alias (__libc_getauxval, __getauxval)