1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

hurd: keep only required PLTs in ld.so

We need NO_RTLD_HIDDEN because of the need for PLT calls in ld.so.
See Roland's comment in
https://sourceware.org/bugzilla/show_bug.cgi?id=15605
"in the Hurd it's crucial that calls like __mmap be the libc ones
instead of the rtld-local ones after the bootstrap phase, when the
dynamic linker is being used for dlopen and the like."

We used to just avoid all hidden use in the rtld ; this commit switches to
keeping only those that should use PLT calls, i.e. essentially those defined in
sysdeps/mach/hurd/dl-sysdep.c:

__assert_fail
__assert_perror_fail
__*stat64
_exit

This fixes a few startup issues, notably the call to __tunable_get_val that is
made before PLTs are set up.
This commit is contained in:
Samuel Thibault
2020-11-10 23:35:19 +00:00
parent a40b18b233
commit 3d3316b1de
17 changed files with 20 additions and 34 deletions

View File

@ -292,7 +292,9 @@ Inconsistency detected by ld.so: %s: %u: %s%sAssertion `%s' failed!\n",
assertion); assertion);
} }
# ifndef NO_RTLD_HIDDEN
rtld_hidden_weak (__assert_fail) rtld_hidden_weak (__assert_fail)
# endif
void weak_function void weak_function
__assert_perror_fail (int errnum, __assert_perror_fail (int errnum,
@ -306,7 +308,9 @@ Inconsistency detected by ld.so: %s: %u: %s%sUnexpected error: %s.\n",
__strerror_r (errnum, errbuf, sizeof errbuf)); __strerror_r (errnum, errbuf, sizeof errbuf));
} }
# ifndef NO_RTLD_HIDDEN
rtld_hidden_weak (__assert_perror_fail) rtld_hidden_weak (__assert_perror_fail)
# endif
#endif #endif
#undef _itoa #undef _itoa

View File

@ -81,7 +81,7 @@ extern int __scandir64_tail (DIR *dp,
libc_hidden_proto (__rewinddir) libc_hidden_proto (__rewinddir)
extern __typeof (scandirat) __scandirat; extern __typeof (scandirat) __scandirat;
# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN # if IS_IN (rtld)
extern __typeof (__rewinddir) __rewinddir attribute_hidden; extern __typeof (__rewinddir) __rewinddir attribute_hidden;
# endif # endif
# endif # endif

View File

@ -43,7 +43,7 @@ extern void __libc_thread_freeres (void);
/* Define and initialize `__progname' et. al. */ /* Define and initialize `__progname' et. al. */
extern void __init_misc (int, char **, char **) attribute_hidden; extern void __init_misc (int, char **, char **) attribute_hidden;
# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN # if IS_IN (rtld)
extern __typeof (__profile_frequency) __profile_frequency attribute_hidden; extern __typeof (__profile_frequency) __profile_frequency attribute_hidden;
# endif # endif

View File

@ -643,7 +643,7 @@ for linking")
# define libc_hidden_data_ver(local, name) # define libc_hidden_data_ver(local, name)
#endif #endif
#if IS_IN (rtld) && !defined NO_RTLD_HIDDEN #if IS_IN (rtld)
# define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define rtld_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) # define rtld_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
# define rtld_hidden_def(name) hidden_def (name) # define rtld_hidden_def(name) hidden_def (name)

View File

@ -27,7 +27,7 @@ extern void __libc_longjmp (sigjmp_buf env, int val)
libc_hidden_proto (_setjmp) libc_hidden_proto (_setjmp)
libc_hidden_proto (__sigsetjmp) libc_hidden_proto (__sigsetjmp)
# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN # if IS_IN (rtld)
extern __typeof (__sigsetjmp) __sigsetjmp attribute_hidden; extern __typeof (__sigsetjmp) __sigsetjmp attribute_hidden;
# endif # endif

View File

