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] Fix up LD_* vars behaviour


On Sun, Apr 8, 2012 at 7:28 PM, Marek Polacek <polacek@redhat.com> wrote:
> While playing with LD_DYNAMIC_WEAK I've found an inconsistency in
> processing LD_* vars. ?There are some variables which are switched
> on only when the part after `=' is non-null, e.g.:
>
> $ LD_DEBUG=statistics LD_BIND_NOW= elf/ld-linux-x86-64.so.2 --library-path . /bin/ed <<< q
> ? ? 31275: ? ? runtime linker statistics:
> ? ? 31275: ? ? ? ? ? ? ? ?final number of relocations: 103
> ? ? 31275: ? ? final number of relocations from cache: 3
>
> $ LD_DEBUG=statistics LD_BIND_NOW=1 elf/ld-linux-x86-64.so.2 --library-path . /bin/ed <<< q
> ? ? 31276: ? ? runtime linker statistics:
> ? ? 31276: ? ? ? ? ? ? ? ?final number of relocations: 147
> ? ? 31276: ? ? final number of relocations from cache: 3
>
> On the other hand, some are enabled even though they're null:
>
> $ LD_SHOW_AUXV= elf/ld-linux-x86-64.so.2 --library-path . /bin/true
> AT_SYSINFO_EHDR: 0x7fff329ff000
> AT_HWCAP: ? ? ? ?bfebfbff
> AT_PAGESZ: ? ? ? 4096
> ...
>
> So, if this isn't actually wanted for some reason, I propose following
> patch. ?Regtested on x86_64-linux, ok for trunk?
>
> 2012-04-08 ?Marek Polacek ?<polacek@redhat.com>
>
> ? ? ? ?* elf/rtld.c (process_envvars): Ignore null LD_SHOW_AUXV,
> ? ? ? ?LD_DYNAMIC_WEAK and LD_TRACE_LOADED_OBJECTS envvars.

I like this change. I wish we could check it in :-)

Unfortunately there is clear user documentation written by the linux
man-pages team saying "... if the environment variable is set..." and
that includes setting it to the null string. We happen to not have any
documentation of our own, so we don't get to cry foul here (though we
should!).

POSIX is pretty clear about this distinction and uses the wording "If
the environment variable is unset or is set to the empty string, the
implementation shall..."

Therefore for the sake of compatibility I think we need to leave these
as they are.

If there is any bug here it is that an LD_* var is documented as being
enabled by the environment variable being set and it does so only when
set to non-null.

Cheers,
Carlos.


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