Mark internal stdlib functions with attribute_hidden [BZ #18822]

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.
	(__realpath): Add libc_hidden_proto.
	(__ecvt_r): Likewise.
	(__fcvt_r): Likewise.
	(__qecvt_r): Likewise.
	(__qfcvt_r): Likewise.
	* misc/efgcvt_r.c (cvt_symbol_1): Add libc_hidden_def (local).
	* stdlib/canonicalize.c (__realpath): Add libc_hidden_def.
This commit is contained in:
H.J. Lu 2017-10-01 14:34:18 -07:00
parent ef9b6f73f4
commit 8ed3b64330
4 changed files with 68 additions and 20 deletions

View File

@ -1,3 +1,32 @@
2017-10-01 H.J. Lu <hongjiu.lu@intel.com>
[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.
(__realpath): Add libc_hidden_proto.
(__ecvt_r): Likewise.
(__fcvt_r): Likewise.
(__qecvt_r): Likewise.
(__qfcvt_r): Likewise.
* misc/efgcvt_r.c (cvt_symbol_1): Add libc_hidden_def (local).
* stdlib/canonicalize.c (__realpath): Add libc_hidden_def.
2017-10-01 H.J. Lu <hongjiu.lu@intel.com>
[BZ #18822]

View File

@ -36,56 +36,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);
@ -250,9 +259,11 @@ 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);
libc_hidden_proto (__ecvt_r)
extern int __fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
int *__restrict __sign, char *__restrict __buf,
size_t __len);
libc_hidden_proto (__fcvt_r)
extern char *__qecvt (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign);
extern char *__qfcvt (long double __value, int __ndigit,
@ -261,9 +272,11 @@ 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);
libc_hidden_proto (__qecvt_r)
extern int __qfcvt_r (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign,
char *__restrict __buf, size_t __len);
libc_hidden_proto (__qfcvt_r)
# if IS_IN (libc)
# undef MB_CUR_MAX

View File

@ -240,6 +240,7 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
# define cvt_symbol_1(lib, local, symbol, version) \
libc_hidden_def (local) \
versioned_symbol (lib, local, symbol, version)
# else
# define cvt_symbol(symbol) \
@ -247,11 +248,15 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
APPEND (q, symbol), GLIBC_2_0); \
weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
# define cvt_symbol_1(lib, local, symbol, version) \
libc_hidden_def (local) \
compat_symbol (lib, local, symbol, version)
# endif
#else
# define cvt_symbol(symbol) \
weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
# define cvt_symbol_1(local, symbol) \
libc_hidden_def (local) \
weak_alias (local, symbol)
#endif
cvt_symbol(fcvt_r);
cvt_symbol(ecvt_r);

View File

@ -218,6 +218,7 @@ error:
free (rpath);
return NULL;
}
libc_hidden_def (__realpath)
versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);