@ -67,7 +67,7 @@ extern int __xpg_sigpause (int sig);
/* Allocate real-time signal with highest/lowest available priority. */ /* Allocate real-time signal with highest/lowest available priority. */
extern int __libc_allocate_rtsig (int __high); extern int __libc_allocate_rtsig (int __high);
# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN # if IS_IN (rtld)
extern __typeof (__sigaction) __sigaction attribute_hidden; extern __typeof (__sigaction) __sigaction attribute_hidden;
extern __typeof (__libc_sigaction) __libc_sigaction attribute_hidden; extern __typeof (__libc_sigaction) __libc_sigaction attribute_hidden;
# endif # endif

View File

@ -310,7 +310,7 @@ struct abort_msg_s
extern struct abort_msg_s *__abort_msg; extern struct abort_msg_s *__abort_msg;
libc_hidden_proto (__abort_msg) libc_hidden_proto (__abort_msg)
# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN # if IS_IN (rtld)
extern __typeof (unsetenv) unsetenv attribute_hidden; extern __typeof (unsetenv) unsetenv attribute_hidden;
extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden; extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;
# endif # endif

View File

@ -150,7 +150,7 @@ libc_hidden_builtin_proto (strspn)
libc_hidden_builtin_proto (strstr) libc_hidden_builtin_proto (strstr)
libc_hidden_builtin_proto (ffs) libc_hidden_builtin_proto (ffs)
#if IS_IN (rtld) && !defined NO_RTLD_HIDDEN #if IS_IN (rtld)
extern __typeof (__stpcpy) __stpcpy attribute_hidden; extern __typeof (__stpcpy) __stpcpy attribute_hidden;
extern __typeof (__strdup) __strdup attribute_hidden; extern __typeof (__strdup) __strdup attribute_hidden;
extern __typeof (__strerror_r) __strerror_r attribute_hidden; extern __typeof (__strerror_r) __strerror_r attribute_hidden;

View File

@ -7,7 +7,7 @@ extern int __uname (struct utsname *__name);
libc_hidden_proto (uname) libc_hidden_proto (uname)
libc_hidden_proto (__uname) libc_hidden_proto (__uname)
# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN # if IS_IN (rtld)
extern __typeof (__uname) __uname attribute_hidden; extern __typeof (__uname) __uname attribute_hidden;
# endif # endif
#endif #endif

View File

@ -4,7 +4,9 @@
# ifndef _ISOMAC # ifndef _ISOMAC
libc_hidden_proto (_exit, __noreturn__) libc_hidden_proto (_exit, __noreturn__)
# ifndef NO_RTLD_HIDDEN
rtld_hidden_proto (_exit, __noreturn__) rtld_hidden_proto (_exit, __noreturn__)
# endif
libc_hidden_proto (alarm) libc_hidden_proto (alarm)
extern size_t __confstr (int name, char *buf, size_t len); extern size_t __confstr (int name, char *buf, size_t len);
libc_hidden_proto (__confstr) libc_hidden_proto (__confstr)

View File

@ -46,7 +46,7 @@ extern char *_itoa (unsigned long long int value, char *buflim,
extern const char _itoa_upper_digits[]; extern const char _itoa_upper_digits[];
extern const char _itoa_lower_digits[]; extern const char _itoa_lower_digits[];
#if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN) #if IS_IN (libc) || IS_IN (rtld)
hidden_proto (_itoa_upper_digits) hidden_proto (_itoa_upper_digits)
hidden_proto (_itoa_lower_digits) hidden_proto (_itoa_lower_digits)
#endif #endif

View File

@ -129,11 +129,7 @@ _dl_tlsdesc_dynamic:
.p2align 4,,7 .p2align 4,,7
.Lslow: .Lslow:
cfi_adjust_cfa_offset (28) cfi_adjust_cfa_offset (28)
#ifdef NO_RTLD_HIDDEN
call JUMPTARGET (___tls_get_addr)
#else
call HIDDEN_JUMPTARGET (___tls_get_addr) call HIDDEN_JUMPTARGET (___tls_get_addr)
#endif
jmp .Lret jmp .Lret
cfi_endproc cfi_endproc
.size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic .size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic

View File

@ -51,5 +51,7 @@ _exit (int status)
_hurd_exit (W_EXITCODE (status, 0)); _hurd_exit (W_EXITCODE (status, 0));
} }
libc_hidden_def (_exit) libc_hidden_def (_exit)
#ifndef NO_RTLD_HIDDEN
rtld_hidden_def (_exit) rtld_hidden_def (_exit)
#endif
weak_alias (_exit, _Exit) weak_alias (_exit, _Exit)

