]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: keep only required PLTs in ld.so
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Tue, 10 Nov 2020 23:35:19 +0000 (23:35 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Wed, 11 Nov 2020 01:36:22 +0000 (02:36 +0100)
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.

17 files changed:
elf/dl-minimal.c
include/dirent.h
include/libc-internal.h
include/libc-symbols.h
include/setjmp.h
include/signal.h
include/stdlib.h
include/string.h
include/sys/utsname.h
include/unistd.h
sysdeps/generic/_itoa.h
sysdeps/i386/dl-tlsdesc.S
sysdeps/mach/hurd/_exit.c
sysdeps/mach/hurd/dl-sysdep.c
sysdeps/mach/hurd/i386/ld.abilist
sysdeps/mach/hurd/i386/localplt.data
sysdeps/x86_64/dl-tlsdesc.S

index b37abfaff919383a1f1217f94798c65a0a70f398..1168ac786edc2d97a3ec5d97661fe4b22481747b 100644 (file)
@@ -292,7 +292,9 @@ Inconsistency detected by ld.so: %s: %u: %s%sAssertion `%s' failed!\n",
                    assertion);
 
 }
+# ifndef NO_RTLD_HIDDEN
 rtld_hidden_weak (__assert_fail)
+# endif
 
 void weak_function
 __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));
 
 }
+# ifndef NO_RTLD_HIDDEN
 rtld_hidden_weak (__assert_perror_fail)
+# endif
 #endif
 \f
 #undef _itoa
index 8325a19e5fb09049a631993a2cdd060240f49154..f1d7e8359c6d4215361a08e802d2c4f368427d1b 100644 (file)
@@ -81,7 +81,7 @@ extern int __scandir64_tail (DIR *dp,
 libc_hidden_proto (__rewinddir)
 extern __typeof (scandirat) __scandirat;
 
-#  if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
+#  if IS_IN (rtld)
 extern __typeof (__rewinddir) __rewinddir attribute_hidden;
 #  endif
 # endif
index 729db7918e8c943f6623ee40503c613e49b6ebb4..915613c030f18ac620718e4af8f9962bc1769e8b 100644 (file)
@@ -43,7 +43,7 @@ extern void __libc_thread_freeres (void);
 /* Define and initialize `__progname' et. al.  */
 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;
 # endif
 
index 60153bb50d3dcf5aeff9303403300ae3609e2bbe..b8103b98bbee1eaa410911ecc630ce5553dad337 100644 (file)
@@ -643,7 +643,7 @@ for linking")
 # define libc_hidden_data_ver(local, name)
 #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_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
 # define rtld_hidden_def(name) hidden_def (name)
index e13017edd22094d9a6e393dc5932cd74ca47dc74..0a8e4d2eaf4bde19dce0c932b15ca5724fa9d878 100644 (file)
@@ -27,7 +27,7 @@ extern void __libc_longjmp (sigjmp_buf env, int val)
 libc_hidden_proto (_setjmp)
 libc_hidden_proto (__sigsetjmp)
 
-# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
+# if IS_IN (rtld)
 extern __typeof (__sigsetjmp) __sigsetjmp attribute_hidden;
 # endif
 
index 544d701bce59460db2d9b9297ebbcd89a7de1c2b..2a278697c1acb300285c9cea3b324b890cda95dc 100644 (file)
@@ -67,7 +67,7 @@ extern int __xpg_sigpause (int sig);
 /* Allocate real-time signal with highest/lowest available priority.  */
 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 (__libc_sigaction) __libc_sigaction attribute_hidden;
 #  endif
index ffcefd7b85ae603111441b1dc5e82cf0c25008c1..cdbdbf310dbc7fe8a1913fb4cd30c24e68332c6e 100644 (file)
@@ -310,7 +310,7 @@ struct abort_msg_s
 extern struct abort_msg_s *__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 (__strtoul_internal) __strtoul_internal attribute_hidden;
 # endif
index f4ce1386221c17e35cc1983ad086ec5ae0b201a2..7d344d77d43e6be9a97fc324ab217f8492f511b2 100644 (file)
@@ -150,7 +150,7 @@ libc_hidden_builtin_proto (strspn)
 libc_hidden_builtin_proto (strstr)
 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 (__strdup) __strdup attribute_hidden;
 extern __typeof (__strerror_r) __strerror_r attribute_hidden;
index 9ed5fa25657438a2f2c0c25999f607d86ff100db..14f4247dd4135d68c9ad4703a8dcf40c5edf3794 100644 (file)
@@ -7,7 +7,7 @@ extern int __uname (struct utsname *__name);
 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;
 # endif
 #endif
index f48da2c7a37257f8912f4f04225c5f98870bf3f2..54becbc9eb2df798c39e9170556ed433d4f00116 100644 (file)
@@ -4,7 +4,9 @@
 # ifndef _ISOMAC
 
 libc_hidden_proto (_exit, __noreturn__)
+#  ifndef NO_RTLD_HIDDEN
 rtld_hidden_proto (_exit, __noreturn__)
+#  endif
 libc_hidden_proto (alarm)
 extern size_t __confstr (int name, char *buf, size_t len);
 libc_hidden_proto (__confstr)
index 790f88a6d51d2e0fa82645918c6de1b6c2d624da..ef4de3af1b64e99f41d10135d9e9fbf8c21981af 100644 (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_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_lower_digits)
 #endif
index 32383e3badafd94ec4c823044af998a0f4f7332c..6d577395157e848978a86685eda5b81dffead44e 100644 (file)
@@ -129,11 +129,7 @@ _dl_tlsdesc_dynamic:
        .p2align 4,,7
 .Lslow:
        cfi_adjust_cfa_offset (28)
-#ifdef NO_RTLD_HIDDEN
-       call    JUMPTARGET (___tls_get_addr)
-#else
        call    HIDDEN_JUMPTARGET (___tls_get_addr)
-#endif
        jmp     .Lret
        cfi_endproc
        .size   _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic
index 46db06db63cd0a039a78d132332a617221f5c788..f04c5d2acf4e171b27b7b161a0b1e6b71293ffe7 100644 (file)
@@ -51,5 +51,7 @@ _exit (int status)
   _hurd_exit (W_EXITCODE (status, 0));
 }
 libc_hidden_def (_exit)
