This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Add support for tlsldm operator to llvm-mc
ClosedPublic

Authored by peter.smith on Jul 18 2016, 6:36 AM.

Details

Summary

The standard local dynamic model for TLS on ARM systems needs two relocations for each data access:

  • R_ARM_TLS_LDM32 (module idx)
  • R_ARM_TLS_LDO32 (offset of object from origin of module TLS block)

In GNU style assembler we use symbol(tlsldm) and symbol(tlsldo) to produce these relocations.

llvm-mc for ARM supports symbol(tlsldo) but does not support symbol(tlsldm). This patch wires up the existing symbol(tlsldm) support in the assembler to the R_ARM_TLS_LDM32 relocation.

This change is for llvm-mc only, it does not implement lowering of generated TLS code to local-dynamic (-mtls-model=local-dynamic).

TLS for ARM is defined in Addenda to, and Errata in, the ABI for the ARM Architecture

Diff Detail

Event Timeline

peter.smith retitled this revision from to [ARM] Add support for tlsldm operator to llvm-mc.
peter.smith updated this object.
peter.smith added a subscriber: llvm-commits.
rengolin accepted this revision.Jul 19 2016, 6:10 AM
rengolin edited edge metadata.

Simple test comment, otherwise, LGTM. Thanks!

test/MC/ARM/symbol-variants.s
93

why not just put this as the last test and avoid the change to the got_prel part?

This revision is now accepted and ready to land.Jul 19 2016, 6:10 AM

Putting TLSLDM before the GOT_PREL makes all the relocations pair up in source file order. The ldr r3, =f31(GOT_PREL) creates a literal pool entry with a relocation, the literal pool entry will always be at the end so if GOT_PREL isn't at the end of the source file the .word and the literal pool entry R_ARM_GOT_PREL relocations won't appear as a pair like all the others.

I chose to insert before the GOT_PREL to neaten the expected output.

This revision was automatically updated to reflect the committed changes.

Thanks for the review, committed 275977. Will close when bots are ok.