[v4] Enable VDSO on x86_64 statically linked programs.
Commit Message
> > 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 <rafael@espindo.la>
[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
Comments
Ping
>
> Thanks. A new version is attached and it uses your suggestion.
>
> The new ChangeLog is
>
> 2018-11-12 Rafael Ávila de Espíndola <rafael@espindo.la>
>
> [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?=
> <rafael@espindo.la>
> 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 <libc-vdso.h>
>
> @@ -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 <bits/wordsize.h>
> #include <kernel-features.h>
>
> +/* 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 <time.h>
> #include <sys/time.h>
>
> -#ifdef SHARED
> +#if USE_VSYSCALL
>
> # include <sysdep-vdso.h>
>
> 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
> <http://www.gnu.org/licenses/>. */
>
> -#ifdef SHARED
> -# include <time.h>
> -# include <sysdep.h>
> -# include <dl-vdso.h>
> -# include <libc-vdso.h>
> +#include <time.h>
> +#include <sysdep.h>
> +#include <dl-vdso.h>
> +#include <libc-vdso.h>
>
> 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 <csu/init-first.c>
> 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 <sysdeps/unix/sysv/linux/sysdep.h>
> #include <sysdeps/unix/x86_64/sysdep.h>
> --
> 2.19.1
On Mon, Nov 12, 2018 at 2:38 PM Rafael Avila de Espindola
<rafael@espindo.la> wrote:
>
> > > 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 <rafael@espindo.la>
>
> [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.
>
>
LGTM.
Thanks.
"H.J. Lu" <hjl.tools@gmail.com> writes:
> On Mon, Nov 12, 2018 at 2:38 PM Rafael Avila de Espindola
> <rafael@espindo.la> wrote:
>>
>> > > 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 <rafael@espindo.la>
>>
>> [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.
>>
>>
>
> LGTM.
If you could commit it that would be awesome.
Thanks,
Rafael
"Rafael Avila de Espindola" <rafael@espindo.la> writes:
>> LGTM.
>
> If you could commit it that would be awesome.
Ping.
Cheers,
Rafael
On Fri, Nov 23, 2018 at 8:56 AM Rafael Avila de Espindola
<rafael@espindo.la> wrote:
>
> "Rafael Avila de Espindola" <rafael@espindo.la> writes:
>
> >> LGTM.
> >
> > If you could commit it that would be awesome.
>
> Ping.
>
Done.
"H.J. Lu" <hjl.tools@gmail.com> writes:
> On Fri, Nov 23, 2018 at 8:56 AM Rafael Avila de Espindola
> <rafael@espindo.la> wrote:
>>
>> "Rafael Avila de Espindola" <rafael@espindo.la> writes:
>>
>> >> LGTM.
>> >
>> > If you could commit it that would be awesome.
>>
>> Ping.
>>
>
> Done.
Thanks!
Cheers,
Rafael
In file included from ../sysdeps/unix/sysv/linux/powerpc/libc-vdso.h:25,
from ../sysdeps/powerpc/powerpc32/backtrace.c:23:
../sysdeps/unix/sysv/linux/sysdep-vdso.h:29:5: error: "USE_VSYSCALL" is not defined, evaluates to 0 [-Werror=undef]
#if USE_VSYSCALL && defined HAVE_VSYSCALL
^~~~~~~~~~~~
Andreas.
Andreas Schwab <schwab@suse.de> writes:
> In file included from ../sysdeps/unix/sysv/linux/powerpc/libc-vdso.h:25,
> from ../sysdeps/powerpc/powerpc32/backtrace.c:23:
> ../sysdeps/unix/sysv/linux/sysdep-vdso.h:29:5: error: "USE_VSYSCALL" is not defined, evaluates to 0 [-Werror=undef]
> #if USE_VSYSCALL && defined HAVE_VSYSCALL
> ^~~~~~~~~~~~
Fixed with commit 8ae74eadb60e.
"Andreas Schwab" <schwab@suse.de> writes:
> In file included from ../sysdeps/unix/sysv/linux/powerpc/libc-vdso.h:25,
> from ../sysdeps/powerpc/powerpc32/backtrace.c:23:
> ../sysdeps/unix/sysv/linux/sysdep-vdso.h:29:5: error: "USE_VSYSCALL" is not defined, evaluates to 0 [-Werror=undef]
> #if USE_VSYSCALL && defined HAVE_VSYSCALL
Sorry about that.
While the particular build problem on powerpc is now fixed, maybe we
should just include sysdep.h from sysdep-vdso.h?
The attached patch does just that. The changelog is
2018-11-26 Rafael Ávila de Espíndola <rafael@espindo.la>
[BZ #19767]
* sysdeps/unix/sysv/linux/sysdep-vdso.h: include sysdep.h.
Cheers,
Rafael
Rafael Avila de Espindola <rafael@espindo.la> writes:
> "Andreas Schwab" <schwab@suse.de> writes:
>
>> In file included from ../sysdeps/unix/sysv/linux/powerpc/libc-vdso.h:25,
>> from ../sysdeps/powerpc/powerpc32/backtrace.c:23:
>> ../sysdeps/unix/sysv/linux/sysdep-vdso.h:29:5: error: "USE_VSYSCALL" is not defined, evaluates to 0 [-Werror=undef]
>> #if USE_VSYSCALL && defined HAVE_VSYSCALL
>
> Sorry about that.
>
> While the particular build problem on powerpc is now fixed, maybe we
> should just include sysdep.h from sysdep-vdso.h?
>
> The attached patch does just that. The changelog is
The patch is missing.
> 2018-11-26 Rafael Ávila de Espíndola <rafael@espindo.la>
>
> [BZ #19767]
> * sysdeps/unix/sysv/linux/sysdep-vdso.h: include sysdep.h.
Uppercase sentence -----------------------------^
"Tulio Magno Quites Machado Filho" <tuliom@ascii.art.br> writes:
> Rafael Avila de Espindola <rafael@espindo.la> writes:
>
>> "Andreas Schwab" <schwab@suse.de> writes:
>>
>>> In file included from ../sysdeps/unix/sysv/linux/powerpc/libc-vdso.h:25,
>>> from ../sysdeps/powerpc/powerpc32/backtrace.c:23:
>>> ../sysdeps/unix/sysv/linux/sysdep-vdso.h:29:5: error: "USE_VSYSCALL" is not defined, evaluates to 0 [-Werror=undef]
>>> #if USE_VSYSCALL && defined HAVE_VSYSCALL
>>
>> Sorry about that.
>>
>> While the particular build problem on powerpc is now fixed, maybe we
>> should just include sysdep.h from sysdep-vdso.h?
>>
>> The attached patch does just that. The changelog is
>
> The patch is missing.
Oops. Attached now.
The fixed changelog is
2018-11-27 Rafael Ávila de Espíndola <rafael@espindo.la>
[BZ #19767]
* sysdeps/unix/sysv/linux/sysdep-vdso.h: Include sysdep.h.
Cheers,
Rafael
Rafael Avila de Espindola <rafael@espindo.la> writes:
> "Tulio Magno Quites Machado Filho" <tuliom@ascii.art.br> writes:
>
>> Rafael Avila de Espindola <rafael@espindo.la> writes:
>>
>>> The attached patch does just that. The changelog is
>>
>> The patch is missing.
>
> Oops. Attached now.
There is nothing here again.
Maybe the mailing list is removing your patch?
I couldn't find a hint here:
https://sourceware.org/ml/libc-alpha/2018-11/msg00717.html
* Tulio Magno Quites Machado Filho:
> Rafael Avila de Espindola <rafael@espindo.la> writes:
>
>> "Tulio Magno Quites Machado Filho" <tuliom@ascii.art.br> writes:
>>
>>> Rafael Avila de Espindola <rafael@espindo.la> writes:
>>>
>>>> The attached patch does just that. The changelog is
>>>
>>> The patch is missing.
>>
>> Oops. Attached now.
>
> There is nothing here again.
>
> Maybe the mailing list is removing your patch?
Then Red Hat email system removes it as well. 8-/
Note that including <sysdep.h> can be problematic because on certain
architectures, not all assembler files are compatible with <sysdep.h>,
so if <sysdep-vdso.h> ends in assembler files, that could be a problem.
Thanks,
Florian
"Florian Weimer" <fweimer@redhat.com> writes:
> * Tulio Magno Quites Machado Filho:
>
>> Rafael Avila de Espindola <rafael@espindo.la> writes:
>>
>>> "Tulio Magno Quites Machado Filho" <tuliom@ascii.art.br> writes:
>>>
>>>> Rafael Avila de Espindola <rafael@espindo.la> writes:
>>>>
>>>>> The attached patch does just that. The changelog is
>>>>
>>>> The patch is missing.
>>>
>>> Oops. Attached now.
>>
>> There is nothing here again.
>>
>> Maybe the mailing list is removing your patch?
>
> Then Red Hat email system removes it as well. 8-/
>
> Note that including <sysdep.h> can be problematic because on certain
> architectures, not all assembler files are compatible with <sysdep.h>,
> so if <sysdep-vdso.h> ends in assembler files, that could be a problem.
Looks like powerpc was the only build failure, so it might not be worth
the risk.
I will keep updating one arch at a time as I find time to test it on the
gcc farm.
Cheers,
Rafael
28.11.2018 13:55 Tulio Magno Quites Machado Filho <tuliom@ascii.art.br>
wrote:
>
> Rafael Avila de Espindola <rafael@espindo.la> writes:
>
> > "Tulio Magno Quites Machado Filho" <tuliom@ascii.art.br> writes:
> >
> >> Rafael Avila de Espindola <rafael@espindo.la> writes:
> >>
> >>> The attached patch does just that. The changelog is
> >>
> >> The patch is missing.
> >
> > Oops. Attached now.
>
> There is nothing here again.
>
> Maybe the mailing list is removing your patch?
> [...]
Rafael, does your email body contain a line consisting of only a single
dot? I saw SMTP servers treating it as the end of message and removing
everything below.
Regards,
Rafal
From e035a9e1da87daec5e0b8f735734df42e595646b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?=
<rafael@espindo.la>
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
@@ -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
new file mode 100644
@@ -0,0 +1 @@
+#include "tst-cond11.c"
@@ -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
@@ -26,7 +26,7 @@
funcptr (args)
#endif
-#if defined SHARED && defined HAVE_VSYSCALL
+#if USE_VSYSCALL && defined HAVE_VSYSCALL
# include <libc-vdso.h>
@@ -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 */
@@ -18,6 +18,13 @@
#include <bits/wordsize.h>
#include <kernel-features.h>
+/* 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 *). */
new file mode 100644
@@ -0,0 +1 @@
+#include "tst-affinity.c"
@@ -22,7 +22,7 @@
#include <time.h>
#include <sys/time.h>
-#ifdef SHARED
+#if USE_VSYSCALL
# include <sysdep-vdso.h>
@@ -16,11 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#ifdef SHARED
-# include <time.h>
-# include <sysdep.h>
-# include <dl-vdso.h>
-# include <libc-vdso.h>
+#include <time.h>
+#include <sysdep.h>
+#include <dl-vdso.h>
+#include <libc-vdso.h>
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 <csu/init-first.c>
@@ -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 <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/x86_64/sysdep.h>
--
2.19.1