Open kovdan01 opened 1 month ago
Tagging @smithp35 @asl
@smithp35 I've submitted a PR to llvm-project repo adding the relocs with the following codes (the latest code for previously defined GOT-generating relocs was 0x811d) - see https://github.com/llvm/llvm-project/pull/113716:
R_AARCH64_AUTH_TLSDESC_ADR_PAGE21 0x811e
R_AARCH64_AUTH_TLSDESC_LD64_LO12 0x811f
R_AARCH64_AUTH_TLSDESC_ADD_LO12 0x8120
Please let me know if these code are OK.
My apologies, I'll be out of office for the the week of 28th October to the 1st November so this is a quick response at the weekend. I'll get back to this when I'm back in the office in a week's time.
The relocation codes are OK for now [1] as they are in the private space reserved for experiments https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#5714private-and-platform-specific-relocations
The GOT signing relocations are currently in the private space. As I understand it there's a high chance that these will be needed. When they stabilise we'll need to move them to the space reserved for PAuthABI https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#5716pauthabi-relocations
What I think needs doing:
There's a separate topic of moving the relocations from the private experiment space.
@smithp35 Thanks for your feedback!
- There are more non-auth TLSDESC relocations defined in AAELF64. Is it worth defining AUTH equivalents for these (assuming they are relevant to PAuth; I've not checked)?
These three should be enough for working TLSDESC implementation - we have llvm codegen https://github.com/llvm/llvm-project/pull/113813, lld linker https://github.com/llvm/llvm-project/pull/113817 and musl dynamic loader https://github.com/access-softek/musl/pull/2 patches for that, and the functionality was also tested in runtime, not only by lit tests.
It actually looks like that other non-auth TLSDESC-related relocs from this section https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#57115thread-local-storage-descriptors are not even used by llvm-project. Some of them (R_<CLS>_TLSDESC_ LD_PREL19
, R_<CLS>_TLSDESC_ ADR_PREL21
) seem to be intended for usage with tiny code model, for some others (R_<CLS>_TLSDESC_ OFF_G1
, R_<CLS>_TLSDESC_ OFF_G0_NC
) I'm not even sure what's their purpose. Anyway, the three relocs listed above should definitely be enough for "default" implementation matching existing non-auth implementation in llvm's backend.
- Make sure we're happy with the names. From a glance they look fine.
I've just added AUTH to the following non-auth reloc names: R_<CLS>_TLSDESC_ADR_PAGE21
, R_<CLS>_TLSDESC_LD64_LO12
, R_<CLS>_TLSDESC_ADD_LO12
. I would be happy if you double-check that it's OK :)
- Update the PAuthABI spec.
I can submit a corresponding PR if you wish - just let me know if you want me to do that or if you plan to do it by yourself later.
Just got back to the office today, apologies for the delay in responding.
I can post a patch to the ABI tomorrow.
Looking at the initial proposals for the relocation, the code sequences for the tiny and large code-models use these relocations. Although to the best of my knowledge both clang and GCC only implement the small code-model for accessing TLS.
I agree that we don't need to specify relocations for these until someone wants to optimise TLSDESC for the tiny code-model.
Tiny:
ldr x1, :tlsdesc:var R_AARCH64_TLSDESC_LD_PREL19 var
adr x0, :tlsdesc:var R_AARCH64_TLSDESC_ADR_PREL21 var
.tlsdesccall var
blr x1 R_AARCH64_TLSDESC_CALL var
Large:
# gp = register containing address of GOT.
movz x0, #:tlsdesc_off_g1:var R_AARCH64_TLSDESC_OFF_G1 var
movk x0, #:tlsdesc_off_g0_nc:var R_AARCH64_TLSDESC_OFF_G0_NC var
.tlsdescldr var
ldr x1, [gp, x0] R_AARCH64_TLSDESC_LDR var
.tlsdescadd var
add x0, gp, x0 R_AARCH64_TLSDESC_ADD var
.tlsdesccall var
blr x1 R_AARCH64_TLSDESC_CALL var
I've submitted https://github.com/ARM-software/abi-aa/pull/295 for review
In pauthabielf64, dynamic AUTH TLSDESC relocation
R_AARCH64_AUTH_TLSDESC
is defined https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#auth-variant-got-generating-relocations.However, the section with AUTH variant GOT-generating relocations does not contain definitions for static TLSDESC relocs: https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#auth-variant-got-generating-relocations.
Particularly, the following relocation types are missing and should be defined:
R_AARCH64_AUTH_TLSDESC_ADR_PAGE21
R_AARCH64_AUTH_TLSDESC_LD64_LO12
R_AARCH64_AUTH_TLSDESC_ADD_LO12