-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[RISC-V][LLD] Add Support for RISC-V TLSDESC Relocations #66916
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
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ce9772d
[RISCV] Support Global Dynamic TLSDESC in the RISC-V backend
ilovepi 8a7ecf7
!fixup Call and test checkPseudoTLSDESCCall
ilovepi 388dfac
fixup! clang-format
ilovepi ee2f817
Merge branch 'main' into gd-tlsdesc
ilovepi 896ca77
!fixup Address code differences after rebase
ilovepi df381c9
!fixup Remove parsing for `la.tlsdesc`
ilovepi 50d3ffb
!fixup Add TODO to remove the cl::opt option
ilovepi c54f7ac
!fixup Rename getGeneralDynamicTLSDescAddr to getTLSDescAddr
ilovepi 48ed87a
Merge branch 'main' into gd-tlsdesc
ilovepi 152b415
Don't set isAsmParserOnly bits in PseudoLA_TLSDESC
ilovepi 7ba5295
Add back RUN lines to test removed in old rebase
ilovepi 1ba4890
Test tlsdesc relocations in MC layer
ilovepi de4b9fc
Add test for invalid TLSDESC relocations
ilovepi d60118c
Remove trailing whitespace
ilovepi aa301e3
Update error string to match checks
ilovepi dcce101
Fix documentation for fixup_riscv_tlsdesc_load_lo12
ilovepi cde5cba
Run clang-format on patch
ilovepi 2e3d34a
[RISCV] Support RISC-V TLSDESC in LLD
ilovepi dc965af
Add checks both local and global accesses in test
ilovepi df3a919
Merge branch 'main' into lld-tlsdesc
ilovepi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// RUN: llvm-mc -filetype=obj -triple=riscv64-pc-linux %s -o %t.o | ||
// RUN: ld.lld -shared %t.o -o %t.so | ||
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.so | FileCheck %s | ||
// RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=REL %s | ||
|
||
// CHECK: 0000000000001318 <_start>: | ||
// CHECK-NEXT: 1318: auipc a0, 1 | ||
// CHECK-NEXT: 131c: ld a1, 1008(a0) | ||
// CHECK-NEXT: 1320: addi a0, a0, 1008 | ||
// CHECK-NEXT: 1324: jalr t0, a1 | ||
// CHECK-NEXT: 1328: add a0, a0, tp | ||
// CHECK-NEXT: 132c: auipc a0, 1 | ||
// CHECK-NEXT: 1330: ld a1, 1040(a0) | ||
// CHECK-NEXT: 1334: addi a0, a0, 1040 | ||
// CHECK-NEXT: 1338: jalr t0, a1 | ||
// CHECK-NEXT: 133c: add a0, a0, tp | ||
// CHECK-NEXT: 1340: ret | ||
|
||
// REL: Relocation section '.rela.dyn' at offset 0x{{[0-9a-f]+}} contains 3 entries | ||
// REL: R_RISCV_TLSDESC_CALL ffffffffffffffd4 | ||
// REL-NEXT: R_RISCV_TLSDESC_CALL 4 | ||
// REL-NEXT: R_RISCV_TLSDESC_CALL ffffffffffffffe8 | ||
|
||
.text | ||
.attribute 4, 16 | ||
.attribute 5, "rv64i2p1" | ||
.file "<stdin>" | ||
.globl _start # -- Begin function _start | ||
.p2align 2 | ||
.type _start,@function | ||
_start: # @_start | ||
// access local variable | ||
.Ltlsdesc_hi0: | ||
auipc a0, %tlsdesc_hi(unspecified) | ||
ld a1, %tlsdesc_load_lo(.Ltlsdesc_hi0)(a0) | ||
addi a0, a0, %tlsdesc_add_lo(.Ltlsdesc_hi0) | ||
jalr t0, 0(a1), %tlsdesc_call(.Ltlsdesc_hi0) | ||
add a0, a0, tp | ||
|
||
// access global variable | ||
.Ltlsdesc_hi1: | ||
auipc a0, %tlsdesc_hi(unspecified) | ||
ld a1, %tlsdesc_load_lo(.Ltlsdesc_hi1)(a0) | ||
addi a0, a0, %tlsdesc_add_lo(.Ltlsdesc_hi1) | ||
jalr t0, 0(a1), %tlsdesc_call(.Ltlsdesc_hi1) | ||
add a0, a0, tp | ||
ret | ||
.Lfunc_end0: | ||
.size _start, .Lfunc_end0-_start | ||
# -- End function | ||
.section ".note.GNU-stack","",@progbits | ||
|
||
.section .tbss,"awT",@nobits | ||
.p2align 2 | ||
.global v1 | ||
v1: | ||
.zero 4 | ||
|
||
unspecified: | ||
.zero 4 |
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe lld supports TLSDESC for ARM64 because it's the default TLS access model on ARM64. The comment here says that
_TLS_MODULE_BASE_
is defined for targets that support TLSDESC. But theif
condition includes only i386 and x86-64. It doesn't seem correct. Not directly related to this change, though.