Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pauthabi64] Add Auth variants of TLSDESC generating GOT relocations #295

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

smithp35
Copy link
Contributor

@smithp35 smithp35 commented Nov 5, 2024

Add static Auth equivalents of the existing relocations:

  • R_AARCH64_TLSDESC_ADR_PAGE21
  • R_AARCH64_TLSDESC_LD64_LO12
  • R_AARCH64_TLSDESC_ADD_LO12

These are sufficient to implement the small code-model for TLSDESC using the PAuthABI. Support for the tiny and large code-model is not implemented for the PAuthABI, or for the normal ABI in both clang and GCC so we defer from specifiying Auth variants of all possible relocations.

I've followed the convention that non-zero addends are not permitted for GOT generating relocations. As each unique S+A combination needs its own pair of GOT slots indexed by S+A and no static linker supports that.

Fixes #293

Add static Auth equivalents of the existing relocations:
* R_AARCH64_TLSDESC_ADR_PAGE21
* R_AARCH64_TLSDESC_LD64_LO12
* R_AARCH64_TLSDESC_ADD_LO12

These are sufficient to implement the small code-model for TLSDESC
using the PAuthABI. Support for the tiny and large code-model is
not implemented for the PAuthABI, or for the normal ABI in both
clang and GCC so we defer from specifiying Auth variants of all
possible relocations.

I've followed the convention that non-zero addends are not
permitted for GOT generating relocations. As each unique S+A
combination needs its own pair of GOT slots indexed by S+A and
no static linker supports that.

Fixes ARM-software#293
kovdan01 added a commit to llvm/llvm-project that referenced this pull request Nov 18, 2024
smithp35 added a commit to smithp35/abi-aa that referenced this pull request Nov 29, 2024
In the initial draft relocations for signing GOT entries were
defined in the private space reserved for experiments. It was not
known if these relocations would be useful as if RELRO is supported
the GOT does not need to be signed. There is now at least one user
of the GOT signing relocations so we should move the relocations
out of the private space and into the space reserved for the
PAuthABI.

This PR includes relocations added in
ARM-software#295

Fixes: ARM-software#298
+-------------+----------------------------------------+----------------------------------------+--------------------------+
| 0x811E | R\_AARCH64\_AUTH\_TLSDESC\_ADR\_PAGE21 | Page(G(ENCD(GTLSDESC(S)))) - Page(P) | Set an ADRP immediate |
| | | | field to bits [32:12] of |
| | | | X; check –2\ :sup:`20` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The range for ADRP is ±4GB [1], so I think that the check should be between -2^32 and 2^32, instead of 20.

[1] https://developer.arm.com/documentation/100076/0100/A64-Instruction-Set-Reference/A64-General-Instructions/ADRP

Copy link
Contributor Author

@smithp35 smithp35 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. It looks like I used the text from R_<CLS>_TLSDESC_ ADR_PREL21 in the table rather than the similarly named R_<CLS>_TLSDESC_ ADR_PAGE21

Will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR to use -2^32 and 2^32

The R_AARCH64_AUTH_TLSDESC_ADR_PAGE21 now has the correct range
check of +- 2^32.
Copy link
Member

@stuij stuij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@smithp35 smithp35 merged commit dbe1d94 into ARM-software:main Jan 9, 2025
1 check passed
smithp35 added a commit to smithp35/abi-aa that referenced this pull request Jan 9, 2025
In the initial draft relocations for signing GOT entries were
defined in the private space reserved for experiments. It was not
known if these relocations would be useful as if RELRO is supported
the GOT does not need to be signed. There is now at least one user
of the GOT signing relocations so we should move the relocations
out of the private space and into the space reserved for the
PAuthABI.

This PR includes relocations added in
ARM-software#295

Fixes: ARM-software#298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pauthabielf64] Define static AUTH TLSDESC relocations
2 participants