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

Fangrui Song via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 30 19:27:52 PDT 2021


On 2021-07-29, Noah Hütter via llvm-dev wrote:
>Hi all,
>
>When porting a project from using GNU-gcc to LLVM with LLD I encounter
>this discrepancy in the `__tbss_end` symbol.
>
>With an explicit linker script, the __tbss_end symbols has the same
>value as __tbss_start:
>
>.tbss :
>{
>  __tbss_start = .;
>  *(.tbss .tbss.* .gnu.linkonce.tb.*)
>  *(.tcommon)
>  __tbss_end = .;
>}
>
>LD correctly assigns the end to __tbss_end. We need to determine the
>size of the tbss section to initialize it on our bare-metal target.
>
>What is the proper way to determine the tbss section size in LLD?
>
>Noah

The incorrect dot is related to ThreadBssOffset.

When location counter was implemented (during
http://reviews.llvm.org/D18499 and rL282147 time), ThreadBssOffset was
added to support multiple tbss sections.

This has limited support in ld.lld and isn't supported by GNU ld.

I sent https://reviews.llvm.org/D107208 to make __tbss_end = .; work.

Happy to back port it into 13.0.0


More information about the llvm-dev mailing list