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]

_rtld_global_ro and static dlopen (was: Re: Pending fixes for all-ABIs builds)


On 11/10/2016 10:27 AM, Andreas Schwab wrote:
On Nov 10 2016, Florian Weimer <fweimer@redhat.com> wrote:

Could we put this information into rtld_global_ro, instead of having a
separate variable?  (Assuming that rtld_global_ro is indeed in read-only
memory after relocation.)

It cannot be read-only, it is set only after ld.so is initialized.

I know that glibc has trouble with multiple definitions, but at least one copy of _rtld_global_ro *is* read-only after relocation:

(gdb) print memset (&_rtld_global_ro, 1, 1)
Program received signal SIGSEGV, Segmentation fault.
__memset_sse2 () at ../sysdeps/x86_64/memset.S:110
110		movb	%cl, (%rdi)

It also contains a function pointer to _dl_lookup_symbol_x, so I think this data structure should work for locating ld.so functions.

Is the problem that we determine too late that we are running in a nested configuration, and the inner ld.so has already been relocated? Maybe gdb is lying to me, but it seems that we run the inner libc.so with a _rtld_global_ro which has not been initialized beyond what is in the default initializer. It seems that dl_main never runs.

But this means that most uses of GLRO inside libc.so.6 are broken. And indeed, GLRO (dl_auxv) does not work as intended, and results in a NULL pointer dereference in getauxval:

  https://sourceware.org/bugzilla/show_bug.cgi?id=20802

How can we fix this? Could we synthesize a link map which interposes the necessary definitions?

Thanks,
Florian


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