[1/2] Mark internal argz functions with attribute_hidden [BZ #18822]

Message ID 20170818130141.GA4463@gmail.com
State New, archived
Headers

Commit Message

H.J. Lu Aug. 18, 2017, 1:01 p.m. UTC
  Mark internal argz functions with attribute_hidden to allow direct
access to them within libc.so and libc.a without using GOT nor PLT.

OK for master?

H.J.
---
	[BZ #18822]
	* include/argz.h (__argz_add): Add attribute_hidden.
	(__argz_add_sep): Likewise.
	(__argz_append): Likewise.
	(__argz_create_sep): Likewise.
---
 include/argz.h | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Joseph Myers Aug. 18, 2017, 2:01 p.m. UTC | #1
On Fri, 18 Aug 2017, H.J. Lu wrote:

> diff --git a/include/argz.h b/include/argz.h
> index 0388c23277..bddebfa221 100644
> --- a/include/argz.h
> +++ b/include/argz.h
> @@ -4,6 +4,11 @@
>  
>  # ifndef _ISOMAC
>  
> +extern __typeof (__argz_add) __argz_add attribute_hidden;
> +extern __typeof (__argz_add_sep) __argz_add_sep attribute_hidden;
> +extern __typeof (__argz_append) __argz_append attribute_hidden;
> +extern __typeof (__argz_create_sep) __argz_create_sep attribute_hidden;

This sort of use of typeof is suspect for an internal function.  For 
declaring an internal alias to a public function, sure, but why redeclare 
an internal function using typeof rather than just getting the original 
declaration of the internal function right?

In this case, the problem presumably is that the internal declarations are 
in the installed argz.h header.  So move them from the installed header to 
the include/ one.  At that point, using typeof *does* make sense to copy 
the type from the public function, e.g.

extern __typeof (argz_add) __argz_add __THROW attribute_hidden;

(argz.h is shared with gnulib, but in gnulib it doesn't have those 
internal declarations anyway.  So moving them to the include/ header helps 
bring the public one closer to the gnulib version.)
  

Patch

diff --git a/include/argz.h b/include/argz.h
index 0388c23277..bddebfa221 100644
--- a/include/argz.h
+++ b/include/argz.h
@@ -4,6 +4,11 @@ 
 
 # ifndef _ISOMAC
 
+extern __typeof (__argz_add) __argz_add attribute_hidden;
+extern __typeof (__argz_add_sep) __argz_add_sep attribute_hidden;
+extern __typeof (__argz_append) __argz_append attribute_hidden;
+extern __typeof (__argz_create_sep) __argz_create_sep attribute_hidden;
+
 libc_hidden_proto (argz_delete)
 libc_hidden_proto (__argz_count)
 libc_hidden_proto (__argz_stringify)