-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-objcopy] Add change-section-lma *+/-offset #95431
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
Changes from all commits
56a3e22
ae970b4
7e90cdd
b053be3
2e7afb7
dc6e748
bdf46de
ef9b76d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# RUN: yaml2obj %s -o %t | ||
# RUN: llvm-objcopy --change-section-lma *+0x20 %t %t2 | ||
# RUN: llvm-readelf --program-headers %t2 | FileCheck %s --check-prefix=CHECK-PLUS-PROGRAMS | ||
# RUN: llvm-readelf --section-headers %t2 | FileCheck %s --check-prefix=CHECK-PLUS-SECTIONS | ||
Comment on lines
+3
to
+4
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. You could simplify this and the similar below down to a single call with both options specified. 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. Yes the original version had them in one command but I "simplified" it by having two separate commands. I think it makes it clearly to see what is being checked. |
||
# RUN: llvm-objcopy --change-section-lma *-0x30 %t %t3 | ||
# RUN: llvm-readelf --program-headers %t3 | FileCheck %s --check-prefix=CHECK-MINUS-PROGRAMS | ||
# RUN: llvm-readelf --section-headers %t3 | FileCheck %s --check-prefix=CHECK-MINUS-SECTIONS | ||
# RUN: not llvm-objcopy --change-section-lma .text3=0x5000 %t 2>&1 | FileCheck %s --check-prefix=ERR-SET-ADDRESS | ||
# RUN: not llvm-objcopy --change-section-lma .text3+0x30 %t 2>&1 | FileCheck %s --check-prefix=ERR-SPECIFIC-SEC | ||
# RUN: not llvm-objcopy --change-section-lma *+0c50 %t 2>&1 | FileCheck %s --check-prefix=ERR-INVALID-VAL | ||
# RUN: not llvm-objcopy --change-section-lma 0 %t 2>&1 | FileCheck %s --check-prefix=ERR-MISSING-OFFSET | ||
# RUN: not llvm-objcopy --change-section-lma *-0x2000 %t 2>&1 | FileCheck %s --check-prefix=ERR-UNDERFLOW | ||
# RUN: not llvm-objcopy --change-section-lma *+0x100000000 %t 2>&1 | FileCheck %s --check-prefix=ERR-OVERFLOW | ||
|
||
# CHECK-PLUS-PROGRAMS: Type Offset VirtAddr PhysAddr FileSiz MemSiz | ||
# CHECK-PLUS-PROGRAMS: PHDR 0x000002 0x0000000000001102 0x0000000000001122 0x000038 0x000000 | ||
# CHECK-PLUS-PROGRAMS: LOAD 0x000000 0x0000000000001100 0x0000000000001120 0x000258 0x000258 | ||
# CHECK-PLUS-PROGRAMS: LOAD 0x000258 0xffffffff00005100 0xffffffff00006120 0x000100 0x000100 | ||
# CHECK-PLUS-PROGRAMS: NOTE 0x000358 0x0000000000001200 0x0000000000001220 0x000010 0x000000 | ||
# CHECK-PLUS-PROGRAMS: NOTE 0x000368 0x0000000000000000 0x0000000000000000 0x000000 0x000000 | ||
|
||
# CHECK-MINUS-PROGRAMS: PHDR 0x000002 0x0000000000001102 0x00000000000010d2 0x000038 0x000000 | ||
# CHECK-MINUS-PROGRAMS: LOAD 0x000000 0x0000000000001100 0x00000000000010d0 0x000258 0x000258 | ||
# CHECK-MINUS-PROGRAMS: LOAD 0x000258 0xffffffff00005100 0xffffffff000060d0 0x000100 0x000100 | ||
# CHECK-MINUS-PROGRAMS: NOTE 0x000358 0x0000000000001200 0x00000000000011d0 0x000010 0x000000 | ||
# CHECK-MINUS-PROGRAMS: NOTE 0x000368 0x0000000000000000 0x0000000000000000 0x000000 0x000000 | ||
|
||
# CHECK-PLUS-SECTIONS: [Nr] Name Type Address Off Size ES Flg Lk Inf Al | ||
# CHECK-PLUS-SECTIONS: .text1 | ||
# CHECK-PLUS-SECTIONS-SAME: 0000000000000000 | ||
# CHECK-PLUS-SECTIONS: .text2 | ||
# CHECK-PLUS-SECTIONS-SAME: 0000000000000000 | ||
|
||
# CHECK-MINUS-SECTIONS: .text1 | ||
# CHECK-MINUS-SECTIONS-SAME: 0000000000000000 | ||
# CHECK-MINUS-SECTIONS: .text2 | ||
# CHECK-MINUS-SECTIONS-SAME: 0000000000000000 | ||
|
||
# ERR-SET-ADDRESS: error: bad format for --change-section-lma: changing LMA to a specific value is not supported. Use *+val or *-val instead | ||
# ERR-SPECIFIC-SEC: error: bad format for --change-section-lma: changing a specific section LMA is not supported. Use *+val or *-val instead | ||
# ERR-INVALID-VAL: error: bad format for --change-section-lma: value after *+ is 0c50 when it should be an integer | ||
# ERR-MISSING-OFFSET: error: bad format for --change-section-lma: missing LMA offset | ||
# ERR-UNDERFLOW: : address 0x1102 cannot be decreased by 0x2000. The result would underflow | ||
# ERR-OVERFLOW: address 0xffffffff00006100 cannot be increased by 0x100000000. The result would overflow | ||
|
||
!ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_EXEC | ||
Sections: | ||
- Name: .text1 | ||
Type: SHT_PROGBITS | ||
Size: 0x100 | ||
- Name: .text2 | ||
Type: SHT_PROGBITS | ||
Size: 0x100 | ||
ProgramHeaders: | ||
- Type: PT_PHDR | ||
FileSize: 0x38 | ||
Offset: 0x2 | ||
VAddr: 0x1102 | ||
- Type: PT_LOAD | ||
Offset: 0x0 | ||
VAddr: 0x1100 | ||
FirstSec: .text1 | ||
LastSec: .text1 | ||
- Type: PT_LOAD | ||
VAddr: 0xFFFFFFFF00005100 | ||
PAddr: 0xFFFFFFFF00006100 | ||
FirstSec: .text2 | ||
LastSec: .text2 | ||
- Type: PT_NOTE | ||
FileSize: 0x10 | ||
VAddr: 0x1200 | ||
Offset: 0x358 | ||
- Type: PT_NOTE | ||
FileSize: 0x0 | ||
Offset: 0x368 |
Uh oh!
There was an error while loading. Please reload this page.