forked from Imagelibrary/binutils-gdb
Add --decompress option to readelf to decompress sections before they are dumped.
bin * readelf.c (options): Add "decompress". (usage): Mention -z/--decompress. (parse_args): Handle -z. (uncompress_section_contents): Move to earlier in the file. (dump_section_as_strings): If requested, decompress the section before dumping. (dump_section_as_bytes): Likewise. * doc/binutils.texi: Document the new option. tests * binutils-all/z.s: New test. Checks the --decompress option to readelf. * binutils-all/readelf.exp: Run the test. * binutils-all/readelf.z: Expected output from readelf.
This commit is contained in:
@@ -346,29 +346,49 @@ readelf_dump_test
|
||||
if {![binutils_assemble $srcdir/$subdir/version.s tmpdir/version.o]} then {
|
||||
perror "could not assemble version note test file"
|
||||
unresolved "readelf - failed to assemble"
|
||||
return
|
||||
}
|
||||
|
||||
if ![is_remote host] {
|
||||
set tempfile tmpdir/version.o
|
||||
fail "readelf -n"
|
||||
} else {
|
||||
set tempfile [remote_download host tmpdir/version.o]
|
||||
|
||||
if ![is_remote host] {
|
||||
set tempfile tmpdir/version.o
|
||||
} else {
|
||||
set tempfile [remote_download host tmpdir/version.o]
|
||||
}
|
||||
|
||||
readelf_test -n $tempfile readelf.n {}
|
||||
}
|
||||
|
||||
readelf_test -n $tempfile readelf.n {}
|
||||
|
||||
# PR 18374 - Check that relocations against the .debug_loc section
|
||||
# do not prevent readelf from displaying all the location lists.
|
||||
if {![binutils_assemble $srcdir/$subdir/pr18374.s tmpdir/pr18374.o]} then {
|
||||
perror "could not assemble PR18374 test file"
|
||||
unresolved "readelf - failed to assemble"
|
||||
return
|
||||
}
|
||||
|
||||
if ![is_remote host] {
|
||||
set tempfile tmpdir/pr18374.o
|
||||
fail "readelf --debug-loc"
|
||||
} else {
|
||||
set tempfile [remote_download host tmpdir/pr18374.o]
|
||||
|
||||
if ![is_remote host] {
|
||||
set tempfile tmpdir/pr18374.o
|
||||
} else {
|
||||
set tempfile [remote_download host tmpdir/pr18374.o]
|
||||
}
|
||||
|
||||
readelf_test --debug-dump=loc $tempfile readelf.pr18374 {}
|
||||
}
|
||||
|
||||
readelf_test --debug-dump=loc $tempfile readelf.pr18374 {}
|
||||
|
||||
# Check that decompressed dumps work.
|
||||
if {![binutils_assemble $srcdir/$subdir/z.s tmpdir/z.o]} then {
|
||||
perror "could not assemble decompress dump test file"
|
||||
unresolved "readelf - failed to assemble"
|
||||
fail "readelf -z"
|
||||
} else {
|
||||
|
||||
if ![is_remote host] {
|
||||
set tempfile tmpdir/z.o
|
||||
} else {
|
||||
set tempfile [remote_download host tmpdir/z.o]
|
||||
}
|
||||
|
||||
readelf_test {--decompress --hex-dump .debug_loc} $tempfile readelf.z {}
|
||||
}
|
||||
|
||||
8
binutils/testsuite/binutils-all/readelf.z
Normal file
8
binutils/testsuite/binutils-all/readelf.z
Normal file
@@ -0,0 +1,8 @@
|
||||
Hex dump of section '.debug_loc':
|
||||
0x00000000 00000000 00000000 01005000 00000000 ..........P.....
|
||||
0x00000010 00000004 00f30150 9f000000 00000000 .......P........
|
||||
0x00000020 00000000 00000000 00010051 00000000 ...........Q....
|
||||
0x00000030 00000000 0300717f 9f000000 00000000 ......q.........
|
||||
0x00000040 000b0070 0020f301 51227000 229f0000 ...p. ..Q"p."...
|
||||
0x00000050 00000000 00000b00 70002070 0022f301 ........p. p."..
|
||||
0x00000060 51229f00 00000000 000000 Q".........
|
||||
70
binutils/testsuite/binutils-all/z.s
Normal file
70
binutils/testsuite/binutils-all/z.s
Normal file
@@ -0,0 +1,70 @@
|
||||
.section .debug_loc,"",%progbits
|
||||
|
||||
.byte 0x5a
|
||||
.byte 0x4c
|
||||
.byte 0x49
|
||||
.byte 0x42
|
||||
.byte 0x00
|
||||
.byte 0x00
|
||||
.byte 0x00
|
||||
.byte 0x00
|
||||
.byte 0x00
|
||||
.byte 0x00
|
||||
.byte 0x00
|
||||
.byte 0x6b
|
||||
.byte 0x78
|
||||
.byte 0x9c
|
||||
.byte 0x63
|
||||
.byte 0x60
|
||||
.byte 0x80
|
||||
.byte 0x00
|
||||
.byte 0x46
|
||||
.byte 0x86
|
||||
.byte 0x00
|
||||
.byte 0x28
|
||||
.byte 0x8b
|
||||
.byte 0x81
|
||||
.byte 0x85
|
||||
.byte 0xe1
|
||||
.byte 0x33
|
||||
.byte 0x63
|
||||
.byte 0xc0
|
||||
.byte 0x7c
|
||||
.byte 0x06
|
||||
.byte 0x34
|
||||
.byte 0xc0
|
||||
.byte 0xc8
|
||||
.byte 0x10
|
||||
.byte 0x08
|
||||
.byte 0x63
|
||||
.byte 0x32
|
||||
.byte 0x33
|
||||
.byte 0x14
|
||||
.byte 0xd6
|
||||
.byte 0xc3
|
||||
.byte 0xe5
|
||||
.byte 0xb9
|
||||
.byte 0x19
|
||||
.byte 0x0a
|
||||
.byte 0x18
|
||||
.byte 0x14
|
||||
.byte 0x3e
|
||||
.byte 0x33
|
||||
.byte 0x06
|
||||
.byte 0x2a
|
||||
.byte 0x15
|
||||
.byte 0x30
|
||||
.byte 0x28
|
||||
.byte 0xa1
|
||||
.byte 0x0a
|
||||
.byte 0x02
|
||||
.byte 0x05
|
||||
.byte 0x40
|
||||
.byte 0xe2
|
||||
.byte 0x70
|
||||
.byte 0x41
|
||||
.byte 0x00
|
||||
.byte 0xc1
|
||||
.byte 0x6a
|
||||
.byte 0x0a
|
||||
.byte 0x83
|
||||
Reference in New Issue
Block a user