-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[lld][LoongArch] Support the R_LARCH_{ADD,SUB}_ULEB128 relocation types #81133
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
6 commits
Select commit
Hold shift + click to select a range
03866c8
[lld][LoongArch] Support the R_LARCH_{ADD,SUB}_ULEB128 relocation types
MQ-mengqing f53db4f
Address @SixWeining's comments
MQ-mengqing d389797
Remove useless `--noinhibit-exec`
MQ-mengqing 7687cc3
Remove err parameter in decodeULEB128 and use 1ULL when shift
MQ-mengqing c860d46
Address @MaskRay's comments
MQ-mengqing 7793126
Add elf32 test and use 64bits uleb128 value
MQ-mengqing 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# REQUIRES: loongarch | ||
# RUN: rm -rf %t && split-file %s %t && cd %t | ||
|
||
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=+relax a.s -o a.o | ||
# RUN: llvm-readobj -r -x .gcc_except_table -x .debug_rnglists -x .debug_loclists a.o | FileCheck %s --check-prefix=REL | ||
# RUN: ld.lld -shared --gc-sections a.o -o a.so | ||
# RUN: llvm-readelf -x .gcc_except_table -x .debug_rnglists -x .debug_loclists a.so | FileCheck %s | ||
|
||
# RUN: llvm-mc --filetype=obj --triple=loongarch32 --mattr=+relax a.s -o a32.o | ||
# RUN: llvm-readobj -r -x .gcc_except_table -x .debug_rnglists -x .debug_loclists a32.o | FileCheck %s --check-prefix=REL | ||
# RUN: ld.lld -shared --gc-sections a32.o -o a32.so | ||
# RUN: llvm-readelf -x .gcc_except_table -x .debug_rnglists -x .debug_loclists a32.so | FileCheck %s | ||
|
||
# RUN: llvm-mc --filetype=obj --triple=loongarch32 --mattr=+relax extraspace.s -o extraspace32.o | ||
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=+relax extraspace.s -o extraspace64.o | ||
# RUN: not ld.lld -shared extraspace32.o 2>&1 | FileCheck %s --check-prefix=ERROR | ||
# RUN: not ld.lld -shared extraspace64.o 2>&1 | FileCheck %s --check-prefix=ERROR | ||
# ERROR: error: extraspace{{.*}}.o:(.rodata+0x0): extra space for uleb128 | ||
|
||
#--- a.s | ||
.cfi_startproc | ||
.cfi_lsda 0x1b,.LLSDA0 | ||
.cfi_endproc | ||
|
||
.section .text.w,"axR" | ||
break 0; break 0; break 0; w1: | ||
.p2align 4 # 4 bytes after relaxation | ||
w2: break 0 | ||
|
||
.section .text.x,"ax" | ||
break 0; break 0; break 0; x1: | ||
.p2align 4 # 4 bytes after relaxation | ||
x2: break 0 | ||
|
||
.section .gcc_except_table,"a" | ||
.LLSDA0: | ||
.uleb128 w2-w1+116 # initial value: 0x0080 | ||
.uleb128 w1-w2+141 # initial value: 0x0080 | ||
.uleb128 w2-w1+16372 # initial value: 0x008080 | ||
.uleb128 w1-w2+16397 # initial value: 0x008080 | ||
.uleb128 w2-w1+2097140 # initial value: 0x00808080 | ||
.uleb128 w1-w2+2097165 # initial value: 0x00808080 | ||
|
||
.section .debug_rnglists | ||
.uleb128 w2-w1+116 # initial value: 0x0080 | ||
.uleb128 w1-w2+141 # initial value: 0x0080 | ||
.uleb128 w2-w1+16372 # initial value: 0x008080 | ||
.uleb128 w1-w2+16397 # initial value: 0x008080 | ||
.uleb128 w2-w1+2097140 # initial value: 0x00808080 | ||
.uleb128 w1-w2+2097165 # initial value: 0x00808080 | ||
|
||
.section .debug_loclists | ||
.uleb128 x2-x1 # references discarded symbols | ||
|
||
# REL: Section ({{.*}}) .rela.debug_rnglists { | ||
# REL-NEXT: 0x0 R_LARCH_ADD_ULEB128 w2 0x74 | ||
# REL-NEXT: 0x0 R_LARCH_SUB_ULEB128 w1 0x0 | ||
# REL-NEXT: 0x2 R_LARCH_ADD_ULEB128 w1 0x8D | ||
# REL-NEXT: 0x2 R_LARCH_SUB_ULEB128 w2 0x0 | ||
# REL-NEXT: 0x4 R_LARCH_ADD_ULEB128 w2 0x3FF4 | ||
# REL-NEXT: 0x4 R_LARCH_SUB_ULEB128 w1 0x0 | ||
# REL-NEXT: 0x7 R_LARCH_ADD_ULEB128 w1 0x400D | ||
# REL-NEXT: 0x7 R_LARCH_SUB_ULEB128 w2 0x0 | ||
# REL-NEXT: 0xA R_LARCH_ADD_ULEB128 w2 0x1FFFF4 | ||
# REL-NEXT: 0xA R_LARCH_SUB_ULEB128 w1 0x0 | ||
# REL-NEXT: 0xE R_LARCH_ADD_ULEB128 w1 0x20000D | ||
# REL-NEXT: 0xE R_LARCH_SUB_ULEB128 w2 0x0 | ||
# REL-NEXT: } | ||
# REL: Section ({{.*}}) .rela.debug_loclists { | ||
# REL-NEXT: 0x0 R_LARCH_ADD_ULEB128 x2 0x0 | ||
# REL-NEXT: 0x0 R_LARCH_SUB_ULEB128 x1 0x0 | ||
# REL-NEXT: } | ||
|
||
# REL: Hex dump of section '.gcc_except_table': | ||
# REL-NEXT: 0x00000000 80008000 80800080 80008080 80008080 . | ||
# REL-NEXT: 0x00000010 8000 . | ||
# REL: Hex dump of section '.debug_rnglists': | ||
# REL-NEXT: 0x00000000 80008000 80800080 80008080 80008080 . | ||
# REL-NEXT: 0x00000010 8000 . | ||
# REL: Hex dump of section '.debug_loclists': | ||
# REL-NEXT: 0x00000000 00 . | ||
|
||
# CHECK: Hex dump of section '.gcc_except_table': | ||
# CHECK-NEXT: 0x[[#%x,]] f8008901 f8ff0089 8001f8ff ff008980 . | ||
# CHECK-NEXT: 0x[[#%x,]] 8001 . | ||
# CHECK: Hex dump of section '.debug_rnglists': | ||
# CHECK-NEXT: 0x00000000 f8008901 f8ff0089 8001f8ff ff008980 . | ||
# CHECK-NEXT: 0x00000010 8001 . | ||
# CHECK: Hex dump of section '.debug_loclists': | ||
# CHECK-NEXT: 0x00000000 00 . | ||
|
||
#--- extraspace.s | ||
.text | ||
w1: | ||
la.pcrel $t0, w1 | ||
w2: | ||
|
||
.rodata | ||
.reloc ., R_LARCH_ADD_ULEB128, w2 | ||
.reloc ., R_LARCH_SUB_ULEB128, w1 | ||
.fill 10, 1, 0x80 | ||
.byte 0 |
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.