-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[JITLink][AArch32] Fix Unaligned Data Symbol Address Resolution #97030
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 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5244f5f
[JITLink][AArch32] Fix Unaligned Data Symbol Address Resolution
eymay 608326f
Enhance the test with LinkGraph and additional checks
eymay 9fffa30
Make FileCheck checks stricter
eymay aa0b3f2
Turn the condition check from OBJECT to FUNC
eymay 0859338
Make the checker expressions prettier
eymay 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
72 changes: 72 additions & 0 deletions
72
llvm/test/ExecutionEngine/JITLink/AArch32/ELF_data_alignment.s
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,72 @@ | ||
# RUN: llvm-mc -triple=armv7-linux-gnueabi -arm-add-build-attributes -filetype=obj -o %t_armv7.o %s | ||
# RUN: llvm-objdump -s --section=.rodata %t_armv7.o | FileCheck --check-prefix=CHECK-OBJ %s | ||
# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 -slab-allocate 10Kb \ | ||
# RUN: -slab-page-size 4096 %t_armv7.o -debug-only=jitlink 2>&1 \ | ||
# RUN: | FileCheck --check-prefix=CHECK-LG %s | ||
# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 -slab-allocate 10Kb \ | ||
# RUN: -slab-page-size 4096 %t_armv7.o -check %s | ||
|
||
# RUN: llvm-mc -triple=thumbv7-linux-gnueabi -arm-add-build-attributes -filetype=obj -o %t_thumbv7.o %s | ||
# RUN: llvm-objdump -s --section=.rodata %t_thumbv7.o | FileCheck --check-prefix=CHECK-OBJ %s | ||
# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 -slab-allocate 10Kb \ | ||
# RUN: -slab-page-size 4096 %t_thumbv7.o -debug-only=jitlink 2>&1 \ | ||
# RUN: | FileCheck --check-prefix=CHECK-LG %s | ||
# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 -slab-allocate 10Kb \ | ||
# RUN: -slab-page-size 4096 %t_thumbv7.o -check %s | ||
|
||
# The strings of "H1\00", "H2\00" and "H3\00" are encoded as | ||
# 0x483100, 0x483200 and 0x483300 .rodata section. | ||
# CHECK-OBJ: Contents of section .rodata: | ||
# CHECK-OBJ: 0000 48310048 32004833 00 H1.H2.H3. | ||
|
||
# CHECK-LG: Starting link phase 1 for graph | ||
# CHECK-LG: section .rodata: | ||
|
||
# CHECK-LG: block 0x0 size = 0x00000009, align = 1, alignment-offset = 0 | ||
# CHECK-LG-NEXT: symbols: | ||
# CHECK-LG-NEXT: 0x0 (block + 0x00000000): size: 0x00000003, linkage: strong, scope: default, live - Lstr.H1 | ||
# CHECK-LG-NEXT: 0x3 (block + 0x00000003): size: 0x00000003, linkage: strong, scope: default, live - Lstr.H2 | ||
# CHECK-LG-NOT: 0x2 (block + 0x00000002): size: 0x00000003, linkage: strong, scope: default, live - Lstr.H2 | ||
# CHECK-LG-NEXT: 0x6 (block + 0x00000006): size: 0x00000003, linkage: strong, scope: default, live - Lstr.H3 | ||
|
||
# FIXME: The expression we want is either *{3}(Lstr.H1) = ... | ||
# or *{4}(Lstr.H1) & 0x00ffffff = ... | ||
# The first is not supported and the latter segfaults. | ||
# Also, whitespaces are not recognized and not consumed by the checker. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you could write either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does! Thanks for the tip. |
||
|
||
# jitlink-check: Lstr.H1 = 0x76ff0000 | ||
# jitlink-check: 0x00ffffff&*{4}(Lstr.H1) = 0x003148 | ||
.globl Lstr.H1 | ||
.type Lstr.H1,%object | ||
.section .rodata,"a",%progbits | ||
Lstr.H1: | ||
.asciz "H1" | ||
.size Lstr.H1, 3 | ||
|
||
# H2 is unaligned as its beginning address is base address + 0x3 | ||
# Make sure the string we get is 0x003248 and not 0x324800 | ||
# jitlink-check: Lstr.H2 = 0x76ff0003 | ||
# jitlink-check: 0x00ffffff&*{4}(Lstr.H2) = 0x003248 | ||
.globl Lstr.H2 | ||
.type Lstr.H2,%object | ||
Lstr.H2: | ||
.asciz "H2" | ||
.size Lstr.H2, 3 | ||
|
||
# jitlink-check: Lstr.H3 = 0x76ff0006 | ||
# jitlink-check: 0x00ffffff&*{4}(Lstr.H3) = 0x003348 | ||
.globl Lstr.H3 | ||
.type Lstr.H3,%object | ||
Lstr.H3: | ||
.asciz "H3" | ||
.size Lstr.H3, 3 | ||
|
||
.text | ||
.syntax unified | ||
# Empty main function for jitlink to be happy | ||
.globl main | ||
.type main,%function | ||
.p2align 2 | ||
main: | ||
bx lr | ||
.size main,.-main |
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.
With your fix in
getRawOffset()
this check shouldn't be necessary anymore, isn't it? Instead we might want to assert that all symbols with theThumbSymbol
target flag areELF::STT_FUNC
.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.
Agree but I had to keep it because of a failed assert in
llvm-project/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
Line 52 in f1faba2
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.
Updated the condition to check for
STT_FUNC
. I found a similar assert to what you mentioned in the previous comment, should I still add one?