+#ifndef NO_RTLD_HIDDEN
 rtld_hidden_def (_exit)
+#endif
 weak_alias (_exit, _Exit)
index 5c0bb3124df872c88346a9709fe20083347d995a..6b32d41c7600d14d6afc6462d58cf9631d5f1660 100644 (file)
@@ -641,7 +641,8 @@ __sbrk (intptr_t increment)
   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
 __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
    that were affected by the libc_hidden_proto declaration for abort.  */
 strong_alias (abort, __GI_abort)
-strong_alias (abort, __GI___chk_fail)
 strong_alias (abort, __GI___fortify_fail)
 strong_alias (abort, __GI___assert_fail)
 strong_alias (abort, __GI___assert_perror_fail)
index 2e9bf2811f855b51450b033534258bfb8c37c0b1..0eaea9f66dfdb31490e4f835dba0ceb5233deb1b 100644 (file)
@@ -9,7 +9,6 @@ GLIBC_2.2.6 __open64 F
 GLIBC_2.2.6 __pread64 F
 GLIBC_2.2.6 __read F
 GLIBC_2.2.6 __sbrk F
-GLIBC_2.2.6 __strtoul_internal F
 GLIBC_2.2.6 __write F
 GLIBC_2.2.6 __writev F
 GLIBC_2.2.6 __xstat64 F
index b199e14e7f7cf87c8ae4df9235279bc364ca19c5..abd8f31fac729855c51cc3d020dfc7dc5b6bbc63 100644 (file)
@@ -37,24 +37,11 @@ ld.so: __access_noerrno
 ld.so: __getpid
 ld.so: __getcwd
 ld.so: __sbrk
-ld.so: __strtoul_internal
-#ld.so: _exit
+ld.so: _exit ?
 ld.so: abort
 ld.so: _hurd_intr_rpc_mach_msg
 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_mcount
-ld.so: ___tls_get_addr
-ld.so: __tunable_get_val
 #
 # These should ideally be avoided, but is currently difficult
 libc.so: siglongjmp ?
index 512a704faceb806eb567bc81b8ef5e040e74d56d..2535c88946e1b83a34b9de74b57b9594178bd74a 100644 (file)
@@ -131,11 +131,7 @@ _dl_tlsdesc_dynamic:
        movq    %r10, 40(%rsp)
        movq    %r11, 48(%rsp)
        /* %rdi already points to the tlsinfo data structure.  */
-#ifdef NO_RTLD_HIDDEN
-       call    JUMPTARGET (__tls_get_addr)
-#else
        call    HIDDEN_JUMPTARGET (__tls_get_addr)
-#endif
        movq    8(%rsp), %rdx
        movq    16(%rsp), %rcx
        movq    24(%rsp), %r8