Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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 llvm-svn: 361910
- Loading branch information
Showing
6 changed files
with
61 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# RUN: llvm-mc -triple i386-pc-linux-musl %s | FileCheck --check-prefix=PRINT %s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple i386-pc-linux-musl %s -o %t | ||
# RUN: llvm-readelf -s %t | FileCheck --check-prefix=SYM %s | ||
# RUN: llvm-objdump -dr --no-show-raw-insn %t | FileCheck %s | ||
|
||
# PRINT: leal a@tlsdesc(%ebx), %eax | ||
# PRINT-NEXT: calll *a@tlscall(%eax) | ||
|
||
# SYM: TLS GLOBAL DEFAULT UND a | ||
|
||
# CHECK: 0: leal (%ebx), %eax | ||
# CHECK-NEXT: 00000002: R_386_TLS_GOTDESC a | ||
# CHECK-NEXT: 6: calll *(%eax) | ||
# CHECK-NEXT: 00000006: R_386_TLS_DESC_CALL a | ||
|
||
leal a@tlsdesc(%ebx), %eax | ||
call *a@tlscall(%eax) | ||
addl %gs:0, %eax |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# RUN: llvm-mc -triple x86_64-pc-linux-musl %s | FileCheck --check-prefix=PRINT %s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-musl %s -o %t | ||
# RUN: llvm-readelf -s %t | FileCheck --check-prefix=SYM %s | ||
# RUN: llvm-objdump -dr --no-show-raw-insn %t | FileCheck --match-full-lines %s | ||
|
||
# PRINT: leaq a@tlsdesc(%rip), %rax | ||
# PRINT-NEXT: callq *a@tlscall(%rax) | ||
|
||
# SYM: TLS GLOBAL DEFAULT UND a | ||
|
||
# CHECK: 0: leaq (%rip), %rax | ||
# CHECK-NEXT: 0000000000000003: R_X86_64_GOTPC32_TLSDESC a-4 | ||
# CHECK-NEXT: 7: callq *(%rax) | ||
# CHECK-NEXT: 0000000000000007: R_X86_64_TLSDESC_CALL a | ||
|
||
leaq a@tlsdesc(%rip), %rax | ||
call *a@tlscall(%rax) | ||
addq %fs:0, %rax |