diff mbox

[19/58] Mark internal stdlib functions with attribute_hidden [BZ #18822]

Message ID 20170901180029.9527-20-hjl.tools@gmail.com
State New, archived
Headers show

Commit Message

H.J. Lu Sept. 1, 2017, 5:59 p.m. UTC
Mark internal stdlib functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.  __realpath
is hidden with libc_hidden_proto and libc_hidden_def since the exported
realpath is an alias of __realpath.

	[BZ #18822]
	* include/stdlib.h (__random): Add attribute_hidden.
	(__random_r): Likewise.
	(__srandom_r): Likewise.
	(__initstate_r): Likewise.
	(__setstate_r): Likewise.
	(__erand48_r): Likewise.
	(__nrand48_r): Likewise.
	(__jrand48_r): Likewise.
	(__srand48_r): Likewise.
	(__seed48_r): Likewise.
	(__lcong48_r): Likewise.
	(__drand48_iterate): Likewise.
	(__setenv): Likewise.
	(__unsetenv): Likewise.
	(__clearenv): Likewise.
	(__ptsname_r): Likewise.
	(__posix_openpt): Likewise.
	(__add_to_environ): Likewise.
	(__ecvt_r): Likewise.
	(__fcvt_r): Likewise.
	(__qecvt_r): Likewise.
	(__qfcvt_r): Likewise.
	(__realpath): Add libc_hidden_proto.
	* stdlib/canonicalize.c (__realpath): Add libc_hidden_def.
---
 include/stdlib.h      | 57 ++++++++++++++++++++++++++++++---------------------
 stdlib/canonicalize.c |  1 +
 2 files changed, 35 insertions(+), 23 deletions(-)

Comments

Florian Weimer Sept. 3, 2017, 9:13 a.m. UTC | #1
On 09/01/2017 07:59 PM, H.J. Lu wrote:
> 	(__qecvt_r): Likewise.
> 	(__qfcvt_r): Likewise.

I think this change makes symbols vanish from the public ABI on various
architectures:

--- ../sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
2017-08-28 05:01:14.557643019 -0400
+++ /home/bmg/build/glibcs/powerpc64-linux-gnu/glibc/libc.symlist
2017-09-03 05:07:32.110128081 -0400
@@ -1383 +1382,0 @@ GLIBC_2.3 qecvt F
-GLIBC_2.3 qecvt_r F
@@ -1385 +1383,0 @@ GLIBC_2.3 qfcvt F
-GLIBC_2.3 qfcvt_r F
@@ -2198 +2195,0 @@ GLIBC_2.4 qecvt F
-GLIBC_2.4 qecvt_r F
@@ -2200 +2196,0 @@ GLIBC_2.4 qfcvt F
-GLIBC_2.4 qfcvt_r F

(I assume that the patch is identical to what is on the hjl/pr18822
branch, which is what I used for testing.)

Thanks,
Florian
H.J. Lu Sept. 3, 2017, 9:49 p.m. UTC | #2
On Sun, Sep 3, 2017 at 2:13 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 09/01/2017 07:59 PM, H.J. Lu wrote:
>>       (__qecvt_r): Likewise.
>>       (__qfcvt_r): Likewise.
>
> I think this change makes symbols vanish from the public ABI on various
> architectures:
>
> --- ../sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
> 2017-08-28 05:01:14.557643019 -0400
> +++ /home/bmg/build/glibcs/powerpc64-linux-gnu/glibc/libc.symlist
> 2017-09-03 05:07:32.110128081 -0400
> @@ -1383 +1382,0 @@ GLIBC_2.3 qecvt F
> -GLIBC_2.3 qecvt_r F
> @@ -1385 +1383,0 @@ GLIBC_2.3 qfcvt F
> -GLIBC_2.3 qfcvt_r F
> @@ -2198 +2195,0 @@ GLIBC_2.4 qecvt F
> -GLIBC_2.4 qecvt_r F
> @@ -2200 +2196,0 @@ GLIBC_2.4 qfcvt F
> -GLIBC_2.4 qfcvt_r F
>
> (I assume that the patch is identical to what is on the hjl/pr18822
> branch, which is what I used for testing.)

I updated hjl/pr18822 branch and there are no regressions with
build-many-glibcs.py.
H.J. Lu Oct. 1, 2017, 9:10 p.m. UTC | #3
On 9/3/17, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Sep 3, 2017 at 2:13 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 09/01/2017 07:59 PM, H.J. Lu wrote:
>>>       (__qecvt_r): Likewise.
>>>       (__qfcvt_r): Likewise.
>>
>> I think this change makes symbols vanish from the public ABI on various
>> architectures:
>>
>> --- ../sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
>> 2017-08-28 05:01:14.557643019 -0400
>> +++ /home/bmg/build/glibcs/powerpc64-linux-gnu/glibc/libc.symlist
>> 2017-09-03 05:07:32.110128081 -0400
>> @@ -1383 +1382,0 @@ GLIBC_2.3 qecvt F
>> -GLIBC_2.3 qecvt_r F
>> @@ -1385 +1383,0 @@ GLIBC_2.3 qfcvt F
>> -GLIBC_2.3 qfcvt_r F
>> @@ -2198 +2195,0 @@ GLIBC_2.4 qecvt F
>> -GLIBC_2.4 qecvt_r F
>> @@ -2200 +2196,0 @@ GLIBC_2.4 qfcvt F
>> -GLIBC_2.4 qfcvt_r F
>>
>> (I assume that the patch is identical to what is on the hjl/pr18822
>> branch, which is what I used for testing.)
>
> I updated hjl/pr18822 branch and there are no regressions with
> build-many-glibcs.py.
>

I am checking it in now.
diff mbox

Patch

diff --git a/include/stdlib.h b/include/stdlib.h
index d0dcbf81c3..61a15cb340 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -40,56 +40,65 @@  libc_hidden_proto (__qsort_r)
 libc_hidden_proto (lrand48_r)
 libc_hidden_proto (wctomb)
 
-extern long int __random (void);
+extern long int __random (void) attribute_hidden;
 extern void __srandom (unsigned int __seed);
 extern char *__initstate (unsigned int __seed, char *__statebuf,
 			  size_t __statelen);
 extern char *__setstate (char *__statebuf);
-extern int __random_r (struct random_data *__buf, int32_t *__result);
-extern int __srandom_r (unsigned int __seed, struct random_data *__buf);
+extern int __random_r (struct random_data *__buf, int32_t *__result)
+     attribute_hidden;
+extern int __srandom_r (unsigned int __seed, struct random_data *__buf)
+     attribute_hidden;
 extern int __initstate_r (unsigned int __seed, char *__statebuf,
-			  size_t __statelen, struct random_data *__buf);
-extern int __setstate_r (char *__statebuf, struct random_data *__buf);
+			  size_t __statelen, struct random_data *__buf)
+     attribute_hidden;
+extern int __setstate_r (char *__statebuf, struct random_data *__buf)
+     attribute_hidden;
 extern int __rand_r (unsigned int *__seed);
 extern int __erand48_r (unsigned short int __xsubi[3],
-			struct drand48_data *__buffer, double *__result);
+			struct drand48_data *__buffer, double *__result)
+     attribute_hidden;
 extern int __nrand48_r (unsigned short int __xsubi[3],
 			struct drand48_data *__buffer,
-			long int *__result);
+			long int *__result) attribute_hidden;
 extern int __jrand48_r (unsigned short int __xsubi[3],
 			struct drand48_data *__buffer,
-			long int *__result);
+			long int *__result) attribute_hidden;
 extern int __srand48_r (long int __seedval,
-			struct drand48_data *__buffer);
+			struct drand48_data *__buffer) attribute_hidden;
 extern int __seed48_r (unsigned short int __seed16v[3],
-		       struct drand48_data *__buffer);
+		       struct drand48_data *__buffer) attribute_hidden;
 extern int __lcong48_r (unsigned short int __param[7],
-			struct drand48_data *__buffer);
+			struct drand48_data *__buffer) attribute_hidden;
 
 /* Internal function to compute next state of the generator.  */
 extern int __drand48_iterate (unsigned short int __xsubi[3],
-			      struct drand48_data *__buffer);
+			      struct drand48_data *__buffer)
+     attribute_hidden;
 
 /* Global state for non-reentrant functions.  Defined in drand48-iter.c.  */
 extern struct drand48_data __libc_drand48_data attribute_hidden;
 
