[AArch64] Implement TLS relaxations#1213
Open
deepakshirkem wants to merge 5 commits into
Open
Conversation
Extend IE->LE relaxation in tls_gottprel_page and tls_gottprel_lo to cover global TLS symbols in static executables. Previously only local symbols (without ReserveGOT) were relaxed. Fixes part of qualcomm#1004 Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
Preserve destination register (Rd) when relaxing TLSDESC_LD64_LO12 to movk in static executables. Previously x0 was hardcoded. Also extend relaxation to cover global symbols in static executables by adding isCodeStatic() check, matching the IE->LE fix. Fixes part of qualcomm#1004 Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
…cutables Extend TLSDESC->LE relaxation in tls_tlsdesc_page to cover global TLS symbols in static executables by adding isCodeStatic() check. Also fix tls_tlsdesc_lo to always use x0 for the relaxed movk instruction, matching LLD behavior and ensuring the TLS offset is in the correct register after relaxation. Add test for TLSDESC->LE relaxation covering both global and local TLS symbols. Fixes part of qualcomm#1004 Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
For PIE executables, relax TLSDESC sequences to Initial Exec (IE) instead of keeping the expensive TLSDESC runtime resolver call. Changes: - scanLocalReloc/scanGlobalReloc: detect isPIE() and create IE GOT entry with R_AARCH64_TLS_TPREL64 dynamic relocation instead of TLSDESC GOT with R_AARCH64_TLSDESC - tls_tlsdesc_lo: rewrite ldr to IE GOT load into x0 for PIE - tls_tlsdesc_add: emit nop for PIE (matching static behavior) - tls_call: emit nop for PIE (matching static behavior) - Update DESC.test placeholder with correct CHECK lines - Add TLS_DESC_PIE.test to verify TLSDESC->IE relaxation Fixes part of qualcomm#1004 Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
Add TLS_Relaxation_Verify test using real compiler-generated TLS relocations to verify end-to-end correctness of relaxations: - TLSDESC->LE for static executables (movz+movk+nop+nop) - TLSDESC->IE for PIE executables (adrp+ldr+nop+nop) - R_AARCH64_TLS_TPREL64 dynamic reloc present in PIE Add IE_PIE test to verify IE relocations remain as GOT-indirect adrp+ldr in PIE executables. Fixes part of qualcomm#1004 Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes part of #1004
Implements TLS relaxations for AArch64 covering all TLS access models supported by the AArch64 ABI
Implementation follows LLD's AArch64 TLS relaxation in lld/ELF/Arch/AArch64.cpp (relaxTlsGdToLe, relaxTlsGdToIe,
relaxTlsIeToLe).
CC @parth-07 @quic-seaswara @quic-areg