-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[llvm-readobj,ELF] Support --decompress/-z #82594
Merged
MaskRay
merged 5 commits into
main
from
users/MaskRay/spr/llvm-readobjelf-support-decompress-z
Feb 22, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
06fc237
[𝘀𝗽𝗿] initial version
MaskRay c40413d
remove a stray edit due to slow emacs
MaskRay 8a6c853
add decompress-zstd.test. rename decompress.test to decompress-zlib.test
MaskRay 26f73c6
add decompress-zstd-unsupported.test
MaskRay 309fdcf
test unsupported ch_type
MaskRay 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 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 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
32 changes: 32 additions & 0 deletions
32
llvm/test/tools/llvm-readobj/ELF/decompress-unsupported-zlib.test
This file contains 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,32 @@ | ||
# UNSUPPORTED: zlib | ||
# RUN: yaml2obj %s -o %t | ||
# RUN: llvm-readobj -z -p .a -x .b %t 2>&1 | FileCheck %s -DFILE=%t | ||
|
||
# CHECK: String dump of section '.a': | ||
# CHECK-NEXT: warning: '[[FILE]]': LLVM was not built with LLVM_ENABLE_ZLIB or did not find zlib at build time | ||
# CHECK-NEXT: [ 0] . | ||
# CHECK-NEXT: [ 8] . | ||
# CHECK-NEXT: [ 10] . | ||
# CHECK-NEXT: [ 18] x.c. | ||
# CHECK-NEXT: [ 1e] . | ||
# CHECK-NEXT: [ 20] . | ||
# CHECK-NEXT: Hex dump of section '.b': | ||
# CHECK-NEXT: warning: '[[FILE]]': LLVM was not built with LLVM_ENABLE_ZLIB or did not find zlib at build time | ||
# CHECK-NEXT: 0x00000000 01000000 00000000 01000000 00000000 ................ | ||
# CHECK-NEXT: 0x00000010 01000000 00000000 789c6304 00000200 ........x.c..... | ||
# CHECK-NEXT: 0x00000020 02 . | ||
|
||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Sections: | ||
- Name: .a | ||
Type: SHT_PROGBITS | ||
Flags: [SHF_COMPRESSED] | ||
Content: 010000000000000001000000000000000100000000000000789c63040000020002 | ||
- Name: .b | ||
Type: SHT_PROGBITS | ||
Flags: [SHF_COMPRESSED] | ||
Content: 010000000000000001000000000000000100000000000000789c63040000020002 |
This file contains 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,67 @@ | ||||||
# REQUIRES: zlib | ||||||
## Test --decompress/-z | ||||||
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.
Suggested change
Nit. |
||||||
|
||||||
# RUN: yaml2obj %s -o %t | ||||||
|
||||||
# RUN: llvm-readelf -z -x .strings -x .not_null_terminated %t | FileCheck %s --check-prefix=HEX | ||||||
# RUN: llvm-readobj --decompress -p .strings -p .not_null_terminated %t | FileCheck %s --check-prefix=STR | ||||||
|
||||||
# HEX: Hex dump of section '.strings': | ||||||
# HEX-NEXT: 0x00000000 68657265 00617265 00736f6d 65007374 here.are.some.st | ||||||
# HEX-NEXT: 0x00000010 72696e67 7300 rings. | ||||||
# HEX: Hex dump of section '.not_null_terminated': | ||||||
# HEX-NEXT: 0x00000000 6e6f006e 756c6c no.null | ||||||
|
||||||
# RUN: llvm-readobj -x .strings -p .not_null_terminated %t | FileCheck %s --check-prefix=COMPRESSED | ||||||
|
||||||
# COMPRESSED: String dump of section '.not_null_terminated': | ||||||
# COMPRESSED-NEXT: [ 0] no | ||||||
# COMPRESSED-NEXT: [ 3] null | ||||||
# COMPRESSED-NEXT: Hex dump of section '.strings': | ||||||
# COMPRESSED-NEXT: 0x00000000 01000000 00000000 16000000 00000000 ................ | ||||||
# COMPRESSED-NEXT: 0x00000010 00000000 00000000 789ccb48 2d4a6548 ........x..H-JeH | ||||||
# COMPRESSED-NEXT: 0x00000020 04e2e2fc 5c205152 9499975e cc000058 ....\ QR...^...X | ||||||
# COMPRESSED-NEXT: 0x00000030 2e079b ... | ||||||
|
||||||
# STR: String dump of section '.strings': | ||||||
# STR-NEXT: [ 0] here | ||||||
# STR-NEXT: [ 5] are | ||||||
# STR-NEXT: [ 9] some | ||||||
# STR-NEXT: [ e] strings | ||||||
# STR-EMPTY: | ||||||
# STR-NEXT: String dump of section '.not_null_terminated': | ||||||
# STR-NEXT: [ 0] no | ||||||
# STR-NEXT: [ 3] null{{$}} | ||||||
# STR-NOT: {{.}} | ||||||
|
||||||
# RUN: llvm-readelf -z -p .invalid1 -x .invalid2 %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=INVALID | ||||||
|
||||||
# INVALID: String dump of section '.invalid1': | ||||||
# INVALID-NEXT: warning: '[[FILE]]': corrupted compressed section header | ||||||
# INVALID-NEXT: [ 0] . | ||||||
# INVALID-NEXT: Hex dump of section '.invalid2': | ||||||
# INVALID-NEXT: warning: '[[FILE]]': zlib error: Z_DATA_ERROR | ||||||
# INVALID-NEXT: 0x00000000 01000000 00000000 16000000 00000000 ................ | ||||||
# INVALID-NEXT: 0x00000010 00000000 00000000 78 ........x | ||||||
|
||||||
--- !ELF | ||||||
FileHeader: | ||||||
Class: ELFCLASS64 | ||||||
Data: ELFDATA2LSB | ||||||
Type: ET_REL | ||||||
Sections: | ||||||
- Name: .strings | ||||||
Type: SHT_PROGBITS | ||||||
Flags: [SHF_COMPRESSED] | ||||||
Content: 010000000000000016000000000000000000000000000000789ccb482d4a654804e2e2fc5c2051529499975ecc0000582e079b | ||||||
- Name: .not_null_terminated | ||||||
Type: SHT_PROGBITS | ||||||
Content: 6e6f006e756c6c | ||||||
- Name: .invalid1 | ||||||
Type: SHT_PROGBITS | ||||||
Flags: [SHF_COMPRESSED] | ||||||
Content: 01 | ||||||
- Name: .invalid2 | ||||||
Type: SHT_PROGBITS | ||||||
Flags: [SHF_COMPRESSED] | ||||||
Content: 01000000000000001600000000000000000000000000000078 |
This file contains 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 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 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 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.
Perhaps worth naming decompress-zlib.test, to allow for a zstd version too? (Same applies for the unsupported case).
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.
Sounds good. Done. Added a zstd version.
There is
decompress-zlib-unsupported.test
but nodecompress-zstd-unsupported.test
. The latter probably doesn't add much coverage.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.
That's fine, but one thought that did occur to me is that I suspect zlib is available on more machines than zstd, therefore by having a zstd unsupported test case, you'd be more likely to have coverage of both the supported and unsupported code paths on the same machine.
I'm okay if you still want to do it though.
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.
I think Windows is a popular OS that often misses zlib support. However, "often" may degrade to "sometimes". Anyway, I just added
decompress-zstd-unsupported.test
...