-extern int __setenv (const char *__name, const char *__value, int __replace);
-extern int __unsetenv (const char *__name);
-extern int __clearenv (void);
+extern int __setenv (const char *__name, const char *__value, int __replace)
+     attribute_hidden;
+extern int __unsetenv (const char *__name) attribute_hidden;
+extern int __clearenv (void) attribute_hidden;
 extern char *__mktemp (char *__template) __THROW __nonnull ((1));
 extern char *__canonicalize_file_name (const char *__name);
 extern char *__realpath (const char *__name, char *__resolved);
-extern int __ptsname_r (int __fd, char *__buf, size_t __buflen);
+libc_hidden_proto (__realpath)
+extern int __ptsname_r (int __fd, char *__buf, size_t __buflen)
+     attribute_hidden;
 # ifndef _ISOMAC
 extern int __ptsname_internal (int fd, char *buf, size_t buflen,
 			       struct stat64 *stp) attribute_hidden;
 # endif
 extern int __getpt (void);
-extern int __posix_openpt (int __oflag);
+extern int __posix_openpt (int __oflag) attribute_hidden;
 
 extern int __add_to_environ (const char *name, const char *value,
-			     const char *combines, int replace);
-
+			     const char *combines, int replace)
+     attribute_hidden;
 extern void _quicksort (void *const pbase, size_t total_elems,
 			size_t size, __compar_d_fn_t cmp, void *arg);
 
