-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[obj2yaml] Support CREL #98116
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
[obj2yaml] Support CREL #98116
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
## Test how we dump SHT_CREL sections. | ||
# RUN: yaml2obj %s -o %t1 | ||
# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=YAML | ||
|
||
# YAML: - Name: .crel.text | ||
# YAML-NEXT: Type: SHT_CREL | ||
# YAML-NEXT: Link: .symtab | ||
# YAML-NEXT: Info: .text | ||
# YAML-NEXT: Relocations: | ||
# YAML-NEXT: - Offset: 0x1 | ||
# YAML-NEXT: Symbol: g1 | ||
# YAML-NEXT: Type: R_X86_64_32 | ||
# YAML-NEXT: Addend: 1 | ||
# YAML-NEXT: - Offset: 0x2 | ||
# YAML-NEXT: Symbol: l1 | ||
# YAML-NEXT: Type: R_X86_64_64 | ||
# YAML-NEXT: Addend: 2 | ||
# YAML-NEXT: - Symbol: g1 | ||
# YAML-NEXT: Type: R_X86_64_32S | ||
# YAML-NEXT: Addend: -1 | ||
# YAML-NEXT: - Offset: 0x4 | ||
# YAML-NEXT: Symbol: .text | ||
# YAML-NEXT: Type: R_X86_64_32S | ||
# YAML-NEXT: Addend: -9223372036854775808 | ||
# YAML-NEXT: - Name: .crel.dyn | ||
# YAML-NEXT: Type: SHT_CREL | ||
# YAML-NEXT: Relocations: [] | ||
|
||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Machine: EM_X86_64 | ||
|
||
Sections: | ||
- Name: .foo | ||
Type: SHT_PROGBITS | ||
Flags: [SHF_ALLOC] | ||
- Name: .text | ||
Type: SHT_PROGBITS | ||
Content: "0000000000000000" | ||
Flags: [SHF_ALLOC] | ||
- Name: .crel.text | ||
Type: SHT_CREL | ||
Info: .text | ||
Link: .symtab | ||
Relocations: | ||
- Offset: 0x1 | ||
Symbol: g1 | ||
Type: R_X86_64_32 | ||
Addend: 1 | ||
- Offset: 0x2 | ||
Symbol: l1 | ||
Type: R_X86_64_64 | ||
Addend: 2 | ||
- Offset: 0x0 | ||
Symbol: g1 | ||
Type: R_X86_64_32S | ||
Addend: 0xffffffffffffffff | ||
- Offset: 0x4 | ||
Symbol: .text | ||
Type: R_X86_64_32S | ||
Addend: 0x8000000000000000 | ||
- Name: .crel.dyn | ||
Type: SHT_CREL | ||
Content: 00 | ||
## Trigger the .dynsym emission. | ||
DynamicSymbols: [] | ||
Symbols: | ||
- Name: unused | ||
Section: .text | ||
- Name: .text | ||
Type: STT_SECTION | ||
Section: .text | ||
- Name: l1 | ||
- Name: g1 | ||
Section: .text | ||
Value: 0x0 | ||
Size: 4 | ||
Binding: STB_GLOBAL | ||
|
||
## Test the behavior when the sh_entsize field is broken. | ||
|
||
# RUN: yaml2obj -DTYPE=SHT_RELA --docnum=2 %s -o %t2 | ||
# RUN: not obj2yaml %t2 2>&1 | FileCheck %s --check-prefix=ERR1 | ||
|
||
# ERR1: unable to decode LEB128 at offset 0x00000000: malformed uleb128, extends past end | ||
|
||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_DYN | ||
Sections: | ||
- Name: .foo | ||
Type: SHT_CREL |
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.
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.
Dumb question maybe, but what's the point of this particular symbol?
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.
The unused symbol makes symbols referenced by relocations start at higher indexes.
This property is somewhat useful to test llvm-objcopy. It's probably not so useful after
decodeCrel
has been tested, but I think it does not hurt here...