[PATCH v4] ld/pe-dll: Don't auto-export symbols from .tls section
LIU Hao
lh_mouse@126.com
Mon Jan 26 03:43:04 GMT 2026
在 2026-1-26 11:42, LIU Hao 写道:
> 在 2025-12-11 17:50, Jan Beulich 写道:
>> This is all reasonably okay as far as C code goes. As previously mentioned, in
>> e.g. assembly code or with a custom linker script .tls itself could very well
>> be usable. (Of course with a custom linker script, significance of section
>> names goes away anyway when it comes to ld or bfd code.)
>
> The section names are hard-coded in compilers. If one would like to handcraft thread-local variables
> without using a compiler (using assembly directly), they had better create `IMAGE_TLS_DIRECTORY` themself
> without relying this section-sorting magic, and TLS initializers are really conventional data that can be
> put in `.rdata`.
>
>
>
>> This is factually wrong. The symbols there _are_ used to access the variables,
>> just that the involved relocations are SECREL ones, i.e. ...
>>
>>> only offsets to the
>>> + beginning of the .tls output section matter, but the offsets
>>> + can't be exported.
>>
>> ... yield offsets. The difficulty with using them from another binary is to
>> actually arrange for the SECREL-ness there (when the necessary information
>> isn't represented in .edata / .idata).
>>
>> I'm sorry to be picky, but imprecise comments can do more harm than good.
>
> Right, right, there's not gonna be a change about code, so would you please update the comments as you
> see fit? I'm less picky so I kinda believe you can do a better job than me.
Hello, what's the status of this patch? Thanks in advance.
--
Best regards,
LIU Hao
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20260126/8183f261/attachment.sig>
More information about the Binutils
mailing list