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] BZ #14831: Segfault in _dl_profile_fixup with IRELATIVEand LD_AUDIT


On Wed, Nov 14, 2012 at 1:46 PM, Carlos O'Donell
<carlos@systemhalted.org> wrote:
> On Wed, Nov 14, 2012 at 1:59 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> So the problem is that the objects are loaded in reverse order (for copy reloc
>>> purposes) and therefore we load libm.so *before* libc.so, and thus
>>> l_reloc_result hasn't been allocated for libc.so yet, and thus trying to
>>> resolve a function in libc.so will fail if we have profiling enabled because
>>> that entry in the link_map is not yet allocated (because we haven't called
>>> _dl_relocate_object for libc.so yet).
>>>
>>> We are going to eventually allocate l_reloc_result anyway. Could we instead
>>> refactor the l_reloc_result allocation out of _dl_relocate_object and into
>>> the loop in rtld.c which loads all the objects?
>>>
>>
>> It isn't libc.so's l_reloc_result hasn't been allocated.  It is libm.so's
>> l_reloc_result hasn't been allocated since we have
>
> Yes, sorry, you're right.
>
>> ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling, skip_ifunc);
>> ...
>> l->l_reloc_result = calloc (sizeof (l->l_reloc_result[0]),
>>
>> Allocate l_reloc_result before ELF_DYNAMIC_RELOCATE causes
>> tst-audit2 failure:
>>
>> {abcdef72, d8675309} != {d8675309, abcdef72}
>>
>> since wrong calloc is called.  How about this updated comments?
>
> Could you please look more closely at why tst-audit2 fails?
>
> I see that tst-audit2 simply wants to know if the static TLS variables
> have been initialized *before* calloc ever gets called.
>
> If we move the first call to calloc *before* ELF_DYNAMIC_RELOCATE, how
> does that effect this? I would have expected the static TLS vars to be
> initialized well before this point.
>
> Cheers,
> Carlos.

The calloc check is intentional:

http://www.sourceware.org/ml/libc-alpha/2005-09/msg00075.html
http://sourceware.org/ml/libc-alpha/2006-03/msg00138.html


-- 
H.J.


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