[llvm-dev] [LLD] TLS tbss section discrepancy to gnu-ld

Joerg Sonnenberger via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 30 16:56:02 PDT 2021


On Fri, Jul 30, 2021 at 08:20:22AM +0200, Noah Hütter via llvm-dev wrote:
> 
> 
> On 7/29/21 6:06 PM, Joerg Sonnenberger via llvm-dev wrote:
> > On Thu, Jul 29, 2021 at 11:55:54AM +0200, Noah Hütter via llvm-dev wrote:
> >> What is the proper way to determine the tbss section size in LLD?
> > 
> > Why don't you use the program header for that?
> 
> We have a bare-metal target and the ELF contains the crt0 that
> initializes the tls region so we need to know the tbss size at link
> time. Exactly as for a regular bss section, we need sbss and ebss at
> link time for our loader to initialize this section

I don't understand what you are trying to say. The PT_TLS segment will
tell you exactly where the TLS block is and what size should be
allocated for the per thread data. That's also normally something the
runtime is doing and not the loader, simply because it is part of the
thread creation logic.

Joerg


More information about the llvm-dev mailing list