OSDN Git Service

[llvm-readobj] Allow --hex-dump/--string-dump to dump multiple sections
authorFangrui Song <maskray@google.com>
Tue, 18 Jun 2019 14:01:03 +0000 (14:01 +0000)
committerFangrui Song <maskray@google.com>
Tue, 18 Jun 2019 14:01:03 +0000 (14:01 +0000)
commit894e54f898f9bfc48f82b987b09d1dd02e174054
treed1e22d4473e991ed4d8a6741a0c61b63e84a30b3
parent6a59b73682654043e0be54ba181cfed4afdb5147
[llvm-readobj] Allow --hex-dump/--string-dump to dump multiple sections

1) `-x foo` currently dumps one `foo`. This change makes it dump all `foo`.
2) `-x foo -x foo` currently dumps `foo` twice. This change makes it dump `foo` once.
   In addition, if foo has section index 9, `-x foo -x 9` dumps `foo` once.
3) Give a warning instead of an error if `foo` does not exist.

The new behaviors match GNU readelf.

Also, print a new line as a separator between two section dumps.
GNU readelf uses two lines, but one seems good enough.

Reviewed By: grimar, jhenderson

Differential Revision: https://reviews.llvm.org/D63475

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363683 91177308-0d34-0410-b5e6-96231b3b80d8
test/tools/llvm-objcopy/ELF/overlapping-sections-in-segments.test
test/tools/llvm-objcopy/ELF/overlapping-sections.test
test/tools/llvm-readobj/hex-dump-multi.s [new file with mode: 0644]
test/tools/llvm-readobj/hex-dump.test [new file with mode: 0644]
test/tools/llvm-readobj/hexdump.test [deleted file]
test/tools/llvm-readobj/print-hex.test [deleted file]
test/tools/llvm-readobj/string-dump-multi.s [new file with mode: 0644]
test/tools/llvm-readobj/string-dump.test
tools/llvm-readobj/ObjDumper.cpp
tools/llvm-readobj/ObjDumper.h
tools/llvm-readobj/llvm-readobj.cpp