git-dl-sysdep-check
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Sun, 14 Jan 2018 10:24:48 +0000 (10:24 +0000)
committerAurelien Jarno <aurel32@debian.org>
Sun, 14 Jan 2018 10:24:48 +0000 (10:24 +0000)
commit 5e6f32531eab502afb094ad62aad333c63a58cfd
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Sep 24 17:54:02 2017 +0200

    hurd: Make sure dl-sysdep.c defines proper symbol names

            * sysdeps/mach/hurd/dl-sysdep.c (check_no_hidden): New macro.
            (__open, __close, __libc_read, __libc_write, __writev, __libc_lseek64,
            __mmap, __fxstat64, __xstat64, __access, __access_noerrno, __getpid,
            __getcwd, __sbrk, __strtoul_internal, _exit, abort): Use check_no_hidden
            to make sure that these symbols are defined.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-dl-sysdep-check.diff

sysdeps/mach/hurd/dl-sysdep.c

index a88613405d82d0deaff5209fc218006459af9040..7d20dc5a4e609206abf0594080b916728a88adbc 100644 (file)
@@ -292,6 +292,11 @@ _dl_sysdep_start_cleanup (void)
    dynamic linker re-relocates itself to be user-visible (for -ldl),
    it will get the user's definition (i.e. usually libc's).  */
 
+/* This macro checks that the function does not get renamed to be hidden: we do
+   need these to be overridable by libc's.  */
+#define check_no_hidden(name) \
+static void __check_##name##_no_hidden(void) __attribute__((alias(#name)));
+
 /* Open FILE_NAME and return a Hurd I/O for it in *PORT, or return an
    error.  If STAT is non-zero, stat the file into that stat buffer.  */
 static error_t
@@ -347,6 +352,7 @@ open_file (const char *file_name, int flags,
   return err;
 }
 
+check_no_hidden(__open);
 int weak_function
 __open (const char *file_name, int mode, ...)
 {
@@ -358,6 +364,7 @@ __open (const char *file_name, int mode, ...)
     return (int)port;
 }
 
+check_no_hidden(__close);
 int weak_function
 __close (int fd)
 {
@@ -366,6 +373,7 @@ __close (int fd)
   return 0;
 }
 
+check_no_hidden(__libc_read);
 __ssize_t weak_function
 __libc_read (int fd, void *buf, size_t nbytes)
 {
@@ -389,6 +397,7 @@ __libc_read (int fd, void *buf, size_t nbytes)
 }
 libc_hidden_weak (__libc_read)
 
+check_no_hidden(__libc_write);
 __ssize_t weak_function
 __libc_write (int fd, const void *buf, size_t nbytes)
 {
@@ -406,6 +415,7 @@ __libc_write (int fd, const void *buf, size_t nbytes)
 libc_hidden_weak (__libc_write)
 
 /* This is only used for printing messages (see dl-misc.c).  */
+check_no_hidden(__writev);
 __ssize_t weak_function
 __writev (int fd, const struct iovec *iov, int niov)
 {
@@ -439,7 +449,7 @@ __writev (int fd, const struct iovec *iov, int niov)
   return 0;
 }
 
-
+check_no_hidden(__libc_lseek64);
 off64_t weak_function
 __libc_lseek64 (int fd, off64_t offset, int whence)
 {
@@ -452,6 +462,7 @@ __libc_lseek64 (int fd, off64_t offset, int whence)
   return offset;
 }
 
+check_no_hidden(__mmap);
 __ptr_t weak_function
 __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
 {
@@ -514,6 +525,7 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
   return (__ptr_t) mapaddr;
 }
 
+check_no_hidden(__fxstat64);
 int weak_function
 __fxstat64 (int vers, int fd, struct stat64 *buf)
 {
@@ -529,6 +541,7 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
 }
 libc_hidden_def (__fxstat64)
 
+check_no_hidden(__xstat64);
 int weak_function
 __xstat64 (int vers, const char *file, struct stat64 *buf)
 {
@@ -551,18 +564,21 @@ libc_hidden_def (__xstat64)
    whether debugging malloc is allowed even for SUID binaries.  This
    stub will always fail, which means that malloc-debugging is always
    disabled for SUID binaries.  */
+check_no_hidden(__access);
 int weak_function
 __access (const char *file, int type)
 {
   errno = ENOSYS;
   return -1;
 }
+check_no_hidden(__access_noerrno);
 int weak_function
 __access_noerrno (const char *file, int type)
 {
   return -1;
 }
 
+check_no_hidden(__getpid);
 pid_t weak_function
 __getpid (void)
 {
@@ -586,8 +602,8 @@ strong_alias (__getpid, __GI___getpid)
    the functionality here.  (We could, it just requires duplicating or
    reusing getcwd.c's code but using our special lookup function as in
    `open', above.)  */
-char *
-weak_function
+check_no_hidden(__getcwd);
+char *weak_function
 __getcwd (char *buf, size_t size)
 {
   errno = ENOSYS;
@@ -596,8 +612,8 @@ __getcwd (char *buf, size_t size)
 
 /* This is used by dl-tunables.c to strdup strings.  We can just make this a
    mere allocation.  */
-void *
-weak_function
+check_no_hidden(__sbrk);
+void *weak_function
 __sbrk (intptr_t increment)
 {
   vm_address_t addr;
@@ -605,8 +621,8 @@ __sbrk (intptr_t increment)
   return (void *) addr;
 }
 
-unsigned long int
-weak_function
+check_no_hidden(__strtoul_internal);
+unsigned long int weak_function
 __strtoul_internal (const char *nptr, char **endptr, int base, int group)
 {
   assert (base == 0 || base == 10);
@@ -619,6 +635,7 @@ __strtoul_internal (const char *nptr, char **endptr, int base, int group)
 strong_alias (__strtoul_internal, __GI___strtoul_internal)
 strong_alias (__strtoul_internal, __GI_____strtoul_internal)
 
+check_no_hidden(_exit);
 void weak_function attribute_hidden
 _exit (int status)
 {
@@ -639,6 +656,7 @@ strong_alias (_exit, __GI__exit)
 # define ABORT_INSTRUCTION
 #endif
 
+check_no_hidden(abort);
 void weak_function
 abort (void)
 {