-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm][MC][ARM][Assembly] Emit relocations for LDRs #72873
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7515480
[llvm][MC][ARM][Assembly] Emit relocs for LDRs
eleanor-arm 65a1037
Fixup: Fix clang-format
eleanor-arm c267cca
Fixup: Comment in imm8-relocs test
eleanor-arm d5ec983
fixup: simplify checks & add more label+-imm test coverage
eleanor-arm 06f74e6
Fixup: use regex to pick up both decimal and hex format
eleanor-arm 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@ RUN: llvm-mc -filetype=obj -triple=armv7 %s -o %t | ||
@ RUN: llvm-readelf -r %t | FileCheck %s --check-prefix=ARM | ||
@ RUN: llvm-objdump -d --triple=armv7 %t | FileCheck %s --check-prefix=ARM_ADDEND | ||
|
||
@ ARM: R_ARM_LDRS_PC_G0 | ||
@ ARM: R_ARM_LDRS_PC_G0 | ||
@ ARM: R_ARM_LDRS_PC_G0 | ||
@ ARM: R_ARM_LDRS_PC_G0 | ||
@ ARM: R_ARM_LDRS_PC_G0 | ||
@ ARM: R_ARM_LDRS_PC_G0 | ||
|
||
// The value format is decimal in these specific cases, but it's hex for other | ||
// ldr instructions. These checks are valid for both formats. | ||
|
||
@ ARM_ADDEND: r0, [pc, #-{{(0x)?}}8] | ||
@ ARM_ADDEND: r0, [pc, #-{{(0x)?}}8] | ||
@ ARM_ADDEND: r0, [pc, #-{{(0x)?}}8] | ||
@ ARM_ADDEND: r0, [pc, #-{{16|0x10}}] | ||
@ ARM_ADDEND: r0, [pc, #-{{16|0x10}}] | ||
@ ARM_ADDEND: r0, [pc] | ||
|
||
.arm | ||
.section .text.bar, "ax" | ||
.balign 4 | ||
.global bar | ||
.type bar, %function | ||
bar: | ||
ldrh r0, foo | ||
ldrsb r0, foo | ||
ldrsh r0, foo | ||
ldrh r0, just_after-8 | ||
ldrsb r0, just_after-8 | ||
ldrsh r0, foo+8 | ||
bx lr | ||
|
||
.section .data.foo, "a", %progbits | ||
.balign 4 | ||
.global foo | ||
foo: | ||
.word 0x11223344, 0x55667788 | ||
just_after: | ||
.word 0x9900aabb, 0xccddeeff |
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,46 @@ | ||
@ RUN: llvm-mc -filetype=obj -triple=armv7 %s -o %t | ||
@ RUN: llvm-readelf -r %t | FileCheck %s --check-prefix=ARM | ||
@ RUN: llvm-objdump -d --triple=armv7 %t | FileCheck %s --check-prefix=ARM_ADDEND | ||
@ RUN: llvm-mc -filetype=obj -triple=thumbv7 %s -o %t | ||
@ RUN: llvm-readelf -r %t | FileCheck %s --check-prefix=THUMB | ||
@ RUN: llvm-objdump -d --triple=thumbv7 %t | FileCheck %s --check-prefix=THUMB_ADDEND | ||
|
||
@ ARM: R_ARM_LDR_PC_G0 | ||
@ ARM: R_ARM_LDR_PC_G0 | ||
@ ARM: R_ARM_LDR_PC_G0 | ||
@ ARM: R_ARM_LDR_PC_G0 | ||
|
||
@ ARM_ADDEND: r0, [pc, #-0x8] | ||
@ ARM_ADDEND: r0, [pc, #-0x8] | ||
@ ARM_ADDEND: r0, [pc, #-0x10] | ||
@ ARM_ADDEND: r0, [pc] | ||
|
||
@ THUMB: R_ARM_THM_PC12 | ||
@ THUMB: R_ARM_THM_PC12 | ||
@ THUMB: R_ARM_THM_PC12 | ||
@ THUMB: R_ARM_THM_PC12 | ||
|
||
@ THUMB_ADDEND: r0, [pc, #-0x4] | ||
@ THUMB_ADDEND: r0, [pc, #-0x4] | ||
@ THUMB_ADDEND: r0, [pc, #-0xc] | ||
@ THUMB_ADDEND: r0, [pc, #0x4] | ||
|
||
.section .text.bar, "ax" | ||
.balign 4 | ||
.global bar | ||
.type bar, %function | ||
bar: | ||
ldr r0, foo1 | ||
ldrb r0, foo1 | ||
ldr r0, foo2-8 | ||
ldrb r0, foo1+8 | ||
bx lr | ||
|
||
.section .data.foo, "a", %progbits | ||
.balign 4 | ||
.global foo1 | ||
.global foo2 | ||
foo1: | ||
.word 0x11223344, 0x55667788 | ||
foo2: | ||
.word 0x99aabbcc, 0xddeeff00 |
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,41 @@ | ||
@ RUN: llvm-mc -filetype=obj -triple=thumbv7 %s -o %t | ||
@ RUN: llvm-readelf -r %t | FileCheck %s --check-prefix=THUMB | ||
@ RUN: llvm-objdump -d --triple=thumbv7 %t | FileCheck %s --check-prefix=THUMB_ADDEND | ||
|
||
@ All the ldr variants produce a relocation | ||
@ THUMB: R_ARM_THM_PC12 | ||
@ THUMB: R_ARM_THM_PC12 | ||
@ THUMB: R_ARM_THM_PC12 | ||
@ THUMB: R_ARM_THM_PC12 | ||
@ THUMB: R_ARM_THM_PC12 | ||
@ THUMB: R_ARM_THM_PC12 | ||
|
||
@ THUMB_ADDEND: r0, [pc, #-0x4] | ||
@ THUMB_ADDEND: r0, [pc, #-0x4] | ||
@ THUMB_ADDEND: r0, [pc, #-0x4] | ||
@ THUMB_ADDEND: r0, [pc, #0x4] | ||
@ THUMB_ADDEND: r0, [pc, #-0xc] | ||
@ THUMB_ADDEND: r0, [pc, #0x4] | ||
|
||
.thumb | ||
.section .text.bar, "ax" | ||
.balign 4 | ||
.global bar | ||
.type bar, %function | ||
bar: | ||
ldrh r0, foo1 | ||
ldrsb r0, foo1 | ||
ldrsh r0, foo1 | ||
ldrh r0, foo1+8 | ||
ldrsb r0, foo2-8 | ||
ldrsh r0, foo1+8 | ||
bx lr | ||
|
||
.section .data.foo, "a", %progbits | ||
.balign 4 | ||
.global foo1 | ||
.global foo2 | ||
foo1: | ||
.word 0x11223344, 0x55667788 | ||
foo2: | ||
.word 0x9900aabb, 0xccddeeff |
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
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.
Uh oh!
There was an error while loading. Please reload this page.