From patchwork Sun Sep 24 15:59:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 817929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84897-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="E6xNi4yu"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y0X3B3QTwz9sRm for ; Mon, 25 Sep 2017 01:59:34 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=E5CioVb3g2Exj0c5g1+rFIkH7ubDuuey+mm0wEZJs4ZqvnZS3SOMr p8kvmTx/FNR7SuUhrML2REQCoL1JAfQwvqIF9+9qi181863lLwYENmYvO8edeoGR tQSla8azA801h1BZLkahIS1H9FIVWU+4mnCLTCGPuMrRm2ZiHaF3Xk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=HMIVKam49mJB+pQbqokAZULDpAU=; b=E6xNi4yuaM8/+3pV73qvRS1tpEEJ SFh0xriw799Z1VxX8vnCotSfV4lPMZNsJhjLKefA18WMDghlzSBAtpd8F2jlfWwl B5klsXqvkC+Oa5krVxUMtfdWTmuJASLv9bA0hCzNZhIoDkrJ9WXThWK/Iza/9C4E BITlKcj9qWx62iQ= Received: (qmail 1780 invoked by alias); 24 Sep 2017 15:59:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 1606 invoked by uid 89); 24 Sep 2017 15:59:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_NEUTRAL, URIBL_RED autolearn=ham version=3.3.2 spammy=Thibault, thibault, mere, vers X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [hurd, commited] hurd: Make sure dl-sysdep.c defines proper symbol names Date: Sun, 24 Sep 2017 17:59:18 +0200 Message-Id: <20170924155918.31118-1-samuel.thibault@ens-lyon.org> * 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. --- ChangeLog | 8 ++++++++ sysdeps/mach/hurd/dl-sysdep.c | 32 +++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e986689ade..7336c52c1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2017-09-24 Samuel Thibault + + * 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. + 2017-09-22 Joseph Myers * sysdeps/ieee754/flt-32/s_asinhf.c: Include . diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 8a8ac76efa..2cc342ec8e 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -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); void *weak_function __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) { @@ -514,6 +525,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) return (void *) 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,12 +564,14 @@ 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) { @@ -564,6 +579,7 @@ __access_noerrno (const char *file, int type) return -1; } +check_no_hidden(__getpid); pid_t weak_function __getpid (void) { @@ -587,8 +603,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; @@ -597,8 +613,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; @@ -606,8 +622,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); @@ -620,6 +636,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) { @@ -640,6 +657,7 @@ strong_alias (_exit, __GI__exit) # define ABORT_INSTRUCTION #endif +check_no_hidden(abort); void weak_function abort (void) {