@@ -253,10 +262,10 @@  extern char *__fcvt (double __value, int __ndigit, int *__restrict __decpt,
 extern char *__gcvt (double __value, int __ndigit, char *__buf);
 extern int __ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
 		     int *__restrict __sign, char *__restrict __buf,
-		     size_t __len);
+		     size_t __len) attribute_hidden;
 extern int __fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
 		     int *__restrict __sign, char *__restrict __buf,
-		     size_t __len);
+		     size_t __len) attribute_hidden;
 extern char *__qecvt (long double __value, int __ndigit,
 		      int *__restrict __decpt, int *__restrict __sign);
 extern char *__qfcvt (long double __value, int __ndigit,
@@ -264,10 +273,12 @@  extern char *__qfcvt (long double __value, int __ndigit,
 extern char *__qgcvt (long double __value, int __ndigit, char *__buf);
 extern int __qecvt_r (long double __value, int __ndigit,
 		      int *__restrict __decpt, int *__restrict __sign,
-		      char *__restrict __buf, size_t __len);
+		      char *__restrict __buf, size_t __len)
+     attribute_hidden;
 extern int __qfcvt_r (long double __value, int __ndigit,
 		      int *__restrict __decpt, int *__restrict __sign,
-		      char *__restrict __buf, size_t __len);
+		      char *__restrict __buf, size_t __len)
+     attribute_hidden;
 
 # if IS_IN (libc)
 #  undef MB_CUR_MAX
diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
index c3d892c862..4ff7e0feb8 100644
--- a/stdlib/canonicalize.c
+++ b/stdlib/canonicalize.c
@@ -218,6 +218,7 @@  error:
     free (rpath);
   return NULL;
 }
+libc_hidden_def (__realpath)
 versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);