llvm-project
f1da2ebe - [ELF] Handle and optimize x86-64 PLTOFF64 TLS sequences (#216263)

Commit
92 days ago
[ELF] Handle and optimize x86-64 PLTOFF64 TLS sequences (#216263) In `gcc -mcmodel=large` generated General Dynamic/Local Dynamic TLS sequences, R_X86_64_TLSGD/R_X86_64_TLSLD is followed by a MOVABS loading `__tls_get_addr@pltoff`, and the call goes through a register: ``` leaq x@tlsgd(%rip), %rdi # R_X86_64_TLSGD movabsq $__tls_get_addr@pltoff, %rax # R_X86_64_PLTOFF64 addq %rbx, %rax callq *%rax ``` `relaxTlsGdToLe` and `relaxTlsGdToIe` write the 16-byte direct call sequence at loc-4, corrupting the preceding instruction, while `relaxTlsLdToLe` reports "expected R_X86_64_PLT32 or R_X86_64_GOTPCRELX after R_X86_64_TLSLD". Detect the MOVABS and rewrite the 22 bytes, matching GNU ld. `__tls_get_addr` doesn't need to be defined when optimized to LE/IE, LLM-aided
Author
Parents
Loading