[PATCH v4] ld/pe-dll: Don't auto-export symbols from .tls section
Jan Beulich
jbeulich@suse.com
Mon Jan 26 08:15:23 GMT 2026
On 26.01.2026 04:43, LIU Hao wrote:
> 在 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.
Mind me asking back: Before asking, did you check the tree?
Jan
More information about the Binutils
mailing list