From patchwork Fri Nov 29 21:03:21 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: 180498 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2089312ile; Fri, 29 Nov 2019 13:03:49 -0800 (PST) X-Google-Smtp-Source: APXvYqw8AWA45SByZwe3D+Tvrn2HgnXhASlzTDW3qDCGjnZiRobFYwu6VfujX3DgO7tGRr20V8XT X-Received: by 2002:a50:fc18:: with SMTP id i24mr47879142edr.41.1575061429590; Fri, 29 Nov 2019 13:03:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575061429; cv=none; d=google.com; s=arc-20160816; b=NtBjO9azgM34BTWg8ptUm8ltBFTDFGjblp6cGIY5qWeUH1rXcKEXoDJV05ZHFnECu5 DfbDM5H0nSW4HStKnngIoo4K1lDpEZ9RXB26Q4w/1kJkM7D0PesXAEgoU+L7pgGa7qfL IlT1jsIhyE84B5CBBJxNDB9dKgG3UcPW8peTV0YGm2WZxv2XJv3c8OUqd1y2uSoIFfd/ uD6B9Mer3B2pBlk6KaF6BGf5OEtRlG1mc4ie1SHUiDCCtH1UzMBmbUubc8KcR3+CGIjd 5fw+ZrYtRLYuIQ2kDQQzYZLnRiu2DFt9nhlBhmDE0CC/SzUNSaWFtyoI2hXoNRlMe04x s7Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=rNb6y5m3qVziyKlL95pfTR5PeeAkYgvzhkDZqICtrtw=; b=WZ/YraOJczOa92MDSOGq35FjC/y2THAijDubVgCbcnjV21GHQiey1fHQ3dX3XUlmAG VT+e7KKTXZ5xSQ7GfvCTivmPMRhhbj5CBevNJpIW3x1VBjygFhgtibpQbV4n/BFhmUvh GhK/hc3p3BeKruPdtIGP/SZsDo+Ej6zAMSB4nF9EVQ32NKJLsql4SaRbuBwWf4yQOiXI V09msdmQ/FV3jvFWLU3ysHSIUOC8zV4FJDIwzeC2eTJVw1Hl4EfpgnSv5V+AehRl/MlQ rThnRzQwk0jz0d4KcO+c1+m0PT/UxnO2gjlBpe9W1gFInn4TNCQfyAx2tNmQXqo0lmUH PypQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="KIks/5pU"; dkim=pass header.i=@linaro.org header.s=google header.b=fPN5BtRW; spf=pass (google.com: domain of libc-alpha-return-107558-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107558-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 d12si4487554edr.279.2019.11.29.13.03.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 13:03:49 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-107558-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="KIks/5pU"; dkim=pass header.i=@linaro.org header.s=google header.b=fPN5BtRW; spf=pass (google.com: domain of libc-alpha-return-107558-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107558-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; q=dns; s= default; b=yrWM8GkJeTBlF0goKDcynmsCzAPNTfmhog0jeOcc554YfS+BKPH57 JTBocyDdGWyqJle8N5F0MAwl63E3LbG3VCAjUMMBjc2sqNXKiv1UKmn3XPVJrI3g VEZyKkcPC5jtRjH1BhTK1cC2IRHU/Q/52PTlYmaUFM1Xuk3u/UEcD4= 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; s=default; bh=sMvjZb+mxemBS5nKwuxSVJLd9xU=; b=KIks/5pU8+baPN0QNnNkXg1o+xHG m/m5/9Gx672PmY4IYLFevzEOrUn2QM6oeXi4SGZ1+H7nY73CHxZ2m9/ZmcEDDP3/ RXA0gARaW3P15buX9JoSptu78LrWGTbi3J69mDbqtR9Esl0T1uRIVdxLLliFojRo +fNcoR3dZKJ5TDk= Received: (qmail 71588 invoked by alias); 29 Nov 2019 21:03:38 -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 71580 invoked by uid 89); 29 Nov 2019 21:03:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:single_, sk:SINGLE_, affects, HX-Spam-Relays-External:209.85.222.196 X-HELO: mail-qk1-f196.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=rNb6y5m3qVziyKlL95pfTR5PeeAkYgvzhkDZqICtrtw=; b=fPN5BtRWFxIaIuGaKpMDopvZKSQoGv0ppUYYPbEYuolJT9jBGTLHd38zfkmQEoBGCi YgwBVYng9ozow2T3WBEjxP9McQPXSLxJ9A4mzHXP9eGPfR1sXc6kDOj81GLRv0qEsFM2 ki3GR6OYh/ASKH+8uu4OjXUgjD8jTHpY+5UxRPThdZPh0cFEfrXlXH0aqsXRwVQmqyqi MsejwRS3zN+Sq0WUXhtNYg23tHjNfO6PVpxBmrsIPaa+d3on2y+QYi7cfMGtLx/CUgwn vAkXPBpaXHrNwtMA1uLdmaNOGjeCSbU+35OClVjrtmX3JMyRneQZlgzGCyCKdEJWxlOR 0YAg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/7] linux: Update x86 vDSO symbols Date: Fri, 29 Nov 2019 18:03:21 -0300 Message-Id: <20191129210327.26434-1-adhemerval.zanella@linaro.org> Add the missing time and clock_getres vDSO symbol names on x86. For time, the iFUNC already uses expected name so it affects only the static build. The clock_getres is a new implementation added on Linux 5.3 (f66501dc53e72). Checked on x86-linux-gnu and i686-linux-gnu. --- sysdeps/unix/sysv/linux/i386/sysdep.h | 2 ++ sysdeps/unix/sysv/linux/x86_64/sysdep.h | 2 ++ 2 files changed, 4 insertions(+) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 7066ddc214..b2e750d490 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -315,6 +315,8 @@ struct libc_do_syscall_args /* List of system calls which are supported as vsyscalls. */ # define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +# define HAVE_TIME_VSYSCALL "__vdso_time" +# define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" /* Define a macro which expands inline into the wrapper code for a system call. This use is for internal calls that do not need to handle errors diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index 475b7d991a..965fd4b851 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -376,7 +376,9 @@ /* List of system calls which are supported as vsyscalls. */ # define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +# define HAVE_TIME_VSYSCALL "__vdso_time" # define HAVE_GETCPU_VSYSCALL "__vdso_getcpu" +# define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" # define SINGLE_THREAD_BY_GLOBAL 1 From patchwork Fri Nov 29 21:03:22 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: 180499 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2089529ile; Fri, 29 Nov 2019 13:03:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwTYfFwGSfIAEJWvytcyslPCbXrS41ghFzpU1EHMZgZEsKoaUn6sa2+zW12kFyUdCfgKDFp X-Received: by 2002:a17:906:770b:: with SMTP id q11mr1859245ejm.311.1575061438943; Fri, 29 Nov 2019 13:03:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575061438; cv=none; d=google.com; s=arc-20160816; b=k+SAjJR9j1zYs5DSBoj8TX/sAJNvpf8lTCZ7SeEVBsXWHMmYcS/hsUplI4/qw77b7h 9XebhdRuHl/KoURmthq/H5gMj29+me9/DF5HAyraarf269R88DbtDnUH8x0ZzsTA2pW2 C/J5RAKucSAwMEVaoDLFxbvnMXauk7iliol7nJAYP3H5cb5isGeTkYeuzJj/uMSMsOCf erEd5AN9L/hlu78nWzCPca0KoUSGTI4nk178jHQaZ1bqcl96Lk+mvrf1ew04Idbh722H e/m8mH6RxwjAhy15PAMqEXWMUfQeJZSZD3qy4stNH7snLK3ZYH/gjuivUguFOGkkEA/x ZBgw== 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=HJitG/Yd3dwei1YJX7OtRpoYVMl5njknGvKo52X6Du8=; b=jQ5f/xqtPja8vH8C73ejV5WX/hEuAok8qt7pwItGKAMiAe1xS1o5u28MOipgsZzJPL uREwLPnbYbqE4rL+EZCH37zZae409DmwM8FbyB30dAN5qetp167MgDs83rTXtGL5wAOg HA+L8ydbz82Y/gcUq88NPynE3ykSOwmBT0hl5wMoPTheYC4ZCUPIzRof+tN3eFP/M70D 55trm5pfRz91vqEKBvTjZ7A12zB9pv9jAxrC21nkEgzgLqikfdPU0MZpgVy0eVbwPH5+ f6Ghr+nqPhOlu9fskdR2TcFt+1DFFt+/ASPFvuHtjo2ME2JS7i0uf0XjAq2RZyu1AmSx RGzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=N3b+zgqI; dkim=pass header.i=@linaro.org header.s=google header.b=vORGLT6f; spf=pass (google.com: domain of libc-alpha-return-107559-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107559-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 dk8si1562989ejb.101.2019.11.29.13.03.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 13:03:58 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-107559-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=N3b+zgqI; dkim=pass header.i=@linaro.org header.s=google header.b=vORGLT6f; spf=pass (google.com: domain of libc-alpha-return-107559-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107559-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=skTX0tcR4pEOt0dvEEZQiAr2GjnCDiu IbkiC+Bdg9o5V+B4sTpuAPntIszrhesvrSiVlIpJNfkgcQQo3sQja28q3MBzRbpv w2+7zH+xTEbt+uRW65SFfQjObpFd6w3EWRZftdzerrzFn10mjLsuxX3reGS5Ec3E hiHGpKNkjSEo= 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=I159XlNrbSjcjxW9KzAX3DViluw=; b=N3b+z gqIx3c1a29ECh8SwRVcIqf4BtIQNxDUtwHTJH4Ts9JvTpfI7kHVRGdVJrZL9jHLO qI4hFFcBzF0WGVmD67hC5On/F74tHuBBFf4l3bQBJ0CgIm92Wlszz5YowUrbrJ1X FeLlAg6cc1pBSKi5HUcgb7SwKRSFJLakU9AjBo= Received: (qmail 71695 invoked by alias); 29 Nov 2019 21:03:39 -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 71612 invoked by uid 89); 29 Nov 2019 21:03:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=EXTRA, HX-Languages-Length:796 X-HELO: mail-qk1-f195.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=HJitG/Yd3dwei1YJX7OtRpoYVMl5njknGvKo52X6Du8=; b=vORGLT6fZx+LbzJakS6IyOdKVnqhqFoK+2YpZUqRCrnQq5T4RJ73JZLVeqyUgTH0PL CC49JYg7HizUXmKOKImSY8cKyRKMhCm5mFtXQkSm1Whq041lvhXAABzVdZfslPb15k3X E4PgsuN0nuV1AZfwTmM3y/8FZUYNHUEx7xnJUlE/sWqnlzqAZt2ocXWEry2WekBTWlUi WXfEvGE2HeDm0kNSgWckA8AObSlILbO6ApXNyPifYf43zQtJH08C3PPV/ZKpMJVfKhvS wjXR5EFZsTAd+++KU/s+wynjsKFiypfkvngzOUq4IdeeHFcv8hQ6bJg5UH1mt1b4BjkL oxrA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/7] x86: Make x32 use x86 time implementation Date: Fri, 29 Nov 2019 18:03:22 -0300 Message-Id: <20191129210327.26434-2-adhemerval.zanella@linaro.org> In-Reply-To: <20191129210327.26434-1-adhemerval.zanella@linaro.org> References: <20191129210327.26434-1-adhemerval.zanella@linaro.org> This is the only use of auto-generation syscall which uses a vDSO plus IFUNC and the current x86 generic implementation already covers the expected semantic. Checked on x86_64-linux-gnu-x32. --- sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list | 1 - 1 file changed, 1 deletion(-) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list index 786c884232..58ea31d1fd 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list @@ -2,4 +2,3 @@ personality EXTRA personality Ei:i __personality personality posix_fadvise64 - fadvise64 Vi:iiii posix_fadvise posix_fadvise64 -time - time:__vdso_time@LINUX_2.6 Ei:P time From patchwork Fri Nov 29 21:03:23 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: 180500 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2089695ile; Fri, 29 Nov 2019 13:04:07 -0800 (PST) X-Google-Smtp-Source: APXvYqxE0B3qouwrO/5vZjt0pXFp15FwtedaefU/MvZf6NiXAfo/ZlGHQNMlrmBjn2oAERESqhJE X-Received: by 2002:aa7:d842:: with SMTP id f2mr47422214eds.262.1575061447447; Fri, 29 Nov 2019 13:04:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575061447; cv=none; d=google.com; s=arc-20160816; b=YtJD7Y71qyRJzXPCzkX8af+2khjy2DHsXwTfCT2MS5WX9YkrwYw0T6chBGcOcVGCuB ujY3fcTxnxpcVdtX5qKSEqSKE4QIG7kqIT/phPfnRn0Mv9JxkX9KDL473u0pcsGZNZQ/ 1TqcL80BaIKEaoV8S/CEEzJ0bsCVLRHoAFNQrdNqN8U+W28A4bQJp8vUSfFTZRq3j+XO DHgjTxcIn2CG2pZlmohEI3YD9z4QM6e0VvU5ApOD+I3f1K/3HhW4uABxJm8F2WskoPAA UgXths8oyuGrWdv2g6UeXWzxi9UgwE/7tt7FsKsbnE5Qb7ZbY6rDetGmgqFSt50sEdVh ToFA== 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=/PPOy1QeIiEGrmkgdyk5lGihZwQHH2uEiyFV+yKC27I=; b=LoXQGXUkn4W/GNtwxDQ5eOlFFlUPhUMaCRw5ZHA/42rI95sRt38LKW4Ow20PR0sx+t rCl0vWhdLSAn0qi5pxn2hFYHfpSsvwY2u2yQOKWJW159xWDv8Zxz0rsA2mghnHOWmK7f 94qMYbAzRphzUxJdlJhfPcyogVjOpL7NxNDzBgikxNcOgXzjm/qJUQGpwhvH4OVJYUcE VgfcO8ZINjnJAD60M3lnh193dU6HxeTVWRwavVwAnJacRBoKA1jZ1J0GkYG9FGsD9+XJ loSm0LG6h8kvPAn9WGM70Io4S6CPDX/dpYSMGHklVoMsjUoudFQMU2HUpWw3VbSX4Mh9 5N5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=mffRfENG; dkim=pass header.i=@linaro.org header.s=google header.b=ncborhC5; spf=pass (google.com: domain of libc-alpha-return-107560-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107560-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 pg2si15077965ejb.216.2019.11.29.13.04.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 13:04:07 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-107560-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=mffRfENG; dkim=pass header.i=@linaro.org header.s=google header.b=ncborhC5; spf=pass (google.com: domain of libc-alpha-return-107560-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107560-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=pAdWuPcZRGRUU6GC9SuB3QLljclsOvb I+NLEnFgtkPsCvq3c3K/HGetS3eYgY/5i1rH5mFFGNMTxuC6EvpICTu3YL2mL/6x F+GqE+vtWj4jyAwp5vsCbVJRfeuqaoWf/t4LlQ6j3WN7Ayy4zCInP/N4VFT/DUpI ZQw3QXciAWU0= 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=b8xzT2il0Vuz9LoW9kT/+FRr8o0=; b=mffRf ENGIVIWQXBGo3/vACg3Q0AqGWVgD+A+8JpANIIcr2/s0gQfDsRuM48qR1KDVZc81 8ZI4uvavHTVvQrxT5MjGqCEHWgwTRmpwa98wkQGn2OFaryiLLiK63di60gSoyAM5 u2V4tLRDwnvzeExgulK0esTUaYgHFJ6rmRIBl0= Received: (qmail 72005 invoked by alias); 29 Nov 2019 21:03:41 -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 71957 invoked by uid 89); 29 Nov 2019 21:03:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=eof, HX-Spam-Relays-External:209.85.222.194, H*RU:209.85.222.194, o X-HELO: mail-qk1-f194.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=/PPOy1QeIiEGrmkgdyk5lGihZwQHH2uEiyFV+yKC27I=; b=ncborhC5LzBHo82lah5hwlTH+ggf78TGRbu3CHDneDynhdO0QFW5qzmDhFNR6Cu702 2tTGYKBeyC1KRgjF6HgXA76b688x4Eoo3c/pin1eTtQL+XZqLIR+Lu7v4wEvAm4USAM8 rVUJwCkOiBOSo7a/6jGRZBNZMTdw+kPsjHi7NzL8ewF5/X6bv2dbrbp2fVRXtaFQnoba 2zUmGGdvHoEerLTgDWZvZ1vZxPUX01o2EBu3nkUhc3yhxMcl3ti8wUNmZ/6O5+ADBw19 Jbs7+ByJ3w0Uf8eGLVLWWYU72+CdOl16w8ItGbJYBhMc48B6AdPLpZ/STijT7CoYNhUk P4Aw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/7] Remove vDSO support from make-syscall.sh Date: Fri, 29 Nov 2019 18:03:23 -0300 Message-Id: <20191129210327.26434-3-adhemerval.zanella@linaro.org> In-Reply-To: <20191129210327.26434-1-adhemerval.zanella@linaro.org> References: <20191129210327.26434-1-adhemerval.zanella@linaro.org> Currenty there is no usage of the vDSO, itt requires sync the auto-generated C file with current glibc implementation, it still uses still uses symbol redirections hacks where libc-symbols.h provide macros (for instance libc_ifunc_redirected), and it does not handle all required compiler handling (inhibit_stack_protector on resolver for instance). Checked with a build against all major ABIs. --- sysdeps/unix/make-syscalls.sh | 45 +---------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) -- 2.17.1 diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh index fe24bbc78f..c07626677f 100644 --- a/sysdeps/unix/make-syscalls.sh +++ b/sysdeps/unix/make-syscalls.sh @@ -149,14 +149,6 @@ emit_weak_aliases() echo "$calls" | while read file srcfile caller syscall args strong weak; do - vdso_syscall= - case x"$syscall" in - *:*@*) - vdso_syscall="${syscall#*:}" - syscall="${syscall%:*}" - ;; - esac - case x"$syscall" in x-) callnum=_ ;; *) @@ -233,10 +225,9 @@ while read file srcfile caller syscall args strong weak; do if test $shared_only = t; then # The versioned symbols are only in the shared library. echo "shared-only-routines += $file" - test -n "$vdso_syscall" || echo "\$(objpfx)${file}.os: \\" + echo "\$(objpfx)${file}.os: \\" else object_suffixes='$(object-suffixes)' - test -z "$vdso_syscall" || object_suffixes='$(object-suffixes-noshared)' echo "\ \$(foreach p,\$(sysd-rules-targets),\ \$(foreach o,${object_suffixes},\$(objpfx)\$(patsubst %,\$p,$file)\$o)): \\" @@ -268,40 +259,6 @@ while read file srcfile caller syscall args strong weak; do echo ' ) | $(compile-syscall) '"\ \$(foreach p,\$(patsubst %$file,%,\$(basename \$(@F))),\$(\$(p)CPPFLAGS))" - if test -n "$vdso_syscall"; then - # In the shared library, we're going to emit an IFUNC using a vDSO function. - # $vdso_syscall looks like "name@KERNEL_X.Y" where "name" is the symbol - # name in the vDSO and KERNEL_X.Y is its symbol version. - vdso_symbol="${vdso_syscall%@*}" - vdso_symver="${vdso_syscall#*@}" - vdso_symver=`echo "$vdso_symver" | sed 's/\./_/g'` - cat <'; \\ - echo '#undef ${strong}'; \\ - echo '#define vdso_ifunc_init()'; \\ - echo '__ifunc (__redirect_${strong}, ${strong},'; \\ - echo ' get_vdso_symbol ("${vdso_symbol}"), void,'; \\ - echo ' vdso_ifunc_init)'; \\ -EOF - # This is doing "hidden_def (${strong})", but the compiler - # doesn't know that we've defined ${strong} in the same file, so - # we can't do it the normal way. - cat < X-Patchwork-Id: 180501 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2089861ile; Fri, 29 Nov 2019 13:04:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwOUECmgZd0e29SoCye/0VvYEvENJjsMjI6wZkAfIhAiTKk58lEjVYitATigyTbXrPLAtC4 X-Received: by 2002:a17:906:da1d:: with SMTP id fi29mr7434523ejb.205.1575061455772; Fri, 29 Nov 2019 13:04:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575061455; cv=none; d=google.com; s=arc-20160816; b=AnMjPwKWacFU+SgUwYhpvoQPC1bSVw8/7YeUOti6eS4QZ5MyJsP9Ese1tiZX3cvxVd vUK3392wG/cdlneWWQv5djo7yIqpetIFxL4ptEmxoB7yEp7QocwrPcaH5itYcQQHQF4/ 5nqWEnZQ5sOFvsYDsZTEZjvBu+qdkr2CSMdwIOyVwTV423BDxvaPSCJ93HHixJOMvc1I XWwqvA0EXbj3ZTLfB+dA4IvO83S4qPWVo/r1soXHDzWg6m+p1VfuZIjDHFm5RF4yM7lR rNG30SSdNVV+pA8lYlwQdnDkDKhbcBH9eiL+1sWvxKe3l4ZkAbnwnpfG9T6hQ9ctWlkV OH0Q== 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=laE1kw2Ha54oP+5XsbAUFvfw9qAOg2Z0YjWh6b4B2/s=; b=W1YPzGn0URtRJrum8lEjJsICgkOlTybO0Vd3hPvm/M6toNrBO4T+XNasXcZcr7oMtf ywchEVQb/+OB9xS8IcZW8zIOx9MNYT+3OOgwTgbtHLrvlgvs2YhKCBu4/1Oh0/OpTZdu 6SnCXdE53xsrg+d2Wcj+0qD/yHx74tEykNG39fm5Mp8ftIki5sdbeG5cPxpL3vu1EzB+ reDLeSooXrs12I5qUuUYU0AgMiSb0UtOGTmRt1RIZ+EyDpTtToV15JIG3bWsJEFRdw2b oGGhWTf/iomP0zDi8uXjcx+zFdS1Z3PieGZx51iBcsPM1YwyczmYu4jdZlQ28EbTHYFZ xHfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=OkFfuGyu; dkim=pass header.i=@linaro.org header.s=google header.b=hmgb9FXN; spf=pass (google.com: domain of libc-alpha-return-107561-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107561-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 h26si1079485ejb.268.2019.11.29.13.04.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 13:04:15 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-107561-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=OkFfuGyu; dkim=pass header.i=@linaro.org header.s=google header.b=hmgb9FXN; spf=pass (google.com: domain of libc-alpha-return-107561-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107561-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=pFTPJm+Urc89dEZPXYdrdMtKPSzndCW ynY/xSEP4/EkjQHgC9KFY0F665xWdKIOBMvMMiJ7FMAJfAyzUogezwuY7UhqJWIn VFnnYB6qN+eoNE7LQ+9xTVp8Ef1NZyJQG28Z7/6tiilPF8KZWmCmaMEQuAjNJaNT /K6HpOxP4JXA= 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=EANbpQxFaolOP6eISzQhUqO2IW4=; b=OkFfu Gyur0nE/2g2XiwMQN8mSurY+TNi4RybznmQxVOLj5144bcypObcgCIBQ1og91vZm Lj9YHb1E30nw3SrgqsWSm70R47WjmtyEHWL/6ZfBj/y/taZKTjhleXFsotxNWqie XbaxGU33lHtBxsnUxQ54hlaUZa3kRZrdAWtaqQ= Received: (qmail 72179 invoked by alias); 29 Nov 2019 21:03:42 -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 72120 invoked by uid 89); 29 Nov 2019 21:03:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f196.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=laE1kw2Ha54oP+5XsbAUFvfw9qAOg2Z0YjWh6b4B2/s=; b=hmgb9FXNpFmPcJDMia3fAVxMRHCpKfxRtNiesHaXkuZ9urWsrhMXa0qrFjGc5sYTnY P0ZwD1uub+bB7+3DSVGwOLZFuLdRwgKKbTrXwRrDLVqFZDaYphqJdMUP/7P57Vekq8mL cduKJnJjVDLYAS+8U6tynDUAtidGc92EsOZDr2b4Cm4MnW+ctQapRUAoyXmgR3T+v4H9 CW3ww+cEsRo0rAODpsn9nyHJFCXUQWrPN7NP6BgcebHURGrpIq872I8PxnSxVIRyj2V5 Q3gHA2+5D7wjjfwinUCz/WhJBPrEWhPG/jqcRuphzkeFFU8Zc87yh3sSW9XMLLW0KpGy FxWw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 4/7] linux: Update mips vDSO symbols Date: Fri, 29 Nov 2019 18:03:24 -0300 Message-Id: <20191129210327.26434-4-adhemerval.zanella@linaro.org> In-Reply-To: <20191129210327.26434-1-adhemerval.zanella@linaro.org> References: <20191129210327.26434-1-adhemerval.zanella@linaro.org> The clock_getres is a new implementation added on Linux 5.4 (abed3d826f2f). Checked with a build against mips-linux-gnu and mips64-linux-gnu. --- sysdeps/unix/sysv/linux/mips/sysdep.h | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h index 82a3cf9f3d..47c0333621 100644 --- a/sysdeps/unix/sysv/linux/mips/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/sysdep.h @@ -22,6 +22,7 @@ /* List of system calls which are supported as vsyscalls. */ #define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" #define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +#define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" #ifndef __ASSEMBLER__ From patchwork Fri Nov 29 21:03:25 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: 180502 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2090092ile; Fri, 29 Nov 2019 13:04:25 -0800 (PST) X-Google-Smtp-Source: APXvYqynWncqu3hDVjdjsNA78nZrCZJAYKiqkPYPqD3S2HAGnk6xAj0epQEI/lirsxVILskEh/G/ X-Received: by 2002:a17:906:7042:: with SMTP id r2mr63126069ejj.166.1575061465363; Fri, 29 Nov 2019 13:04:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575061465; cv=none; d=google.com; s=arc-20160816; b=AKtP/lxo2E1PGp+Q+XqRp3bYD0nIaWz92tRpFuwhMnsa961kJEt5xq1JJ/ysl5MXdo MAwEZdxTq9NlQSoRJVumSUDLNNSz0fkoPYFRHWX74EmyhiN5uLrJQK4bNPJQRI5cYhbp WZU+vVN10lavQEZK+jPhvDzWmIhe7nKhIifVz5x6+ImUUd5tqurGLSI7aeWtEjuBTdKl AUz/an8tK4asyBZOVPLd9wtYZ2HEnC4y2nx+MzDZEQNqFYCrRMu/bq7/qe46W0lZW+fd gJAdNad69rW6jNhjrleACr/kcoh0rLr85cOV/Jkq1fQECaOyA85nbywsd630uwxLKBo4 9OZg== 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=uZ7ljY/tPkpsfNmkSLtnbeMdTkZ8/CcTaqA/754S96I=; b=mgMJ7MhDa9iUE4nX8jDA9TeZ9KA3pWQp3H8Vk45cRfg+X6d8SpIGNraCMnth4/64hN jtMZuxLqeH7eBTC7tY0M5Gff5/N7WUM2gaWUt5MamnlvahbeVK3w8DqcKVTzAEd7PMAd qn+5g451hLbxP5QgUb+P7p+lOEV7e/dh7OCR+sWmwqBrJoqICEPUuQs9GDsbVWx3RuLj Pbr8HPra7Ci4qKr4hRZm2aSj+l7fcZw90hNE+tlRy7OyKzVl0fxPDM2Q/ICTCOXFJDNE kvSxJpfuENeiKzLJswArwQhqnviS605m5pIfOlpWDjJ/yLmdB0jiszQZ9T2a99R6KXYu I4Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=yFlFTJIk; dkim=pass header.i=@linaro.org header.s=google header.b="T/qG1jGa"; spf=pass (google.com: domain of libc-alpha-return-107562-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107562-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 d18si3572489eds.125.2019.11.29.13.04.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 13:04:25 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-107562-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=yFlFTJIk; dkim=pass header.i=@linaro.org header.s=google header.b="T/qG1jGa"; spf=pass (google.com: domain of libc-alpha-return-107562-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107562-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=NLjA5+U/wA1tiey/rvYyoADsE98w6Ws imJ3yTb8ZZhj3ai8NJMSBsFwDhpO76/mu6ngnc3zAmdEUEb2QLcp46x++0w/ikJ6 zz3eNiAp2vEb9EGOxBjzyWYT+9e1KhsDUVandWHou8ZQLnR43uE9k0QT6HzloAf2 8tG3q5mo6NU4= 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=Nb7wWiSgRFg9wVn/2EZoscFtwg0=; b=yFlFT JIkU2YkPayRo+Jy8Kv1Y+5fDlifrh72G4afmkjBrHUCluwglLHFQicXKWF+bSuh4 UdiyE8W4X+4MJ5qbnnINyTd+wKJ/woKaGMCzBzpHeVb3EhLT6XG96MVBHe/sDP9f FCpCieaK/BgTj6/W3tdxC+TJW+VNs3ZrOxXfBk= Received: (qmail 72392 invoked by alias); 29 Nov 2019 21:03:44 -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 72334 invoked by uid 89); 29 Nov 2019 21:03:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:sparc64 X-HELO: mail-qk1-f195.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=uZ7ljY/tPkpsfNmkSLtnbeMdTkZ8/CcTaqA/754S96I=; b=T/qG1jGaDm1rpRD6rX9fMr0FRuCwXewIEnSnanmw8jJe0qXWmA+Pt1LnQoyL2a87on 8nIgEIOFJiTTffWkDKTc/DhTWC/hUCUK0QPossAMKK35zlTViLVTZfAnwXFKsIkDEz1e vTm/HLX9BR2LtLwXGBMXhOhR7OjzVOv5iOw7sEMsPK+R++vXa7xEcZx2BOBRKN/nF4Qo 7h3LCRH9Wja1EFDlLLacb07q8VzV4XHROkdwPs/V3MumG8LQnitc9Rfj/7UnApZ+eGiN 4DoJ0VmNbdo/5UXumSvakSnq5LkFHhxa/bAhA2IKdDfAgZBFWpdc6XxwldEIF6VLofED PU4A== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 5/7] elf: Enable relro for static build Date: Fri, 29 Nov 2019 18:03:25 -0300 Message-Id: <20191129210327.26434-5-adhemerval.zanella@linaro.org> In-Reply-To: <20191129210327.26434-1-adhemerval.zanella@linaro.org> References: <20191129210327.26434-1-adhemerval.zanella@linaro.org> The code is similar to the one at rtld.c, where its check for the PT_GNU_RELRO header values from program headers and call _dl_protected_relro with the updated l_relro_{addr,size} values. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, aarch64-linux-gnu, s390x-linux-gnu, and sparc64-linux-gnu. --- elf/dl-support.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/elf/dl-support.c b/elf/dl-support.c index 5526d5ee6e..bdb5c2ae91 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -367,14 +367,24 @@ _dl_non_dynamic_init (void) if (_dl_platform != NULL) _dl_platformlen = strlen (_dl_platform); - /* Scan for a program header telling us the stack is nonexecutable. */ if (_dl_phdr != NULL) - for (uint_fast16_t i = 0; i < _dl_phnum; ++i) - if (_dl_phdr[i].p_type == PT_GNU_STACK) + for (const ElfW(Phdr) *ph = _dl_phdr; ph < &_dl_phdr[_dl_phnum]; ++ph) + switch (ph->p_type) { - _dl_stack_flags = _dl_phdr[i].p_flags; + /* Check if the stack is nonexecutable. */ + case PT_GNU_STACK: + _dl_stack_flags = ph->p_flags; + break; + + case PT_GNU_RELRO: + _dl_main_map.l_relro_addr = ph->p_vaddr; + _dl_main_map.l_relro_size = ph->p_memsz; break; } + + /* Setup relro on the binary itself. */ + if (_dl_main_map.l_relro_size) + _dl_protect_relro (&_dl_main_map); } #ifdef DL_SYSINFO_IMPLEMENTATION From patchwork Fri Nov 29 21:03:26 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: 180503 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2090256ile; Fri, 29 Nov 2019 13:04:34 -0800 (PST) X-Google-Smtp-Source: APXvYqxhJx03/+PTxuOm0pZQCAigBKdrW/6p0JBr0djOPhAJ5XNBWBJQBzmQfZHi7pcUBy1Qg1Pt X-Received: by 2002:adf:fe90:: with SMTP id l16mr7669333wrr.265.1575061473933; Fri, 29 Nov 2019 13:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575061473; cv=none; d=google.com; s=arc-20160816; b=BqS2q3knDJbiDmolrW95sxCDz6xFFeVVszl5Dva8WAgntg2X7ShpDGf1nK3uXj0tb0 8rlzB8KPsVTnVOFAXZxRciE5aLLRlFmr098S7ofR8njXT+jA26Bob71VnBWzmF7akP4/ g093XEXRxyXBwE2ut3aMOHCAYyFoCLv4p7GM1ogFepkyuILxxLE9a/hHuq+g94gvGbpx 4BMyLVYN1rNxzsQ/jrMOc4IwapBTYYV7SHZv66itm0GsbT41KUoSO1TrsnNWryl2Ix90 6foVOiwBmIrGW58lYehLxqPlStQGwxrooYysUbF0Zn5ykicdW8440QFrkHWYamFGwqXp eiAg== 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=AoknaBNUfQvthFfltK6DaxloWZwoEpJbBhDCmjeSwKM=; b=BSgMNw4yZlaRmA/IKGkOJCIyxGuN8BNyeKmBnpW7Axk2sSbeAEcg/EC9dHvLsJrcqH 2hfxzgMBXYFE9hc7PlrvlQ0wehy9v2oED5+Xd5YAm+lY+iOdWnlu6e6/fhIQylab02NE 86Wn88c5/aFQpaoX8JOngmP9pVZ1pU1x+yPU6aiwOKZ2PLuNcIJxWhboKJs/NMj7dUXk 8n7xeU5KjUG7FTsMG5qMNvF+DBSude+bVTVLD8Cq49dXNwxTnOk8EtpEwziWYqlSwHSh Uo+WmAM6p19z7XDK9owRK7xxW3WSDBMubNVd/rIQutre0PiBsASmpWflGecpED69sHkO sm7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lBww4oDn; dkim=pass header.i=@linaro.org header.s=google header.b=oOTA9qU+; spf=pass (google.com: domain of libc-alpha-return-107563-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107563-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 b19si16926858edb.40.2019.11.29.13.04.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 13:04:33 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-107563-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=lBww4oDn; dkim=pass header.i=@linaro.org header.s=google header.b=oOTA9qU+; spf=pass (google.com: domain of libc-alpha-return-107563-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107563-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=oFhFasT1D0ZgJjFUEhNd7iqP8TnSZwH odPRLQU3XzMtwUlJGaOfqj9hWRr5mJfu5ALaOdQI/tLyWx5RvHMCK1o5iuSRodqp 9nAZd1TisKZHxf/yhlVOOVt1dHtg4efu2WRblHQOi5IbGfHG6+nx9xiBBjjX8VVo 0ivIrUbxi1+g= 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=1wQ9FUeT/c92spl5J2mCM35vAV4=; b=lBww4 oDn7ejioSm53aqxe8fPZ4yOUXty2yeOGoNdX6XmWoXspdX46Kih7B7iiZGKPnXvR IhY7JrbeLu7g90vxVEj9+T8OSysk0II1np9ynzCYyQ/wMHyo1+nsbACcGeQtKkYx McqwRGREVFjwSQNMtzhONfVy18p9b9vuhCaBpA= Received: (qmail 72629 invoked by alias); 29 Nov 2019 21:03:45 -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 72574 invoked by uid 89); 29 Nov 2019 21:03:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f180.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=AoknaBNUfQvthFfltK6DaxloWZwoEpJbBhDCmjeSwKM=; b=oOTA9qU+p2PAPVnYXpVY66AmszOvRXoTKXvCo/1nYx/dPapB2nAJef91FDo4nOkP3Z EjD4+ztRiqEarpooco2iVhgjhdDdTAqRD5by6yZId9dNnQh8RW4LOijT1gtW38ln878o dX83F80KjMJT5Za59jBqNvQEEO/Y4stbGCLzrKcJkEVo3BbVHin8mk6QCFxRI313YMi6 5K9c9BoQI3fgiUUJk71Qz55doOabaZ3UJqVP/68qO9yoJ0yTEaawKaknhi4xVWEhL+rc u1U4YaO2FaBXq0zCXDC/GbsYjKjA2lsh3Jt8ZGfVkS3MrYNUfMJurINqjWKmtL7o3yIi tdpw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 6/7] linux: Refactor sched_getcpu in terms of getcpu Date: Fri, 29 Nov 2019 18:03:26 -0300 Message-Id: <20191129210327.26434-6-adhemerval.zanella@linaro.org> In-Reply-To: <20191129210327.26434-1-adhemerval.zanella@linaro.org> References: <20191129210327.26434-1-adhemerval.zanella@linaro.org> Checked on x86_64-linux-gnu. --- sysdeps/unix/sysv/linux/sched_getcpu.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c index 65dd9fdda7..3646c8b713 100644 --- a/sysdeps/unix/sysv/linux/sched_getcpu.c +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c @@ -17,23 +17,11 @@ #include #include -#include - -#ifdef HAVE_GETCPU_VSYSCALL -# define HAVE_VSYSCALL -#endif -#include int sched_getcpu (void) { -#ifdef __NR_getcpu unsigned int cpu; - int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL); - + int r = __getcpu (&cpu, NULL); return r == -1 ? r : cpu; -#else - __set_errno (ENOSYS); - return -1; -#endif } From patchwork Fri Nov 29 21:03:27 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: 180504 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2090562ile; Fri, 29 Nov 2019 13:04:46 -0800 (PST) X-Google-Smtp-Source: APXvYqwNd3zGrcGBGFLihsurtHl3593z36PrBkLFvAa31ryI3ZyqHLCMelUc+vAAunEF0eBkxREt X-Received: by 2002:aa7:d294:: with SMTP id w20mr41218856edq.134.1575061486541; Fri, 29 Nov 2019 13:04:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575061486; cv=none; d=google.com; s=arc-20160816; b=FIIj7ypR4Nd4UGz1Ot+othvwelffX1qO35QOPYiiWQqoGXpr1GytSq7PND28eAGbEi zJjO/tugjKG9ENmxwfzRigixNM3fi4FTxYd1tP/92Qv49sq2DMPOjcImy2C4dAOC/AlY 7s9XGa9xzX34X7jpNdHa8qgPaXsaw3oCQ6daRC4fPVkThIMoVdHNFzpZNOZ7scYEWxdb 8fJisGg3M5uHp9U41iFT17VwN2f84xUCt9PNj9DoWTD7EQiUNo6+790XPvuLNCiHGazG RLYQyCJ0V3yZG4vQ7DqIG+MdwPlf9GWNloG1EPqM6sR/BIWRDSQOE4xdqS0na3c87OXg r/IQ== 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=Tujw0rECX8FKvhK+KoUa8+N5nLF498jO5S2JD2vzggI=; b=rxcnuUR+IdcZM+k8XNVvRfAwVrJttSvEoQi9PHV0jRR/8xta+wHTiQSVk5qtk9nPOs T54OuWHHfLwI6JtoLjkijLiH8VPGmSNwTuit6rBSNu7nIAz4C/BzymfpB0RfTo3T7Ish 7VT8URV4QlXIkiT9T2B21TXV6Qn20tS257a4xZGGDht4IQivRysZ0R3vskiQzSWS+M8l wNMj299LJREAb9re8jH1FQgag8kAo0bJzMdz8PCI4r3MPADcHpMh+iQQStFns3TiTkJ1 hQl3gBmT51az1GsCBU9U4Ux0RTrJZ3jVrRqbLhDx2IM1HweU50zIS9mrmQFwiHSyzdfF c0tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=D7cWwGsm; dkim=pass header.i=@linaro.org header.s=google header.b=mOaGiU8n; spf=pass (google.com: domain of libc-alpha-return-107564-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107564-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 cm9si2022780edb.250.2019.11.29.13.04.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 13:04:46 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-107564-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=D7cWwGsm; dkim=pass header.i=@linaro.org header.s=google header.b=mOaGiU8n; spf=pass (google.com: domain of libc-alpha-return-107564-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107564-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=pMPVDJFuVMKiD0BCNVXkzhkT0vZDFC9 Rusnpbk5POyKo03G7h2wN6/0uB213dDe9fUy3mrf3lDgk5m7SLPjtJW6dYy4aDsY 3BnSxiLKvh+IJazw9uSyv23Uwhmq0wKaUsYkqZVs32fVKXAQLGE5TtY6JV2l2yWq BSuE9SBm54OI= 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=QCTPGSBZGRQH53Ww/DXMKGjcXAk=; b=D7cWw GsmuOmiPFAWs6f5SofhQEQpNwqCUw1H6LzlV0b95pZ5HqIuGb0fXteIzlve6jsKD VXNjMte9mlixo/qWoPadXxm4lXXPRtqQh1Lq0eizkBypBt8shk99PQOZaWYwc4Bv fntsjTwddKPFDStgkeJWisgv6tM/UyB4ROfkJM= Received: (qmail 73955 invoked by alias); 29 Nov 2019 21:03:56 -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 73877 invoked by uid 89); 29 Nov 2019 21:03:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 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=nip, REF, 3017, ppc64 X-HELO: mail-qk1-f177.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=Tujw0rECX8FKvhK+KoUa8+N5nLF498jO5S2JD2vzggI=; b=mOaGiU8n8U/YKXOmKZDAyrmR83/hwqdqOJ146RgT2DS5L5RItLFKGbE3GG6pIapC22 ftuULK/BH8WueEWce6++McxI4Zth9GaLMdb3Hpb5v6pVZg2cYj4C1YXLxpQKdh8nwcSn DfWJSMHz1hv+8CgfDMwPDZuYJ00KX+fIAKlrbpFYzJt9lq9wOzleIgIrZyIwkJtrdVy6 c0lzEQ/UY3dLMjDsf+dyr91RIlMnMcHCcFxaIU+a+Q6WJF/KovykvTDMwQzYszXxNbj2 1gvaYIvIUYOVuWNkLZpGuRvZ3dGMKJNv1vDpJisNkPqim5Z9ur5W9NlNvpPVDEghLTfz wUwQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 7/7] elf: Move vDSO setup to rtld Date: Fri, 29 Nov 2019 18:03:27 -0300 Message-Id: <20191129210327.26434-7-adhemerval.zanella@linaro.org> In-Reply-To: <20191129210327.26434-1-adhemerval.zanella@linaro.org> References: <20191129210327.26434-1-adhemerval.zanella@linaro.org> 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). The macro INLINE_VSYSCALL is also simplified to avoid need to define HAVE_VSYSCALL before including sysdep-vdso (which also avoid not use the vDSO in case of a missing include). The macro is now expected to be called inside the HAVE_*_VSYSCALL and it does not fallback to call syscall for an error. Also, calling the INLINE_VSYSCALL macro with vDSO name not define in the architecture sysdeps will trigger a build error. Internally it is also simplified to expected an negative value with errno embedded similar on how the Linux syscall work. It simplifies the error handling. 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, however the system does not support neither vDSO nor relro. --- 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 | 14 ++-- sysdeps/unix/sysv/linux/arm/Makefile | 1 - sysdeps/unix/sysv/linux/clock_getres.c | 27 ++++--- sysdeps/unix/sysv/linux/clock_gettime.c | 14 ++-- sysdeps/unix/sysv/linux/dl-vdso-setup.c | 77 ++++++++++++++++++ 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/getcpu.c | 16 ++-- sysdeps/unix/sysv/linux/init-first.c | 80 ------------------- sysdeps/unix/sysv/linux/libc-vdso.h | 51 ------------ sysdeps/unix/sysv/linux/mips/Makefile | 2 - sysdeps/unix/sysv/linux/mips/sysdep.h | 16 ---- sysdeps/unix/sysv/linux/powerpc/Makefile | 1 - .../sysv/linux/powerpc/get_timebase_freq.c | 13 ++- .../unix/sysv/linux/powerpc/gettimeofday.c | 24 +++--- sysdeps/unix/sysv/linux/powerpc/init-first.c | 50 ------------ sysdeps/unix/sysv/linux/powerpc/libc-vdso.h | 10 --- .../sysv/linux/powerpc/powerpc32/sysdep.h | 10 ++- .../sysv/linux/powerpc/powerpc64/sysdep.h | 10 ++- sysdeps/unix/sysv/linux/powerpc/time.c | 26 +++--- 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/sparc/sysdep.h | 7 -- sysdeps/unix/sysv/linux/sysdep-vdso.h | 80 +++++-------------- sysdeps/unix/sysv/linux/x86/Makefile | 4 - sysdeps/unix/sysv/linux/x86/gettimeofday.c | 14 ++-- sysdeps/unix/sysv/linux/x86/time.c | 14 ++-- 41 files changed, 344 insertions(+), 477 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 bdb5c2ae91..e719fefdbe 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 e22c7560c9..5510627717 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 9737780136..27f638a713 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -601,6 +601,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 7e772e05ce..a4e793c375 100644 --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c @@ -22,10 +22,6 @@ #include #include - -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL -# define HAVE_VSYSCALL -#endif #include /* Used as a fallback in the ifunc resolver if VDSO is not available @@ -36,16 +32,16 @@ __gettimeofday_vsyscall (struct timeval *restrict tv, void *restrict tz) if (__glibc_unlikely (tz != 0)) memset (tz, 0, sizeof *tz); - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + int ret = INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + if (ret != -1) + return ret; + return INLINE_SYSCALL_CALL (gettimeofday, tv, 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/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c index 9497f78787..4aecd5a173 100644 --- a/sysdeps/unix/sysv/linux/clock_getres.c +++ b/sysdeps/unix/sysv/linux/clock_getres.c @@ -20,36 +20,40 @@ #include #include -#ifdef HAVE_CLOCK_GETRES_VSYSCALL -# define HAVE_VSYSCALL -#endif #include -#include #include /* Get resolution of clock. */ int __clock_getres64 (clockid_t clock_id, struct __timespec64 *res) { + int ret = -1; #ifdef __ASSUME_TIME64_SYSCALLS # ifndef __NR_clock_getres_time64 - return INLINE_VSYSCALL (clock_getres, 2, clock_id, res); +# ifdef HAVE_CLOCK_GETRES_VSYSCALL + ret = INLINE_VSYSCALL (clock_getres, 2, clock_id, res); +# endif + if (ret == -1) + ret = INLINE_SYSCALL (clock_getres, 2, clock_id, res); # else - return INLINE_SYSCALL (clock_getres_time64, 2, clock_id, res); + ret = INLINE_SYSCALL (clock_getres_time64, 2, clock_id, res); # endif #else # ifdef __NR_clock_getres_time64 - int ret = INLINE_SYSCALL (clock_getres_time64, 2, clock_id, res); + ret = INLINE_SYSCALL (clock_getres_time64, 2, clock_id, res); if (ret == 0 || errno != ENOSYS) return ret; # endif struct timespec ts32; - int retval = INLINE_VSYSCALL (clock_getres, 2, clock_id, &ts32); - if (! retval && res) +# ifdef HAVE_CLOCK_GETRES_VSYSCALL + ret = INLINE_VSYSCALL (clock_getres, 2, clock_id, &ts32); +# endif + if (ret == -1) + ret = INLINE_SYSCALL (clock_getres, 2, clock_id, &ts32); + if (ret == 0 && res) *res = valid_timespec_to_timespec64 (ts32); - - return retval; #endif + return ret; } #if __TIMESIZE != 64 @@ -67,6 +71,7 @@ __clock_getres (clockid_t clock_id, struct timespec *res) } #endif +#include versioned_symbol (libc, __clock_getres, clock_getres, GLIBC_2_17); /* clock_getres moved to libc in version 2.17; old binaries may expect the symbol version it had in librt. */ diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c index ca40983f6c..6b5b3e4179 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -20,22 +20,22 @@ #include #include #include "kernel-posix-cpu-timers.h" - -#ifdef HAVE_CLOCK_GETTIME_VSYSCALL -# define HAVE_VSYSCALL -#endif #include -#include - /* Get current value of CLOCK and store it in TP. */ int __clock_gettime (clockid_t clock_id, struct timespec *tp) { - return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); +#ifdef HAVE_CLOCK_GETTIME_VSYSCALL + int ret = INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); + if (ret != -1) + return ret; +#endif + return INLINE_SYSCALL_CALL (clock_gettime, clock_id, tp); } libc_hidden_def (__clock_gettime) +#include versioned_symbol (libc, __clock_gettime, clock_gettime, GLIBC_2_17); /* clock_gettime moved to libc in version 2.17; old binaries may expect the symbol version it had in librt. */ 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..7035e094ae --- /dev/null +++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.c @@ -0,0 +1,77 @@ +/* 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 void *_dl_vdso_clock_gettime RELRO; +#endif +# ifdef HAVE_GETTIMEOFDAY_VSYSCALL +PROCINFO_CLASS void *_dl_vdso_gettimeofday RELRO; +#endif +# ifdef HAVE_TIME_VSYSCALL +PROCINFO_CLASS void *_dl_vdso_time RELRO; +# endif +# ifdef HAVE_GETCPU_VSYSCALL +PROCINFO_CLASS void *_dl_vdso_getcpu_kernel RELRO; +# endif +# ifdef HAVE_CLOCK_GETRES_VSYSCALL +PROCINFO_CLASS void *_dl_vdso_clock_getres RELRO; +# endif + +/* PowerPC specific ones. */ +# ifdef HAVE_GET_TBFREQ +PROCINFO_CLASS void *_dl_vdso_get_tbfreq RELRO; +# endif +# 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..9d0457ef16 --- /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_kernel) = 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/getcpu.c b/sysdeps/unix/sysv/linux/getcpu.c index fdd27203af..77c15080a5 100644 --- a/sysdeps/unix/sysv/linux/getcpu.c +++ b/sysdeps/unix/sysv/linux/getcpu.c @@ -18,21 +18,19 @@ #include #include #include - -#ifdef HAVE_GETCPU_VSYSCALL -# define HAVE_VSYSCALL -#endif #include +int getcpu_kernel (unsigned *cpu, unsigned *node, void *tcache); + int __getcpu (unsigned int *cpu, unsigned int *node) { -#ifdef __NR_getcpu - return INLINE_VSYSCALL (getcpu, 3, cpu, node, NULL); -#else - __set_errno (ENOSYS); - return -1; +#ifdef HAVE_GETCPU_VSYSCALL + int ret = INLINE_VSYSCALL (getcpu_kernel, 3, cpu, node, NULL); + if (ret != -1) + return ret; #endif + return INLINE_SYSCALL_CALL (getcpu, cpu, node, NULL); } weak_alias (__getcpu, getcpu) libc_hidden_def (__getcpu) diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c deleted file mode 100644 index d90ca820be..0000000000 --- a/sysdeps/unix/sysv/linux/init-first.c +++ /dev/null @@ -1,80 +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_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_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 792ac39d85..0000000000 --- a/sysdeps/unix/sysv/linux/libc-vdso.h +++ /dev/null @@ -1,51 +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_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/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h index 47c0333621..943cf4d88a 100644 --- a/sysdeps/unix/sysv/linux/mips/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/sysdep.h @@ -23,19 +23,3 @@ #define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" #define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" #define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" - -#ifndef __ASSEMBLER__ - -/* Standard MIPS syscalls have an error flag, and return a positive errno - when the error flag is set. Emulate this behaviour for vsyscalls so that - the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly. */ -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ - ({ \ - long _ret = funcptr (args); \ - err = ((unsigned long) (_ret) >= (unsigned long) -4095L); \ - if (err) \ - _ret = -_ret; \ - _ret; \ - }) - -#endif /* __ASSEMBLER__ */ 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 29b6624b9a..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,12 +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 (); - - INTERNAL_SYSCALL_DECL (err); - return INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, 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 18d8f7cb7a..816510640c 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -17,11 +17,8 @@ #include #include - -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL -# define HAVE_VSYSCALL -#endif #include +#include static int __gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) @@ -29,21 +26,18 @@ __gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) if (__glibc_unlikely (tz != 0)) memset (tz, 0, sizeof *tz); - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + int ret = INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + if (ret != -1) + return ret; + return INLINE_SYSCALL_CALL (gettimeofday, tv, 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/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h index a3bb552254..3d208dc192 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h @@ -41,7 +41,7 @@ function call, with the exception of LR (which is needed for the "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal an error return status). */ -# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...) \ +# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, type, nr, args...) \ ({ \ register void *r0 __asm__ ("r0"); \ register long int r3 __asm__ ("r3"); \ @@ -63,13 +63,15 @@ : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5), "+r" (r6), "+r" (r7), \ "+r" (r8), "+r" (r9), "+r" (r10), "+r" (r11), "+r" (r12) \ : : "cr0", "ctr", "lr", "memory"); \ - err = (long int) r0; \ + long int err = (long int) r0; \ __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3), "r" (r4)); \ + if (INTERNAL_SYSCALL_ERROR_P (rval, err)) \ + rval = -rval; \ rval; \ }) -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ - INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args) +#define INTERNAL_VSYSCALL_CALL(funcptr, nr, args...) \ + INTERNAL_VSYSCALL_CALL_TYPE(funcptr, long int, nr, args) # undef INLINE_SYSCALL # define INLINE_SYSCALL(name, nr, args...) \ diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h index 207d9d5709..98819eb3f2 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h @@ -51,7 +51,7 @@ gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set) the negation of the return value in the kernel gets reverted. */ -#define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...) \ +#define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, type, nr, args...) \ ({ \ register void *r0 __asm__ ("r0"); \ register long int r3 __asm__ ("r3"); \ @@ -70,13 +70,15 @@ : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5), "+r" (r6), \ "+r" (r7), "+r" (r8) \ : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory"); \ - err = (long int) r0; \ + long int err = (long int) r0; \ __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3)); \ + if (INTERNAL_SYSCALL_ERROR_P (rval, err)) \ + rval = -rval; \ rval; \ }) -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ - INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args) +#define INTERNAL_VSYSCALL_CALL(funcptr, nr, args...) \ + INTERNAL_VSYSCALL_CALL_TYPE(funcptr, long int, nr, args) /* This version is for kernels that implement system calls that behave like function calls as far as register saving. */ diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c index 80a4c73416..4f90604e6a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/time.c +++ b/sysdeps/unix/sysv/linux/powerpc/time.c @@ -18,31 +18,25 @@ #include #include - -#ifdef HAVE_TIME_VSYSCALL -# define HAVE_VSYSCALL -#endif #include +#include static time_t time_vsyscall (time_t *t) { - return INLINE_VSYSCALL (time, 1, t); + time_t ret = INLINE_VSYSCALL (time, 1, t); + if (ret != -1) + return ret; + return INLINE_SYSCALL_CALL (time, 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/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h index f38144c912..4ae0fca6ee 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h @@ -34,13 +34,6 @@ #else /* __ASSEMBLER__ */ -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ - ({ \ - long _ret = funcptr (args); \ - err = ((unsigned long) (_ret) >= (unsigned long) -4095L); \ - _ret; \ - }) - # define VDSO_NAME "LINUX_2.6" # define VDSO_HASH 61765110 diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h index cf614fbf8b..c9becbc86d 100644 --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h @@ -19,71 +19,29 @@ #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, err, nr, args...) \ - funcptr (args) +# define INTERNAL_VSYSCALL_CALL(funcptr, nr, args...) \ + funcptr (args) #endif -#ifdef HAVE_VSYSCALL - -# include - -# define INLINE_VSYSCALL(name, nr, args...) \ - ({ \ - __label__ out; \ - __label__ iserr; \ - INTERNAL_SYSCALL_DECL (sc_err); \ - long int sc_ret; \ - \ - __typeof (__vdso_##name) vdsop = __vdso_##name; \ - PTR_DEMANGLE (vdsop); \ - if (vdsop != NULL) \ - { \ - sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, sc_err, nr, ##args); \ - if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ - goto out; \ - if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \ - goto iserr; \ - } \ - \ - sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \ - if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ - { \ - iserr: \ - __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \ - sc_ret = -1L; \ - } \ - out: \ - sc_ret; \ - }) - -# define INTERNAL_VSYSCALL(name, err, nr, args...) \ - ({ \ - __label__ out; \ - long v_ret; \ - \ - __typeof (__vdso_##name) vdsop = __vdso_##name; \ - PTR_DEMANGLE (vdsop); \ - if (vdsop != NULL) \ - { \ - v_ret = INTERNAL_VSYSCALL_CALL (vdsop, err, nr, ##args); \ - if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err) \ - || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS) \ - goto out; \ - } \ - v_ret = INTERNAL_SYSCALL (name, err, nr, ##args); \ - out: \ - v_ret; \ +#define INLINE_VSYSCALL(name, nr, args...) \ + ({ \ + long int sc_ret = -1; \ + __typeof (name) *vdsop = GLRO(dl_vdso_##name); \ + if (vdsop != NULL) \ + { \ + sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \ + if ((unsigned long) sc_ret > -4096UL) \ + { \ + __set_errno (-sc_ret); \ + sc_ret = -1L; \ + } \ + } \ + sc_ret; \ }) -#else - -# define INLINE_VSYSCALL(name, nr, args...) \ - INLINE_SYSCALL (name, nr, ##args) -# define INTERNAL_VSYSCALL(name, err, nr, args...) \ - INTERNAL_SYSCALL (name, err, nr, ##args) - -#endif /* USE_VSYSCALL && defined HAVE_VSYSCALL */ #endif /* SYSDEP_VDSO_LINUX_H */ 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 190127d31e..bf7d4692bd 100644 --- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/x86/gettimeofday.c @@ -18,10 +18,6 @@ #include #include - -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL -# define HAVE_VSYSCALL -#endif #include static int @@ -30,17 +26,17 @@ __gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) if (__glibc_unlikely (tz != 0)) memset (tz, 0, sizeof *tz); - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + int ret = INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + if (ret != -1) + return ret; + return INLINE_SYSCALL_CALL (gettimeofday, tv, 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 4a03c46d21..c65f2d5d54 100644 --- a/sysdeps/unix/sysv/linux/x86/time.c +++ b/sysdeps/unix/sysv/linux/x86/time.c @@ -18,26 +18,22 @@ #include #include - -#ifdef HAVE_TIME_VSYSCALL -# define HAVE_VSYSCALL -#endif #include static time_t time_vsyscall (time_t *t) { - return INLINE_VSYSCALL (time, 1, t); + time_t ret = INLINE_VSYSCALL (time, 1, t); + if (ret != -1) + return ret; + return INLINE_SYSCALL_CALL (time, 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)