[PATCH v2 1/3] elf: Iterate over loaded object list in _dl_determine_tlsoffset

Florian Weimer fweimer@redhat.com
Wed Jan 15 09:11:08 GMT 2025


* Adhemerval Zanella Netto:

> On 13/01/25 09:32, Florian Weimer wrote:
>> The old code used the slotinfo array as a scratch area to pass the
>> list of TLS-using objects to _dl_determine_tlsoffset.  All array
>> entries are subsequently overwritten by _dl_add_to_slotinfo,
>> except the first one.  The link maps are usually not at their
>> right position for their module ID in the slotinfo array, so
>> the initial use of the slotinfo array would be incorrect if not
>> for scratch purposes only.
>> 
>> In _dl_tls_initial_modid_limit_setup, the old code relied that
>> some link map was written to the first slotinfo entry.  After the
>> change, this no longer happens because TLS module ID zero is unused.
>> It's also necessary to move the call after the real initialization
>> of the slotinfo array.
>
> Ok, but I did not get what you mean by 'not int right position' fr
> the slotinfo array.  Is is that _dl_add_to_slotinfo might seem wrong
> information that should not initialized?

When used as a scratch array, index zero is populated with a link map.
But there is no zero module ID (zero means no TLS block).  So
_dl_add_to_slotinfo never writes to index zero because the slotinfo
array is indexed by TLS module ID.

Thanks,
Florian



More information about the Libc-alpha mailing list