View File

@ -641,7 +641,8 @@ __sbrk (intptr_t increment)
return (void *) addr; return (void *) addr;
} }
check_no_hidden(__strtoul_internal); /* This is only used by hurdlookup for the /dev/fd/nnn magic.
* We avoid pulling the whole libc implementation, and we can keep this hidden. */
unsigned long int weak_function unsigned long int weak_function
__strtoul_internal (const char *nptr, char **endptr, int base, int group) __strtoul_internal (const char *nptr, char **endptr, int base, int group)
{ {
@ -698,7 +699,6 @@ abort (void)
/* We need this alias to satisfy references from libc_pic.a objects /* We need this alias to satisfy references from libc_pic.a objects
that were affected by the libc_hidden_proto declaration for abort. */ that were affected by the libc_hidden_proto declaration for abort. */
strong_alias (abort, __GI_abort) strong_alias (abort, __GI_abort)
strong_alias (abort, __GI___chk_fail)
strong_alias (abort, __GI___fortify_fail) strong_alias (abort, __GI___fortify_fail)
strong_alias (abort, __GI___assert_fail) strong_alias (abort, __GI___assert_fail)
strong_alias (abort, __GI___assert_perror_fail) strong_alias (abort, __GI___assert_perror_fail)

View File

@ -9,7 +9,6 @@ GLIBC_2.2.6 __open64 F
GLIBC_2.2.6 __pread64 F GLIBC_2.2.6 __pread64 F
GLIBC_2.2.6 __read F GLIBC_2.2.6 __read F
GLIBC_2.2.6 __sbrk F GLIBC_2.2.6 __sbrk F
GLIBC_2.2.6 __strtoul_internal F
GLIBC_2.2.6 __write F GLIBC_2.2.6 __write F
GLIBC_2.2.6 __writev F GLIBC_2.2.6 __writev F
GLIBC_2.2.6 __xstat64 F GLIBC_2.2.6 __xstat64 F

View File

@ -37,24 +37,11 @@ ld.so: __access_noerrno
ld.so: __getpid ld.so: __getpid
ld.so: __getcwd ld.so: __getcwd
ld.so: __sbrk ld.so: __sbrk
ld.so: __strtoul_internal ld.so: _exit ?
#ld.so: _exit
ld.so: abort ld.so: abort
ld.so: _hurd_intr_rpc_mach_msg ld.so: _hurd_intr_rpc_mach_msg
ld.so: __errno_location ld.so: __errno_location
# rtld_hidden is currently disabled to avoid having to special-case the
# functions above which do need a PLT. These are thus currently expected.
ld.so: _dl_allocate_tls
ld.so: _dl_allocate_tls_init
ld.so: _dl_exception_create
ld.so: _dl_exception_create_format
ld.so: _dl_exception_free
ld.so: _dl_fatal_printf
ld.so: _dl_find_dso_for_object
ld.so: _dl_init_first ld.so: _dl_init_first
ld.so: _dl_mcount
ld.so: ___tls_get_addr
ld.so: __tunable_get_val
# #
# These should ideally be avoided, but is currently difficult # These should ideally be avoided, but is currently difficult
libc.so: siglongjmp ? libc.so: siglongjmp ?

View File

@ -131,11 +131,7 @@ _dl_tlsdesc_dynamic:
movq %r10, 40(%rsp) movq %r10, 40(%rsp)
movq %r11, 48(%rsp) movq %r11, 48(%rsp)
/* %rdi already points to the tlsinfo data structure. */ /* %rdi already points to the tlsinfo data structure. */
#ifdef NO_RTLD_HIDDEN
call JUMPTARGET (__tls_get_addr)
#else
call HIDDEN_JUMPTARGET (__tls_get_addr) call HIDDEN_JUMPTARGET (__tls_get_addr)
#endif
movq 8(%rsp), %rdx movq 8(%rsp), %rdx
movq 16(%rsp), %rcx movq 16(%rsp), %rcx
movq 24(%rsp), %r8 movq 24(%rsp), %r8