From patchwork Thu Dec 12 18:16:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 181514 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp1119868och; Thu, 12 Dec 2019 10:18:44 -0800 (PST) X-Google-Smtp-Source: APXvYqzMgzltBD/7ZbStyxbcRbUqTVXtFHW1md0uC/G/9T2kME//RPkEt+/xJBn+Ma+m/GLCc40w X-Received: by 2002:a9d:61c4:: with SMTP id h4mr10084327otk.310.1576174724530; Thu, 12 Dec 2019 10:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576174724; cv=none; d=google.com; s=arc-20160816; b=rFNP54Z2+1HP9UbC7bsFofPA4EGvP4iu+ThkgRY4bzhIXlSEFgD4qKQoq89hUFN9WT 5GHSGlZNYXQgKN1ZwRuIxa5x/oB6eWWMJ7xWqesRoggQCZTicKCTl1bTNjDFNxTC3GIH ZnLiNwujHQXG4OBMd/xq4qUqnVr1r0rmVlTUjpoKU3wD2lWiU6ktWVqe90vjQhos++mp f5c3Wm5Kmz8ZXUBpb2mwILQIVmkjI//XncbU4z7k962E3nNJGKpTjCJa0CM7VRceWFO9 MAqhBTQD0oxmSJkhiSL9hJCO59u7gvRTCoPnCj4RQf3M7P1HxO4Rjhu4OCvkxZza9H60 Y5iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=RMfwFfyTPqhfWU0wUaSXXsmFcpAPwuyO6N+KjNHNQNs=; b=JXukpuL7w9jXYnE3Mrc4rA4ryqVsnBK4U7vzdOxbo6FpvIrGkIn4OdTlrycidLP2ho n/ITpQZ+FoRUh8Ql/bvSE6DHZEMxm3L75yStb1+lTbh/Cnap+QImx8rbZs9dVGhlIiQH Qsg8bszrHTJ9Yloyj8gAX3piznYkJhGqTvr/REigs3OnsiDhI0U2VljVKDoD5mLZuPJG WvpSpoAVlW08A7pPiCLBcEBUE1YJDCrjr6kSjAsBba7B7NZtYzSpkW8S4XzP3otKFhKX JVBhFLk2jmTa+iYnhgQho5Ikqf5NnCQIK1iaDOW0NojMQlYOVwlll+KTPVDyeMvAf4Hi SIGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=afucPnr3; dkim=pass header.i=@linaro.org header.s=google header.b=O5JUwCkK; spf=pass (google.com: domain of libc-alpha-return-108026-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-108026-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g10si3422882otn.12.2019.12.12.10.18.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Dec 2019 10:18:44 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-108026-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=afucPnr3; dkim=pass header.i=@linaro.org header.s=google header.b=O5JUwCkK; spf=pass (google.com: domain of libc-alpha-return-108026-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-108026-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=ceBnN1D0Ft6FjotLJK8jA4CkBwVITPR /oknnzX7xYlb85AcTeOVONt+3cvWkpfyKKnP+A7NNINrnOkRlCtjMw/CIY0xsbR1 wR36i9XOoq07cE+gw0P2l/qW9AU28/X51Rp/2cRELBlLlvRu4t7PAGhcowuQpnPj RGbHVagM63x4= 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:subject:date:message-id:in-reply-to :references; s=default; bh=ZvKI7zN2JGPsAIbGxiP5scMyjJ8=; b=afucP nr3YScJSCmAM16invkV0041d9Pq5XYspsdAAOLH4El+IKymO+4nGTy+72X9S84VK NGNUSYW4hopTl4sJfvOx5edHS+uXeXe42xgbrxYKQs48R+FPZT5GMoVIVjAwBNSH vSjWA15jbE6hZlG1uaz8RdcSb6tTP8xDal8qk8= Received: (qmail 47858 invoked by alias); 12 Dec 2019 18:16:57 -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 45940 invoked by uid 89); 12 Dec 2019 18:16:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=vers, csu X-HELO: mail-vk1-f174.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=RMfwFfyTPqhfWU0wUaSXXsmFcpAPwuyO6N+KjNHNQNs=; b=O5JUwCkKPYOs2FkG3y9Oh6aJ5FOrhypYTyNzt0ZRc8shD1vE4q2hDM5jrOVk+Kinc3 jtqsJ7VnpWG/l0BALIPAvqdbEkOk6FFOzqKZScOFUe0OIZTQOcEwfhR0IQvlamNglZNz VcvMBtwRo2RY+beraYWCQmdZ6uGijYgFsDxI94IWjpSAPbCVYgQeG/ai4b6+2eTfd5Do b48uCj7pRz8zaCPI+U8pjBsnYFRuvuL/IjVYCms0tfSJ0jElotcAARpWRCREUFMO0WNp f0/vPbqf59jDSrpl4nwz7z2EeEP977n1ZMU7vV27Zfl+4M1p7oL11Z+ETWNsDAnWMUPK YZlA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 07/12] elf: Move vDSO setup to rtld (BZ#24967) Date: Thu, 12 Dec 2019 15:16:09 -0300 Message-Id: <20191212181614.31782-7-adhemerval.zanella@linaro.org> In-Reply-To: <20191212181614.31782-1-adhemerval.zanella@linaro.org> References: <20191212181614.31782-1-adhemerval.zanella@linaro.org> Changes from previous version: - Simplified the patch by moving the HAVE_VSYSCALL removal refactor to its own patch. -- This patch moves the vDSO setup from libc to loader code, just after the vDSO link_map setup. For static case the initialization is moved to _dl_non_dynamic_init instead. Instead of using the mangled pointer, the vDSO data is set as attribute_relro (on _rtld_global_ro for shared or _dl_vdso_* for static). It is read-only even with partial relro. It also fixes BZ#24967 now that the vDSO pointer is setup earlier than malloc interposition is called. Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, s390x-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. I also run some tests on mips. --- csu/init-first.c | 4 - elf/dl-support.c | 7 ++ elf/rtld.c | 7 +- malloc/tst-interpose-aux.c | 5 ++ sysdeps/generic/dl-vdso-setup.c | 1 + sysdeps/generic/dl-vdso-setup.h | 28 ++++++ sysdeps/generic/dl-vdso.h | 30 +++++++ sysdeps/generic/ldsodefs.h | 6 ++ sysdeps/powerpc/powerpc32/backtrace.c | 16 ++-- sysdeps/powerpc/powerpc64/backtrace.c | 8 +- sysdeps/unix/sysv/linux/aarch64/Makefile | 1 - .../unix/sysv/linux/aarch64/gettimeofday.c | 5 +- sysdeps/unix/sysv/linux/arm/Makefile | 1 - sysdeps/unix/sysv/linux/dl-vdso-setup.c | 81 +++++++++++++++++ sysdeps/unix/sysv/linux/dl-vdso-setup.h | 55 ++++++++++++ sysdeps/unix/sysv/linux/dl-vdso.c | 48 ---------- sysdeps/unix/sysv/linux/dl-vdso.h | 30 ++++--- sysdeps/unix/sysv/linux/init-first.c | 90 ------------------- sysdeps/unix/sysv/linux/libc-vdso.h | 55 ------------ sysdeps/unix/sysv/linux/mips/Makefile | 2 - sysdeps/unix/sysv/linux/powerpc/Makefile | 1 - .../sysv/linux/powerpc/get_timebase_freq.c | 12 ++- .../unix/sysv/linux/powerpc/gettimeofday.c | 15 ++-- sysdeps/unix/sysv/linux/powerpc/init-first.c | 50 ----------- sysdeps/unix/sysv/linux/powerpc/libc-vdso.h | 10 --- sysdeps/unix/sysv/linux/powerpc/time.c | 17 ++-- sysdeps/unix/sysv/linux/riscv/Makefile | 4 - sysdeps/unix/sysv/linux/riscv/flush-icache.c | 2 +- sysdeps/unix/sysv/linux/s390/Makefile | 4 - sysdeps/unix/sysv/linux/sparc/Makefile | 4 - sysdeps/unix/sysv/linux/sysdep-vdso.h | 11 +-- sysdeps/unix/sysv/linux/x86/Makefile | 4 - sysdeps/unix/sysv/linux/x86/gettimeofday.c | 5 +- sysdeps/unix/sysv/linux/x86/time.c | 5 +- 34 files changed, 271 insertions(+), 353 deletions(-) create mode 100644 sysdeps/generic/dl-vdso-setup.c create mode 100644 sysdeps/generic/dl-vdso-setup.h create mode 100644 sysdeps/generic/dl-vdso.h create mode 100644 sysdeps/unix/sysv/linux/dl-vdso-setup.c create mode 100644 sysdeps/unix/sysv/linux/dl-vdso-setup.h delete mode 100644 sysdeps/unix/sysv/linux/dl-vdso.c delete mode 100644 sysdeps/unix/sysv/linux/init-first.c delete mode 100644 sysdeps/unix/sysv/linux/libc-vdso.h delete mode 100644 sysdeps/unix/sysv/linux/powerpc/init-first.c -- 2.17.1 diff --git a/csu/init-first.c b/csu/init-first.c index e0f489ee6d..891719a839 100644 --- a/csu/init-first.c +++ b/csu/init-first.c @@ -74,10 +74,6 @@ _init (int argc, char **argv, char **envp) _dl_non_dynamic_init (); #endif -#ifdef VDSO_SETUP - VDSO_SETUP (); -#endif - __init_misc (argc, argv, envp); /* Initialize ctype data. */ diff --git a/elf/dl-support.c b/elf/dl-support.c index b2b1b12f6f..81d44b0343 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include extern char *__progname; char **_dl_argv = &__progname; /* This is checked for some error messages. */ @@ -201,6 +203,8 @@ struct link_map *_dl_sysinfo_map; # include "get-dynamic-info.h" #endif #include "setup-vdso.h" +/* Define the vDSO function pointers. */ +#include /* During the program run we must not modify the global data of loaded shared object simultanously in two threads. Therefore we @@ -315,6 +319,9 @@ _dl_non_dynamic_init (void) so they can influence _dl_init_paths. */ setup_vdso (NULL, NULL); + /* With vDSO setup we can initialize the function pointers. */ + setup_vdso_pointers (); + /* Initialize the data structures for the search paths for shared objects. */ _dl_init_paths (getenv ("LD_LIBRARY_PATH")); diff --git a/elf/rtld.c b/elf/rtld.c index dd8fc5e6c6..a06e13c657 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include #include @@ -833,7 +835,7 @@ security_init (void) _dl_random = NULL; } -#include "setup-vdso.h" +#include /* The library search path. */ static const char *library_path attribute_relro; @@ -1538,6 +1540,9 @@ ERROR: '%s': cannot process note segment.\n", _dl_argv[0]); so they can influence _dl_init_paths. */ setup_vdso (main_map, &first_preload); + /* With vDSO setup we can initialize the function pointers. */ + setup_vdso_pointers (); + #ifdef DL_SYSDEP_OSCHECK DL_SYSDEP_OSCHECK (_dl_fatal_printf); #endif diff --git a/malloc/tst-interpose-aux.c b/malloc/tst-interpose-aux.c index bbe321e843..8cbc3e6fea 100644 --- a/malloc/tst-interpose-aux.c +++ b/malloc/tst-interpose-aux.c @@ -28,6 +28,7 @@ #include #include #include +#include #if INTERPOSE_THREADS #include @@ -96,6 +97,7 @@ struct __attribute__ ((aligned (__alignof__ (max_align_t)))) allocation_header { size_t allocation_index; size_t allocation_size; + struct timespec ts; }; /* Array of known allocations, to track invalid frees. */ @@ -166,6 +168,9 @@ malloc_internal (size_t size) .allocation_index = index, .allocation_size = allocation_size }; + /* BZ#24967: Check if calling a symbol which may use the vDSO does not fail. + The CLOCK_REALTIME should be supported on all systems. */ + clock_gettime (CLOCK_REALTIME, &allocations[index]->ts); return allocations[index] + 1; } diff --git a/sysdeps/generic/dl-vdso-setup.c b/sysdeps/generic/dl-vdso-setup.c new file mode 100644 index 0000000000..6e25b021ab --- /dev/null +++ b/sysdeps/generic/dl-vdso-setup.c @@ -0,0 +1 @@ +/* Empty. */ diff --git a/sysdeps/generic/dl-vdso-setup.h b/sysdeps/generic/dl-vdso-setup.h new file mode 100644 index 0000000000..3d79bae317 --- /dev/null +++ b/sysdeps/generic/dl-vdso-setup.h @@ -0,0 +1,28 @@ +/* ELF symbol initialization functions for VDSO objects. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_VDSO_INIT_H +#define _DL_VDSO_INIT_H + +/* Initialize the VDSO functions pointers. */ +static inline void __attribute__ ((always_inline)) +setup_vdso_pointers (void) +{ +} + +#endif diff --git a/sysdeps/generic/dl-vdso.h b/sysdeps/generic/dl-vdso.h new file mode 100644 index 0000000000..5651f49a1a --- /dev/null +++ b/sysdeps/generic/dl-vdso.h @@ -0,0 +1,30 @@ +/* ELF symbol resolve functions for VDSO objects. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_VDSO_H +#define _DL_VDSO_H 1 + +/* Function for resolving symbols in the VDSO link map. Return the + address of the vdso symbol NAME. */ +static inline void * +dl_vdso_vsym (const char *name) +{ + return NULL; +} + +#endif diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index fc25a81e1c..8cbd0e87cc 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -608,6 +608,12 @@ struct rtld_global_ro /* At startup time we set up the normal DSO data structure for it, and this points to it. */ EXTERN struct link_map *_dl_sysinfo_map; + +# define PROCINFO_DECL +# ifndef PROCINFO_CLASS +# define PROCINFO_CLASS EXTERN +# endif +# include #endif /* Mask for more hardware capabilities that are available on some diff --git a/sysdeps/powerpc/powerpc32/backtrace.c b/sysdeps/powerpc/powerpc32/backtrace.c index 2e6a859d9f..f2a57480a5 100644 --- a/sysdeps/powerpc/powerpc32/backtrace.c +++ b/sysdeps/powerpc/powerpc32/backtrace.c @@ -51,14 +51,14 @@ struct signal_frame_32 { /* We don't care about the rest, since IP value is at 'mctx' field. */ }; -static inline int +static inline bool is_sigtramp_address (void *nip) { #ifdef HAVE_SIGTRAMP_RT32 - if (nip == VDSO_SYMBOL (sigtramp32)) - return 1; + if (nip == GLRO (dl_vdso_sigtramp_32)) + return true; #endif - return 0; + return false; } struct rt_signal_frame_32 { @@ -68,14 +68,14 @@ struct rt_signal_frame_32 { /* We don't care about the rest, since IP value is at 'uc' field. */ }; -static inline int +static inline bool is_sigtramp_address_rt (void * nip) { #ifdef HAVE_SIGTRAMP_32 - if (nip == VDSO_SYMBOL (sigtramp_rt32)) - return 1; + if (nip == GLRO (dl_vdso_sigtramp_rt32)) + return true; #endif - return 0; + return false; } int diff --git a/sysdeps/powerpc/powerpc64/backtrace.c b/sysdeps/powerpc/powerpc64/backtrace.c index 234d9c00dc..8ed5bc1585 100644 --- a/sysdeps/powerpc/powerpc64/backtrace.c +++ b/sysdeps/powerpc/powerpc64/backtrace.c @@ -54,14 +54,14 @@ struct signal_frame_64 { /* We don't care about the rest, since the IP value is at 'uc' field. */ }; -static inline int +static inline bool is_sigtramp_address (void *nip) { #ifdef HAVE_SIGTRAMP_RT64 - if (nip == VDSO_SYMBOL (sigtramp_rt64)) - return 1; + if (nip == GLRO (dl_vdso_sigtramp_rt64)) + return true; #endif - return 0; + return false; } int diff --git a/sysdeps/unix/sysv/linux/aarch64/Makefile b/sysdeps/unix/sysv/linux/aarch64/Makefile index 57bbfeaac6..4bcae85bca 100644 --- a/sysdeps/unix/sysv/linux/aarch64/Makefile +++ b/sysdeps/unix/sysv/linux/aarch64/Makefile @@ -5,7 +5,6 @@ shared-only-routines += libc-__read_tp endif ifeq ($(subdir),elf) -sysdep_routines += dl-vdso sysdep-rtld-routines += __read_tp ifeq ($(build-shared),yes) # This is needed for DSO loading from static binaries. diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c index 07d38466e2..6475840117 100644 --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c @@ -38,12 +38,9 @@ __gettimeofday_vsyscall (struct timeval *restrict tv, void *restrict tz) } #ifdef SHARED -# include -# include - # define INIT_ARCH() libc_ifunc (__gettimeofday, - (get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) + (GLRO(dl_vdso_gettimeofday) ?: __gettimeofday_vsyscall)) #else diff --git a/sysdeps/unix/sysv/linux/arm/Makefile b/sysdeps/unix/sysv/linux/arm/Makefile index d7a2f6a8a7..abdf01f00c 100644 --- a/sysdeps/unix/sysv/linux/arm/Makefile +++ b/sysdeps/unix/sysv/linux/arm/Makefile @@ -1,5 +1,4 @@ ifeq ($(subdir),elf) -sysdep_routines += dl-vdso sysdep-rtld-routines += aeabi_read_tp libc-do-syscall endif diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.c b/sysdeps/unix/sysv/linux/dl-vdso-setup.c new file mode 100644 index 0000000000..1069879f1a --- /dev/null +++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.c @@ -0,0 +1,81 @@ +/* Data for vDSO support. Linux version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* This file is included in three different modes for both static (libc.a) + and shared (rtld) modes: + + 1. PROCINFO_DECL is defined, meaning we are only interested in + declarations. For static it requires use the extern keywork along with + the attribute_relro while for shared it will be embedded in the + rtld_global_ro. + + 2. PROCINFO_DECL and SHARED are not defined. Nothing to do, the default + zero initializion is suffice. + + 3. PROCINFO_DECL is not defined while SHARED is. Similar to 2., the zero + initialization of rtld_global_ro is suffice. */ + +#ifndef PROCINFO_CLASS +# define PROCINFO_CLASS +#endif + +#ifndef SHARED +# define RELRO attribute_relro +#else +# define RELRO +#endif + +#if defined PROCINFO_DECL || !defined SHARED +# ifdef HAVE_CLOCK_GETTIME_VSYSCALL +PROCINFO_CLASS int (*_dl_vdso_clock_gettime) (clockid_t, + struct timespec *) RELRO; +#endif +# ifdef HAVE_GETTIMEOFDAY_VSYSCALL +PROCINFO_CLASS int (*_dl_vdso_gettimeofday) (struct timeval *, void *) RELRO; +#endif +# ifdef HAVE_TIME_VSYSCALL +PROCINFO_CLASS time_t (*_dl_vdso_time) (time_t *) RELRO; +# endif +# ifdef HAVE_GETCPU_VSYSCALL +PROCINFO_CLASS int (*_dl_vdso_getcpu) (unsigned *, unsigned *, void *) RELRO; +# endif +# ifdef HAVE_CLOCK_GETRES_VSYSCALL +PROCINFO_CLASS int (*_dl_vdso_clock_getres) (clockid_t, + struct timespec *) RELRO; +# endif + +/* PowerPC specific ones. */ +# ifdef HAVE_GET_TBFREQ +PROCINFO_CLASS uint64_t (*_dl_vdso_get_tbfreq)(void) RELRO; +# endif +/* The sigtramp are used on powerpc backtrace without using + INLINE_VSYSCALL, so there is no need to set their type. */ +# ifdef HAVE_SIGTRAMP_RT64 +PROCINFO_CLASS void *_dl_vdso_sigtramp_rt64 RELRO; +# endif +# ifdef HAVE_SIGTRAMP_RT32 +PROCINFO_CLASS void *_dl_vdso_sigtramp_rt32 RELRO; +# endif +# ifdef HAVE_SIGTRAMP_32 +PROCINFO_CLASS void *_dl_vdso_sigtramp_32 RELRO; +# endif +#endif + +#undef RELRO +#undef PROCINFO_DECL +#undef PROCINFO_CLASS diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.h b/sysdeps/unix/sysv/linux/dl-vdso-setup.h new file mode 100644 index 0000000000..f4e76202fc --- /dev/null +++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.h @@ -0,0 +1,55 @@ +/* ELF symbol initialization functions for VDSO objects. Linux version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_VDSO_INIT_H +#define _DL_VDSO_INIT_H + +/* Initialize the VDSO functions pointers. */ +static inline void __attribute__ ((always_inline)) +setup_vdso_pointers (void) +{ +#ifdef HAVE_CLOCK_GETTIME_VSYSCALL + GLRO(dl_vdso_clock_gettime) = dl_vdso_vsym (HAVE_CLOCK_GETTIME_VSYSCALL); +#endif +#ifdef HAVE_GETTIMEOFDAY_VSYSCALL + GLRO(dl_vdso_gettimeofday) = dl_vdso_vsym (HAVE_GETTIMEOFDAY_VSYSCALL); +#endif +#ifdef HAVE_TIME_VSYSCALL + GLRO(dl_vdso_time) = dl_vdso_vsym (HAVE_TIME_VSYSCALL); +#endif +#ifdef HAVE_GETCPU_VSYSCALL + GLRO(dl_vdso_getcpu) = dl_vdso_vsym (HAVE_GETCPU_VSYSCALL); +#endif +#ifdef HAVE_CLOCK_GETRES_VSYSCALL + GLRO(dl_vdso_clock_getres) = dl_vdso_vsym (HAVE_CLOCK_GETRES_VSYSCALL); +#endif +#ifdef HAVE_GET_TBFREQ + GLRO(dl_vdso_get_tbfreq) = dl_vdso_vsym (HAVE_GET_TBFREQ); +#endif +#ifdef HAVE_SIGTRAMP_RT64 + GLRO(dl_vdso_sigtramp_rt64) = dl_vdso_vsym (HAVE_SIGTRAMP_RT64); +#endif +#ifdef HAVE_SIGTRAMP_RT32 + GLRO(dl_vdso_sigtramp_rt32) = dl_vdso_vsym (HAVE_SIGTRAMP_RT32); +#endif +#ifdef HAVE_SIGTRAMP_32 + GLRO(dl_vdso_sigtramp_32) = dl_vdso_vsym (HAVE_SIGTRAMP_32); +#endif +} + +#endif diff --git a/sysdeps/unix/sysv/linux/dl-vdso.c b/sysdeps/unix/sysv/linux/dl-vdso.c deleted file mode 100644 index 5577f2103c..0000000000 --- a/sysdeps/unix/sysv/linux/dl-vdso.c +++ /dev/null @@ -1,48 +0,0 @@ -/* ELF symbol resolve functions for VDSO objects. - Copyright (C) 2005-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include "config.h" -#include - - -void * -_dl_vdso_vsym (const char *name, const struct r_found_version *vers) -{ - struct link_map *map = GLRO (dl_sysinfo_map); - void *value = NULL; - - - if (map != NULL) - { - /* Use a WEAK REF so we don't error out if the symbol is not found. */ - ElfW (Sym) wsym; - memset (&wsym, 0, sizeof (ElfW (Sym))); - wsym.st_info = (unsigned char) ELFW (ST_INFO (STB_WEAK, STT_NOTYPE)); - - /* Search the scope of the vdso map. */ - const ElfW (Sym) *ref = &wsym; - lookup_t result = GLRO (dl_lookup_symbol_x) (name, map, &ref, - map->l_local_scope, - vers, 0, 0, NULL); - - if (ref != NULL) - value = DL_SYMBOL_ADDRESS (result, ref); - } - - return value; -} diff --git a/sysdeps/unix/sysv/linux/dl-vdso.h b/sysdeps/unix/sysv/linux/dl-vdso.h index 19ffd30c7e..d1e782b81f 100644 --- a/sysdeps/unix/sysv/linux/dl-vdso.h +++ b/sysdeps/unix/sysv/linux/dl-vdso.h @@ -22,11 +22,6 @@ #include #include -/* Functions for resolving symbols in the VDSO link map. */ -extern void *_dl_vdso_vsym (const char *name, - const struct r_found_version *version) - attribute_hidden; - /* If the architecture support vDSO it should define which is the expected kernel version and hash value through both VDSO_NAME and VDSO_HASH (usually defined at architecture sysdep.h). */ @@ -38,19 +33,26 @@ extern void *_dl_vdso_vsym (const char *name, # define VDSO_HASH 0 #endif +/* Functions for resolving symbols in the VDSO link map. */ static inline void * -get_vdso_symbol (const char *symbol) +dl_vdso_vsym (const char *name) { + struct link_map *map = GLRO (dl_sysinfo_map); + if (map == NULL) + return NULL; + + /* Use a WEAK REF so we don't error out if the symbol is not found. */ + ElfW (Sym) wsym = { 0 }; + wsym.st_info = (unsigned char) ELFW (ST_INFO (STB_WEAK, STT_NOTYPE)); + struct r_found_version rfv = { VDSO_NAME, VDSO_HASH, 1, NULL }; - return _dl_vdso_vsym (symbol, &rfv); -} -static inline void * -get_vdso_mangle_symbol (const char *symbol) -{ - void *vdsop = get_vdso_symbol (symbol); - PTR_MANGLE (vdsop); - return vdsop; + /* Search the scope of the vdso map. */ + const ElfW (Sym) *ref = &wsym; + lookup_t result = GLRO (dl_lookup_symbol_x) (name, map, &ref, + map->l_local_scope, + &rfv, 0, 0, NULL); + return ref != NULL ? DL_SYMBOL_ADDRESS (result, ref) : NULL; } #endif /* dl-vdso.h */ diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c deleted file mode 100644 index d005d13322..0000000000 --- a/sysdeps/unix/sysv/linux/init-first.c +++ /dev/null @@ -1,90 +0,0 @@ -/* vDSO internal symbols. Linux generic version. - Copyright (C) 2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -/* vDSO symbol used on clock_gettime implementation. */ -#ifdef HAVE_CLOCK_GETTIME_VSYSCALL -int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *) - attribute_hidden; -#endif -/* vDSO symbol used on clock_gettime64 implementation. */ -#ifdef HAVE_CLOCK_GETTIME64_VSYSCALL -int (*VDSO_SYMBOL(clock_gettime64)) (clockid_t, struct __timespec64 *) - attribute_hidden; -#endif -/* vDSO symbol used on clock_getres implementation. */ -#ifdef HAVE_CLOCK_GETRES_VSYSCALL -int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *) - attribute_hidden; -#endif -/* vDSO symbol used on gettimeofday implementation. */ -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL -int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *) - attribute_hidden; -#endif -/* vDSO symbol used on GNU extension getcpu implementation. */ -#ifdef HAVE_GETCPU_VSYSCALL -long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *) - attribute_hidden; -#endif -/* vDSO symbol used on time implementation. */ -#ifdef HAVE_TIME_VSYSCALL -time_t (*VDSO_SYMBOL(time)) (time_t *) attribute_hidden; -#endif - -static inline void -__libc_vdso_platform_setup (void) -{ -#ifdef HAVE_CLOCK_GETTIME_VSYSCALL - VDSO_SYMBOL(clock_gettime) - = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME_VSYSCALL); -#endif - -#ifdef HAVE_CLOCK_GETTIME64_VSYSCALL - VDSO_SYMBOL(clock_gettime64) - = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME64_VSYSCALL); -#endif - -#ifdef HAVE_CLOCK_GETRES_VSYSCALL - VDSO_SYMBOL(clock_getres) - = get_vdso_mangle_symbol (HAVE_CLOCK_GETRES_VSYSCALL); -#endif - -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL - VDSO_SYMBOL(gettimeofday) - = get_vdso_mangle_symbol (HAVE_GETTIMEOFDAY_VSYSCALL); -#endif - -#ifdef HAVE_GETCPU_VSYSCALL - VDSO_SYMBOL(getcpu) = get_vdso_mangle_symbol (HAVE_GETCPU_VSYSCALL); -#endif - -#ifdef HAVE_TIME_VSYSCALL - VDSO_SYMBOL(time) = get_vdso_mangle_symbol (HAVE_TIME_VSYSCALL); -#endif - -#ifdef VDSO_SETUP_ARCH - VDSO_SETUP_ARCH (); -#endif -} - -#define VDSO_SETUP __libc_vdso_platform_setup - -#include diff --git a/sysdeps/unix/sysv/linux/libc-vdso.h b/sysdeps/unix/sysv/linux/libc-vdso.h deleted file mode 100644 index c6d505bab3..0000000000 --- a/sysdeps/unix/sysv/linux/libc-vdso.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2009-2019 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#ifndef _LIBC_VDSO_H -#define _LIBC_VDSO_H - -#define VDSO_SYMBOL(__name) __vdso_##__name - -/* Adjust the return IFUNC value from a vDSO symbol accordingly required - by the ELFv1 ABI. It is used by the architecture to create an ODP - entry since the kernel vDSO does not provide it. */ -#ifndef VDSO_IFUNC_RET -# define VDSO_IFUNC_RET(__value) (__value) -#endif - -#ifdef HAVE_CLOCK_GETTIME_VSYSCALL -extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *) - attribute_hidden; -#endif -#ifdef HAVE_CLOCK_GETTIME64_VSYSCALL -extern int (*VDSO_SYMBOL(clock_gettime64)) (clockid_t, struct __timespec64 *) - attribute_hidden; -#endif -#ifdef HAVE_CLOCK_GETRES_VSYSCALL -extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *) - attribute_hidden; -#endif -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL -extern int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *) - attribute_hidden; -#endif -#ifdef HAVE_GETCPU_VSYSCALL -extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *) - attribute_hidden; -#endif -#ifdef HAVE_TIME_VSYSCALL -extern time_t (*VDSO_SYMBOL(time)) (time_t *) attribute_hidden; -#endif - -#endif /* _LIBC_VDSO_H */ diff --git a/sysdeps/unix/sysv/linux/mips/Makefile b/sysdeps/unix/sysv/linux/mips/Makefile index 03044e7365..026ba242cf 100644 --- a/sysdeps/unix/sysv/linux/mips/Makefile +++ b/sysdeps/unix/sysv/linux/mips/Makefile @@ -60,8 +60,6 @@ ifeq ($(subdir),elf) ifeq ($(build-shared),yes) # This is needed for DSO loading from static binaries. sysdep-dl-routines += dl-static - -sysdep_routines += dl-vdso endif # If the compiler doesn't use GNU.stack note, # this test is expected to fail. diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile index 1596238afa..cc2f804d86 100644 --- a/sysdeps/unix/sysv/linux/powerpc/Makefile +++ b/sysdeps/unix/sysv/linux/powerpc/Makefile @@ -13,7 +13,6 @@ gen-as-const-headers += ucontext_i.sym endif ifeq ($(subdir),elf) -sysdep_routines += dl-vdso ifeq ($(build-shared),yes) # This is needed for DSO loading from static binaries. sysdep-dl-routines += dl-static diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c index 32b9ab5da5..d4afd488f4 100644 --- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c +++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c @@ -21,7 +21,7 @@ #include #include -#include +#include static uint64_t get_timebase_freq_fallback (void) @@ -101,11 +101,9 @@ uint64_t __get_timebase_freq (void) { /* The vDSO does not have a fallback mechanism (such calling a syscall). */ - __typeof (VDSO_SYMBOL (get_tbfreq)) vdsop = VDSO_SYMBOL (get_tbfreq); - PTR_DEMANGLE (vdsop); - if (vdsop == NULL) - return get_timebase_freq_fallback (); - - return INTERNAL_VSYSCALL_CALL_TYPE (vdsop, uint64_t, 0); + uint64_t (*vdsop) (void) = GLRO(dl_vdso_get_tbfreq); + if (vdsop != NULL) + return INTERNAL_VSYSCALL_CALL_TYPE (vdsop, uint64_t, 0); + return get_timebase_freq_fallback (); } weak_alias (__get_timebase_freq, __ppc_get_timebase_freq) diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c index 1982b1e025..061fa66746 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -18,6 +18,7 @@ #include #include #include +#include static int __gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) @@ -31,17 +32,11 @@ __gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) } #ifdef SHARED -# include -# include - -# define INIT_ARCH() \ - void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) - +# define INIT_ARCH() /* If the vDSO is not available we fall back syscall. */ -libc_ifunc (__gettimeofday, - vdso_gettimeofday - ? VDSO_IFUNC_RET (vdso_gettimeofday) - : (void *) __gettimeofday_syscall); +libc_ifunc (__gettimeofday, GLRO(dl_vdso_gettimeofday) + ? VDSO_IFUNC_RET (GLRO(dl_vdso_gettimeofday)) + : (void *) __gettimeofday_syscall); #else int __gettimeofday (struct timeval *restrict tv, void *restrict tz) diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.c b/sysdeps/unix/sysv/linux/powerpc/init-first.c deleted file mode 100644 index 92a4af83af..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/init-first.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Initialization code run first thing by the ELF startup code. Linux/PowerPC. - Copyright (C) 2007-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void) attribute_hidden; -#if defined(__PPC64__) || defined(__powerpc64__) -void *VDSO_SYMBOL(sigtramp_rt64) attribute_hidden; -#else -void *VDSO_SYMBOL(sigtramp32) attribute_hidden; -void *VDSO_SYMBOL(sigtramp_rt32) attribute_hidden; -#endif - -static inline void -__libc_vdso_platform_setup_arch (void) -{ - VDSO_SYMBOL (get_tbfreq) = get_vdso_mangle_symbol (HAVE_GET_TBFREQ); - - /* PPC64 uses only one signal trampoline symbol, while PPC32 will use - two depending if SA_SIGINFO is used (__kernel_sigtramp_rt32) or not - (__kernel_sigtramp32). - There is no need to pointer mangle these symbol because they will - used only for pointer comparison. */ -#if defined(__PPC64__) || defined(__powerpc64__) - VDSO_SYMBOL(sigtramp_rt64) = get_vdso_symbol (HAVE_SIGTRAMP_RT64); -#else - VDSO_SYMBOL(sigtramp32) = get_vdso_symbol (HAVE_SIGTRAMP_32); - VDSO_SYMBOL(sigtramp_rt32) = get_vdso_symbol (HAVE_SIGTRAMP_RT32); -#endif -} - -#define VDSO_SETUP_ARCH __libc_vdso_platform_setup_arch - -#include diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h index cb7da3b289..adc06d48b0 100644 --- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h +++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h @@ -54,14 +54,4 @@ # define VDSO_IFUNC_RET(value) ((void *) (value)) #endif -#include_next - -extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void); -#if defined(__PPC64__) || defined(__powerpc64__) -extern void *VDSO_SYMBOL(sigtramp_rt64); -#else -extern void *VDSO_SYMBOL(sigtramp32); -extern void *VDSO_SYMBOL(sigtramp_rt32); -#endif - #endif /* _LIBC_VDSO_H */ diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c index 2059097c0a..4f90604e6a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/time.c +++ b/sysdeps/unix/sysv/linux/powerpc/time.c @@ -19,6 +19,7 @@ #include #include #include +#include static time_t time_vsyscall (time_t *t) @@ -30,18 +31,12 @@ time_vsyscall (time_t *t) } #ifdef SHARED -# include -# include - -# define INIT_ARCH() \ - void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL); - +#undef INIT_ARCH +#define INIT_ARCH() /* If the vDSO is not available we fall back to the syscall. */ -libc_ifunc (time, - vdso_time - ? VDSO_IFUNC_RET (vdso_time) - : (void *) time_vsyscall); - +libc_ifunc (time, GLRO(dl_vdso_time) + ? VDSO_IFUNC_RET (GLRO(dl_vdso_time)) + : (void *) time_vsyscall) #else time_t time (time_t *t) diff --git a/sysdeps/unix/sysv/linux/riscv/Makefile b/sysdeps/unix/sysv/linux/riscv/Makefile index b7ad31885c..301b082398 100644 --- a/sysdeps/unix/sysv/linux/riscv/Makefile +++ b/sysdeps/unix/sysv/linux/riscv/Makefile @@ -1,7 +1,3 @@ -ifeq ($(subdir),elf) -sysdep_routines += dl-vdso -endif - ifeq ($(subdir),misc) sysdep_headers += sys/cachectl.h sysdep_routines += flush-icache diff --git a/sysdeps/unix/sysv/linux/riscv/flush-icache.c b/sysdeps/unix/sysv/linux/riscv/flush-icache.c index c5bd60d9c2..e967e40deb 100644 --- a/sysdeps/unix/sysv/linux/riscv/flush-icache.c +++ b/sysdeps/unix/sysv/linux/riscv/flush-icache.c @@ -38,7 +38,7 @@ __riscv_flush_icache_syscall (void *start, void *end, unsigned long int flags) static func_type __lookup_riscv_flush_icache (void) { - func_type func = get_vdso_symbol ("__vdso_flush_icache"); + func_type func = dl_vdso_vsym ("__vdso_flush_icache"); /* If there is no vDSO entry then call the system call directly. All Linux versions provide the vDSO entry, but QEMU's user-mode emulation doesn't diff --git a/sysdeps/unix/sysv/linux/s390/Makefile b/sysdeps/unix/sysv/linux/s390/Makefile index 77f38523b5..d9db1b5422 100644 --- a/sysdeps/unix/sysv/linux/s390/Makefile +++ b/sysdeps/unix/sysv/linux/s390/Makefile @@ -11,10 +11,6 @@ ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext_i.sym endif -ifeq ($(subdir),elf) -sysdep_routines += dl-vdso -endif - ifeq ($(subdir),nptl) libpthread-sysdep_routines += elision-lock elision-unlock elision-timed \ elision-trylock diff --git a/sysdeps/unix/sysv/linux/sparc/Makefile b/sysdeps/unix/sysv/linux/sparc/Makefile index fb3ee5b8a1..b0d182a439 100644 --- a/sysdeps/unix/sysv/linux/sparc/Makefile +++ b/sysdeps/unix/sysv/linux/sparc/Makefile @@ -7,10 +7,6 @@ librt-routines += rt-sysdep librt-shared-only-routines += rt-sysdep endif -ifeq ($(subdir),elf) -sysdep_routines += dl-vdso -endif - ifeq ($(subdir),sysvipc) sysdep_routines += getshmlba endif diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h index 04525340a5..76c46bea8a 100644 --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h @@ -19,22 +19,19 @@ #ifndef SYSDEP_VDSO_LINUX_H # define SYSDEP_VDSO_LINUX_H -#include +#include /* Return the errno value as a negative value in case of an error or 0 or positive value otherwise. */ #ifndef INTERNAL_VSYSCALL_CALL -# define INTERNAL_VSYSCALL_CALL(funcptr, nr, args...) \ - funcptr (args) +# define INTERNAL_VSYSCALL_CALL(funcptr, nr, args...) \ + funcptr (args) #endif -#include - #define INLINE_VSYSCALL(name, nr, args...) \ ({ \ long int sc_ret = -1; \ - __typeof (__vdso_##name) vdsop = __vdso_##name; \ - PTR_DEMANGLE (vdsop); \ + __typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name); \ if (vdsop != NULL) \ { \ sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \ diff --git a/sysdeps/unix/sysv/linux/x86/Makefile b/sysdeps/unix/sysv/linux/x86/Makefile index 02ca36c6d2..b23b532590 100644 --- a/sysdeps/unix/sysv/linux/x86/Makefile +++ b/sysdeps/unix/sysv/linux/x86/Makefile @@ -20,10 +20,6 @@ CFLAGS-elision-timed.c += -mrtm CFLAGS-elision-trylock.c += -mrtm endif -ifeq ($(subdir),elf) -sysdep_routines += dl-vdso -endif - ifeq ($(subdir),setjmp) tests += tst-saved_mask-1 endif diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c index 909575a7e3..f7579ac924 100644 --- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/x86/gettimeofday.c @@ -32,13 +32,10 @@ __gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) } #ifdef SHARED -# include -# include - # define INIT_ARCH() /* If the vDSO is not available we fall back to syscall. */ libc_ifunc (__gettimeofday, - (get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) + (GLRO(dl_vdso_gettimeofday) ?: __gettimeofday_syscall)); #else diff --git a/sysdeps/unix/sysv/linux/x86/time.c b/sysdeps/unix/sysv/linux/x86/time.c index 0aee73826b..c65f2d5d54 100644 --- a/sysdeps/unix/sysv/linux/x86/time.c +++ b/sysdeps/unix/sysv/linux/x86/time.c @@ -30,13 +30,10 @@ time_vsyscall (time_t *t) } #ifdef SHARED -# include -# include - #undef INIT_ARCH #define INIT_ARCH() /* If the vDSO is not available we fall back on the syscall. */ -libc_ifunc (time, (get_vdso_symbol ("__vdso_time") ?: time_vsyscall)) +libc_ifunc (time, (GLRO(dl_vdso_time) ?: time_vsyscall)) #else time_t time (time_t *t)