This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Always set l_used for vDSO (BZ #13706)


On Mon, Feb 20, 2012 at 4:22 AM, Marek Polacek <polacek@redhat.com> wrote:
> As the PR says, ldd reports linux-vdso.so.1 as unused. ?The problem is that
> we weren't always setting l_used for vDSO. ?This path seems to fix it.
> Regtested on x86_64-linux, ok for trunk?

Can you please add a regression test for this?

The next time we break this it would be nice to have a warning.

> 2012-02-20 ?Marek Polacek ?<polacek@redhat.com>
>
> ? ? ? ?* elf/rtld.c (dl_main): Always set l_used to 1 for vDSO.
>
> --- libc/elf/rtld.c.mp ?2012-02-20 10:03:06.799226404 +0100
> +++ libc/elf/rtld.c ? ? 2012-02-20 10:03:18.732248427 +0100
> @@ -1,5 +1,5 @@
> ?/* Run time dynamic linker.
> - ? Copyright (C) 1995-2010, 2011 Free Software Foundation, Inc.
> + ? Copyright (C) 1995-2012 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
> @@ -1375,6 +1375,9 @@ of this helper program; chances are you
> ? ? ? ? ?_dl_setup_hash (l);
> ? ? ? ? ?l->l_relocated = 1;
>
> + ? ? ? ? /* The vDSO is always used. ?*/
> + ? ? ? ? l->l_used = 1;
> +

The call to _dl_new_object did not set l_used because DL_DEBUG_UNUSED
is in effect.

The only code that knows this is a vDSO and that it will be used
unconditionally is the code in elf/rtld.c (dl_main). Therefore this is
probably the best place to mark the vDSO as unconditionally used.

We could hack in a DT_NEEDED somewhere in the list and just allow the
normal DL_DEBUG_UNUSED checks to note that the vDSO was needed, but
that seems extremely obtuse and fragile.

Normally l_used is set during
elf/rtld/dl-lookup.c(_dl_lookup_symbol_x), but in the DL_DEBUG_UNUSED
case we never exercise that code because we aren't running the
program.

All in all your solution looks like the best option.

> ? ? ? ? ?/* Initialize l_local_scope to contain just this map. ?This allows
> ? ? ? ? ? ? the use of dl_lookup_symbol_x to resolve symbols within the vdso.
> ? ? ? ? ? ? So we create a single entry list pointing to l_real as its only
> --- libc/NEWS.mp ? ? ? ?2012-02-20 10:02:20.037140095 +0100
> +++ libc/NEWS ? 2012-02-20 10:03:42.095291549 +0100
> @@ -12,7 +12,7 @@ Version 2.16
> ? 174, 350, 411, 3335, 4026, 4596, 4822, 5077, 5805, 5993, 6884, 6907, 9739,
> ? 9902, 10140, 10210, 11174, 11322, 11494, 12047, 13058, 13525, 13526,
> ? 13527, 13528, 13529, 13530, 13531, 13532, 13533, 13547, 13551, 13552,
> - ?13553, 13555, 13559, 13583, 13618, 13704
> + ?13553, 13555, 13559, 13583, 13618, 13704, 13706
>
> ?* ISO C11 support:
>
> ? ? ? ?Marek

This is good for trunk after you add a regression test.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]