From patchwork Mon Nov 12 22:38:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rafael Avila de Espindola X-Patchwork-Id: 30121 Received: (qmail 14185 invoked by alias); 12 Nov 2018 22:38:43 -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 14128 invoked by uid 89); 12 Nov 2018 22:38:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail1.protonmail.ch Date: Mon, 12 Nov 2018 22:38:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=espindo.la; s=protonmail; t=1542062312; bh=7KZtCOqICt+yNeVtDTcnEOzN7ZkkgFkrJH808MU61gI=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References: Feedback-ID:From; b=aGvHbWuUefZkOAynWAfVxeqb+EKowOZKi+nyAdI0cuFh/jc1pNrWFzlZPRo+mXexR En3ioFGWK2ssPKq19K1JIJQFNsELeumJQBJl66QxbnLgqZW3d9ZzUv3jtXaHZo0kqY /nN5dp3yOe0eh2EWMu2VXf42rQq2JIn++MSdzOUo= To: Florian Weimer From: Rafael Avila de Espindola Cc: "libc-alpha@sourceware.org" , "H.J. Lu" , Szabolcs Nagy Reply-To: Rafael Avila de Espindola Subject: Re: [PATCH v4] Enable VDSO on x86_64 statically linked programs. Message-ID: <2L5vAwL1Dbn5HAap_wUEZpI24EF_Tlwhc88DvKmxb-yHd_Qxdc8A9wHavFzKr11pj-kD44Q-fIE0PubxE5qvepV9WK_Rg8isazIA3Sw6pa4=@espindo.la> In-Reply-To: <877ehiqwmb.fsf@oldenburg.str.redhat.com> References: <877ehiqwmb.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 > > object-suffixes += .os > > -CPPFLAGS-.os = -DPIC -DSHARED > > +CPPFLAGS-.os = -DPIC -DSHARED -DUSE_VSYSCALL > > CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag) > > libtype.os := lib%_pic.a > > > > This can be changed by a sysdep makefile > > > > ========================================= > > This doesn't seem to be the right place to define the macro. We also > prefer macros that are always defined and which change there value > between 0 and 1. > > USE_VSYSCALL seems to be a Linux thing and thus should go into > sysdeps/unix/sysv/linux. > > It may be clearer to define > > #define USE_VSYSCALL (defined (SHARED) || ALWAYS_USE_VSYSCALL) > > and then default ALWAYS_USE_VSYSCALL to 0 and override that to 1 for > x86_64. Thanks. A new version is attached and it uses your suggestion. The new ChangeLog is 2018-11-12 Rafael Ávila de Espíndola [BZ #19767] * nptl/Makefile: Add tst-cond11-static to tests-static and tests. * nptl/tst-cond11-static.c: New File. * sysdeps/unix/sysv/linux/Makefile: Add tst-affinity-static to tests-static and tests * sysdeps/unix/sysv/linux/sysdep-vdso.h: Use USE_VSYSCALL instead of SHARED. * sysdeps/unix/sysv/linux/sysdep.h: Define ALWAYS_USE_VSYSCALL and USE_VSYSCALL. * sysdeps/unix/sysv/linux/tst-affinity-static.c: New file. * sysdeps/unix/sysv/linux/x86/libc-vdso.h: Use USE_VSYSCALL instead of SHARED. * sysdeps/unix/sysv/linux/x86_64/init-first.c: remove #ifdef SHARED. * sysdeps/unix/sysv/linux/x86_64/sysdep.h: define ALWAYS_USE_VSYSCALL. Cheers, Rafael From e035a9e1da87daec5e0b8f735734df42e595646b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Thu, 8 Nov 2018 23:25:31 -0800 Subject: [PATCH] Enable VDSO on x86_64 statically linked programs. All the required code already existed, and some of it was already running. AT_SYSINFO_EHDR is processed if NEED_DL_SYSINFO_DSO is defined, but it looks like it always is. The call to setup_vdso is also unconditional, so all that was left to do was setup the function pointers and use them. This patch just deletes some #ifdef to enable that. --- nptl/Makefile | 5 +++-- nptl/tst-cond11-static.c | 1 + sysdeps/unix/sysv/linux/Makefile | 3 +++ sysdeps/unix/sysv/linux/sysdep-vdso.h | 4 ++-- sysdeps/unix/sysv/linux/sysdep.h | 7 +++++++ sysdeps/unix/sysv/linux/tst-affinity-static.c | 1 + sysdeps/unix/sysv/linux/x86/libc-vdso.h | 2 +- sysdeps/unix/sysv/linux/x86_64/init-first.c | 12 +++++------- sysdeps/unix/sysv/linux/x86_64/sysdep.h | 3 +++ 9 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 nptl/tst-cond11-static.c create mode 100644 sysdeps/unix/sysv/linux/tst-affinity-static.c diff --git a/nptl/Makefile b/nptl/Makefile index 49b6faa330..982e43adfa 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -449,9 +449,10 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \ tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \ tst-cancel21-static tst-cancel24-static tst-cond8-static \ tst-mutex8-static tst-mutexpi8-static tst-sem11-static \ - tst-sem12-static + tst-sem12-static tst-cond11-static + tests += tst-cancel21-static tst-cancel24-static \ - tst-cond8-static + tst-cond8-static tst-cond11-static tests-internal += tst-sem11-static tst-sem12-static tst-stackguard1-static xtests-static += tst-setuid1-static diff --git a/nptl/tst-cond11-static.c b/nptl/tst-cond11-static.c new file mode 100644 index 0000000000..9bccb8ec8b --- /dev/null +++ b/nptl/tst-cond11-static.c @@ -0,0 +1 @@ +#include "tst-cond11.c" diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 72b6b641d5..362cf3b950 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -146,6 +146,9 @@ sysdep_routines += sched_getcpu oldglob tests += tst-affinity tst-affinity-pid +tests-static := tst-affinity-static +tests += $(tests-static) + CFLAGS-fork.c = $(libio-mtsafe) CFLAGS-getpid.o = -fomit-frame-pointer CFLAGS-getpid.os = -fomit-frame-pointer diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h index 7f894c5e02..1ee0657ad3 100644 --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h @@ -26,7 +26,7 @@ funcptr (args) #endif -#if defined SHARED && defined HAVE_VSYSCALL +#if USE_VSYSCALL && defined HAVE_VSYSCALL # include @@ -84,6 +84,6 @@ # define INTERNAL_VSYSCALL(name, err, nr, args...) \ INTERNAL_SYSCALL (name, err, nr, ##args) -#endif /* defined SHARED && defined HAVE_VSYSCALL */ +#endif /* USE_VSYSCALL && defined HAVE_VSYSCALL */ #endif /* SYSDEP_VDSO_LINUX_H */ diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 4fd0a9bae3..9655436ee4 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -18,6 +18,13 @@ #include #include +/* By default only shared builds use vdso. */ +#ifndef ALWAYS_USE_VSYSCALL +#define ALWAYS_USE_VSYSCALL 0 +#endif + +#define USE_VSYSCALL (defined (SHARED) || ALWAYS_USE_VSYSCALL) + /* Set error number and return -1. A target may choose to return the internal function, __syscall_error, which sets errno and returns -1. We use -1l, instead of -1, so that it can be casted to (void *). */ diff --git a/sysdeps/unix/sysv/linux/tst-affinity-static.c b/sysdeps/unix/sysv/linux/tst-affinity-static.c new file mode 100644 index 0000000000..4022ea317a --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-affinity-static.c @@ -0,0 +1 @@ +#include "tst-affinity.c" diff --git a/sysdeps/unix/sysv/linux/x86/libc-vdso.h b/sysdeps/unix/sysv/linux/x86/libc-vdso.h index 6f86073dae..b9b4b93011 100644 --- a/sysdeps/unix/sysv/linux/x86/libc-vdso.h +++ b/sysdeps/unix/sysv/linux/x86/libc-vdso.h @@ -22,7 +22,7 @@ #include #include -#ifdef SHARED +#if USE_VSYSCALL # include diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c index 2320505804..ad19f4b055 100644 --- a/sysdeps/unix/sysv/linux/x86_64/init-first.c +++ b/sysdeps/unix/sysv/linux/x86_64/init-first.c @@ -16,11 +16,10 @@ License along with the GNU C Library; if not, see . */ -#ifdef SHARED -# include -# include -# include -# include +#include +#include +#include +#include long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *) attribute_hidden; @@ -46,7 +45,6 @@ __vdso_platform_setup (void) VDSO_SYMBOL(getcpu) = p; } -# define VDSO_SETUP __vdso_platform_setup -#endif +#define VDSO_SETUP __vdso_platform_setup #include diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index f07eb04962..9f49347ce5 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -18,6 +18,9 @@ #ifndef _LINUX_X86_64_SYSDEP_H #define _LINUX_X86_64_SYSDEP_H 1 +/* Always enable vsyscalls on x86_64 */ +#define ALWAYS_USE_VSYSCALL 1 + /* There is some commonality. */ #include #include -- 2.19.1