--- Begin Message ---
- To: submit@bugs.debian.org
- Subject: vDSO is not in effect in static linked executable on jessie
- From: jian wang <wangjian@bytedance.com>
- Date: Fri, 22 Apr 2016 18:27:34 +0800
- Message-id: <CAJ=zKub=+dHMsWBpT-6vJ_RUcxfzbP8AwrDrpLfmaieDs0ZoGg@mail.gmail.com>
Package: lib6
Version: 2.19-18+deb8u4
Severity: important
vDSO is not in effect in static linked executable on jessie. This is
not the case with wheezy.
We build binary to run on both wheezy and jessie, so -static. When
building platform is wheezy, vdso works fine, but jessie the opposite.
This leads to performance hit. Unfortunately, we use g++ 4.9 for some
application, so wheezy can't be used as build platform.
How to reproduce
$ cat t.c
#include <time.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/time.h>
int main()
{
struct timeval now;
gettimeofday(&now, NULL);
printf("%d\n", now.tv_sec);
printf("%d\n", time(NULL));
return 0;
}
$ gcc -static t.c
$ strace ./a.out
>From output, you can see syscall gettimeofday() is called.
--- End Message ---
--- Begin Message ---
- To: jian wang <wangjian@bytedance.com>, 822236-done@bugs.debian.org
- Subject: Re: Bug#822236: vDSO is not in effect in static linked executable on jessie
- From: Aurelien Jarno <aurelien@aurel32.net>
- Date: Sun, 11 Sep 2022 00:52:10 +0200
- Message-id: <Yx0VGt2HrWgYgD0n@aurel32.net>
- In-reply-to: <20160719165854.GA32347@aurel32.net>
- References: <CAJ=zKub=+dHMsWBpT-6vJ_RUcxfzbP8AwrDrpLfmaieDs0ZoGg@mail.gmail.com> <20160422111112.GU15516@chase.mapreri.org> <20160424103138.GA20676@aurel32.net> <CAJ=zKua1dkMjDHrFcO+3MBFLRRESZrPZULqDQOSQ9HFU70tyag@mail.gmail.com> <20160719165854.GA32347@aurel32.net>
Version: 2.31-1
Hi,
On 2016-07-19 18:58, Aurelien Jarno wrote:
> control: retitle -1 vsyscall is not in effect in static linked executable on jessie
> thanks
>
> On 2016-04-24 21:01, jian wang wrote:
> > On Sun, Apr 24, 2016 at 6:31 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> > > control: tag -1 + moreinfo
> > >
> > > On 2016-04-22 11:11, Mattia Rizzolo wrote:
> > >> control: reassign -1 libc6 2.19-18+deb8u4
> > >>
> > >> On Fri, Apr 22, 2016 at 06:27:34PM +0800, jian wang wrote:
> > >> > Package: lib6
> > >>
> > >> lost a 'c' :)
> > >> reassigning.
> > >>
> > >> > Version: 2.19-18+deb8u4
> > >> > Severity: important
> > >> >
> > >> > vDSO is not in effect in static linked executable on jessie. This is
> > >> > not the case with wheezy.
> > >> >
> > >> > We build binary to run on both wheezy and jessie, so -static. When
> > >> > building platform is wheezy, vdso works fine, but jessie the opposite.
> > >> >
> > >> > This leads to performance hit. Unfortunately, we use g++ 4.9 for some
> > >> > application, so wheezy can't be used as build platform.
> > >
> > > There is not of information about your environment, so given what you
> > > describe, it seems you are using an i386 installation.
> > >
> >
> > The context is for lots of servers. We use amd64 all over datacenters.
> >
> > > The vDSO support requires at least a i686 CPU, while Debian i386 targets
> > > i586. When using dynamic linking, one can install libc6-i686 which
> > > provides an i686 optimized version of the libc, therefore with vDSO
> > > support. It is automatically loaded if the CPU supports it.
> > >
> > > In your case, given you use static linking, the i586 version of the libc
> > > is used, and it therefore doesn't support vDSO . That is true on wheezy,
> > > jessie, stretch, sid. I don't believe this is a regression, and in
> > > addition I can't reproduce it.
> > >
> >
> > No.
> >
> > We have looked into the code now.
> >
> > Glibc 2.13 (wheezy) uses an asm version of gettimeofday.S for x86_64
> > which uses vDSO.
>
> To be more precise, glibc 2.13 uses vDSO for shared builds and vsyscall
> for static ones.
>
> > On the way up to glibc 2.19 (jessie), vDSO was rewritten into
> > gettimeofday.c. And as we dig out, Ulrich Drepper decided to not
> > optimize static linking, or even to dwarf static linking
> >
> > https://sourceware.org/bugzilla/show_bug.cgi?id=12813
>
> vsyscalls are consider deprecated due to limitation and security
> consideration. I guess that the reason the vsyscall part of the code has
> been removed.
Support for vDSO in static binaries has been added in glibc 2.31.
Closing the bug accordingly.
Regards
Aurelien
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://www.aurel32.net
--- End Message ---