Noah Hütter via llvm-dev
2021-Jul-29 09:55 UTC
[llvm-dev] [LLD] TLS tbss section discrepancy to gnu-ld
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 -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 495 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210729/928a6d9d/attachment.sig>
Joerg Sonnenberger via llvm-dev
2021-Jul-29 16:06 UTC
[llvm-dev] [LLD] TLS tbss section discrepancy to gnu-ld
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? Joerg
Fangrui Song via llvm-dev
2021-Jul-31 02:27 UTC
[llvm-dev] [LLD] TLS tbss section discrepancy to gnu-ld
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? > >NoahThe 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
Noah Hütter via llvm-dev
2021-Aug-01 09:15 UTC
[llvm-dev] [LLD] TLS tbss section discrepancy to gnu-ld
> 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.0That is exactly what solved my problem, thanks! Happy to see this in 13.0.0. @Joerg We (mis)use the TLS section for hardware threads in a cluster of RISCV cores that executes a statically linked binary. The TLS allocation is done by each hart at boot. The cluster doesn't have access to the ELF but copies (t)data to its local memory. We don't have a loader nor thread creation logic in that regard. -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 495 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210801/7e88cbf5/attachment.sig>