]> granicus.if.org Git - llvm/commit
[X86] Fix x86-64 call *foo@tlsdesc(%rax) and support R_386_TLSGOTDESC R_386_TLS_DESC_CALL
authorFangrui Song <maskray@google.com>
Wed, 29 May 2019 02:02:59 +0000 (02:02 +0000)
committerFangrui Song <maskray@google.com>
Wed, 29 May 2019 02:02:59 +0000 (02:02 +0000)
commit87dc5aca14d66ce15aded7f8475fce29e19f0c9c
treeb5533d4a0b9435c6814889eb761e8b9df89dace4
parent224fbc5082f05a514792a36cb21df741aa000851
[X86] Fix x86-64 call *foo@tlsdesc(%rax) and support R_386_TLSGOTDESC R_386_TLS_DESC_CALL

D18885 emitted 5 bytes for call *foo@tlsdesc(%rax). It should use the
2-byte form instead and let R_X86_64_TLSDESC_CALL apply to the beginning
of the call instruction.

The 2-byte form was deliberately chosen to make ->LE and ->IE relaxation work:

    0:   48 8d 05 00 00 00 00    lea    0x0(%rip),%rax        # 7 <.text+0x7>
                         3: R_X86_64_GOTPC32_TLSDESC     a-0x4
    7:   ff 10                   callq  *(%rax)
                         7: R_X86_64_TLSDESC_CALL        a

=>

    0:   48 c7 c0 fc ff ff ff    mov    $0xfffffffffffffffc,%rax
    7:   66 90                   xchg   %ax,%ax

Also change the symbol type to STT_TLS when VK_TLSCALL or VK_TLSDESC is
seen.

Reviewed By: compnerd

Differential Revision: https://reviews.llvm.org/D62512

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361910 91177308-0d34-0410-b5e6-96231b3b80d8
lib/MC/MCELFStreamer.cpp
lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
test/MC/ELF/relocation-tls.s [deleted file]
test/MC/X86/tlsdesc-32.s [new file with mode: 0644]
test/MC/X86/tlsdesc-64.s [new file with mode: 0644]