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] Save reference to kernel provided envp in the linker


On Fri, Dec 21, 2012 at 5:18 AM, Siddhesh Poyarekar <siddhesh@redhat.com> wrote:
> Hi,
>
> A circular dependency between libpthread.so and libc.so ensures that
> libpthread.so constructor is called first.  Due to this, libpthread.so
> constructor does not have access to the environment variables, since a
> relocation wipes out the __environ that the dynamic linker had, which
> gets updated when the libc.so constructor is called.
>

This is pretty odd.  We made some changes to libpthread to
add a constructor to .init_array section in libpthread.so.
It does get the proper environ:

Breakpoint 1, elision_init (argc=1, argv=0x7fffffffe258,
    environ=0x7fffffffe268)
    at ../nptl/sysdeps/unix/sysv/linux/x86/multiarch/elision-conf.c:214
214	{
(gdb) bt
#0  elision_init (argc=1, argv=0x7fffffffe258, environ=0x7fffffffe268)
    at ../nptl/sysdeps/unix/sysv/linux/x86/multiarch/elision-conf.c:214
#1  0x00007ffff7de9966 in call_init (env=0x7fffffffe268, argv=0x7fffffffe258,
    argc=1, l=<optimized out>) at dl-init.c:84
#2  call_init (l=<optimized out>, argc=1, argv=0x7fffffffe258,
    env=0x7fffffffe268) at dl-init.c:34
#3  0x00007ffff7de9a67 in _dl_init (main_map=0x7ffff7ffe208, argc=1,
    argv=0x7fffffffe258, env=0x7fffffffe268) at dl-init.c:99
#4  0x00007ffff7ddc59a in _dl_start_user ()
   from /export/build/gnu/glibc-andi/build-x86_64-linux/elf/ld.so
#5  0x0000000000000001 in ?? ()
#6  0x00007fffffffe4dc in ?? ()
#7  0x0000000000000000 in ?? ()
(gdb) p *environ
$1 = 0x7fffffffe51d "TERM=xterm"
(gdb)

Have you verified that envron isn't passed to functions in
.init_array section in libpthread.so?


-- 
H.J.


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