aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-readobj/llvm-readobj.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-05-03Move llvm-readobj/StreamWriter to Support.Zachary Turner1-3/+4
We wish to re-use this from llvm-pdbdump, and it provides a nice way to print structured data in scoped format that could prove useful for many other dumping tools as well. Moving to support and changing name to ScopedPrinter to better reflect its purpose. llvm-svn: 268342
2016-04-11[llvm-readobj] Add ELF hash histogram printingHemant Kulkarni1-0/+7
Differential Revision: http://reviews.llvm.org/D18907 llvm-svn: 265967
2016-04-06Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump ↵Kevin Enderby1-3/+3
to produce a real error message Produce the first specific error message for a malformed Mach-O file describing the problem instead of the generic message for object_error::parse_failed of "Invalid data was encountered while parsing the file”.  Many more good error messages will follow after this first one. This is built on Lang Hames’ great work of adding the ’Error' class for structured error handling and threading Error through MachOObjectFile construction. And making createMachOObjectFile return Expected<...> . So to to get the error to the llvm-obdump tool, I changed the stack of these methods to also return Expected<...> : object::ObjectFile::createObjectFile() object::SymbolicFile::createSymbolicFile() object::createBinary() Then finally in ParseInputMachO() in MachODump.cpp the error can be reported and the specific error message can be printed in llvm-objdump and can be seen in the existing test case for the existing malformed binary but with the updated error message. Converting these interfaces to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now use of errorToErrorCode() and errorOrToExpected() are used where the callers are yet to be converted. Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values. So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(ObjOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 265606
2016-03-01Fix typo. NFC.Tim Northover1-1/+1
llvm-svn: 262405
2016-02-10[llvm-readobj] Option to emit readelf like outputHemant Kulkarni1-8/+14
New option --elf-output-style=LLVM or GNU Enables -file-headers in readelf style when elf-output-style=GNU Differential revision: http://reviews.llvm.org/D14128 llvm-svn: 260430
2016-02-10Revert "[llvm-readobj] Option to emit readelf like output"Hemant Kulkarni1-14/+8
This reverts commit a58765909660a7195b32e0cc8c7476168b913750. llvm-svn: 260397
2016-02-10[llvm-readobj] Option to emit readelf like outputHemant Kulkarni1-8/+14
New option --elf-output-style=LLVM or GNU Enables -file-headers in readelf style when elf-output-style=GNU Differential revision: http://reviews.llvm.org/D14128 llvm-svn: 260391
2016-01-26[llvm-readobj] Add -elf-section-groups optionHemant Kulkarni1-10/+20
Adds a way to inspect SHT_GROUP sections in ELF objects. Displays signature, member sections of these sections. Differential revision: http://reviews.llvm.org/D16555 llvm-svn: 258845
2015-12-23[llvm-readobj] Use stderr and not stdout for error messages.Davide Italiano1-2/+2
llvm-svn: 256347
2015-12-16Reland "[llvm-readobj] Simplify usage of -codeview flag"Reid Kleckner1-0/+2
Relands r255790 with fixed tests. llvm-svn: 255793
2015-12-16Revert "[llvm-readobj] Simplify usage of -codeview flag"Reid Kleckner1-2/+0
This reverts commit r255790. llvm-svn: 255791
2015-12-16[llvm-readobj] Simplify usage of -codeview flagReid Kleckner1-0/+2
llvm-svn: 255790
2015-12-05[llvm-readobj] report_error() does not return, so we can simplify.Davide Italiano1-6/+2
llvm-svn: 254868
2015-12-04[llvm-readobj] reportError() never returns. Mark with the correct attribute.Davide Italiano1-1/+1
llvm-svn: 254752
2015-11-05Reapply r250906 with many suggested updates from Rafael Espindola.Kevin Enderby1-1/+4
The needed lld matching changes to be submitted immediately next, but this revision will cause lld failures with this alone which is expected. This removes the eating of the error in Archive::Child::getSize() when the characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. These changes will require corresponding changes to the lld project. That will be committed immediately after this change. But this revision will cause lld failures with this alone which is expected. llvm-svn: 252192
2015-10-21Backing out commit r250906 as it broke lld.Kevin Enderby1-6/+1
llvm-svn: 250908
2015-10-21This removes the eating of the error in Archive::Child::getSize() when the ↵Kevin Enderby1-1/+6
characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. Also corrected the code where the size gets us to the “at the end of the archive” which is OK but past the end of the archive will return object_error::parse_failed now. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. llvm-svn: 250906
2015-10-16[llvm-readobj] Teach ELFDumper about symbol versioning.Davide Italiano1-0/+8
Differential Revision: http://reviews.llvm.org/D13824 llvm-svn: 250575
2015-10-14[llvm-readobj/ELF] Print GNU Hash sectionIgor Kudrin1-0/+6
Add a new command line switch, -gnu-hash-table, to print the content of that section. Differential Revision: http://reviews.llvm.org/D13696 llvm-svn: 250291
2015-09-17[llvm-readobj] Fix another "time of check to time of use bug".Davide Italiano1-5/+0
It seems there's more copy-paste between tools than needed. llvm-svn: 247954
2015-09-09[llvm-readobj] MachO -- dump LinkerOptions load command.Davide Italiano1-0/+7
Example output: Linker Options { Size: 32 Count: 2 Strings [ Value: -framework Value: Cocoa ] } There were only two tests using this -- so I converted them as part of this commit rather than separately. Differential Revision: http://reviews.llvm.org/D12702 llvm-svn: 247106
2015-09-03[llvm-readobj] Dump MachO indirect symbols.Davide Italiano1-0/+7
Example output: File: <stdin> Format: Mach-O 32-bit i386 Arch: i386 AddressSize: 32bit Indirect Symbols { Number: 3 Symbols [ Entry { Entry Index: 0 Symbol Index: 0x4 } Entry { Entry Index: 1 Symbol Index: 0x0 } Entry { Entry Index: 2 Symbol Index: 0x1 } ] } Differential Revision: http://reviews.llvm.org/D12570 llvm-svn: 246789
2015-09-02[llvm-readobj] MachO: Dump segment command.Davide Italiano1-0/+7
Example output: File: <stdin> Format: Mach-O arm Arch: arm AddressSize: 32bit Segment { Cmd: LC_SEGMENT Name: Size: 260 vmaddr: 0x0 vmsize: 0x10 fileoff: 408 filesize: 408 maxprot: rwx initprot: rwx nsects: 3 flags: 0x0 } Differential Revision: http://reviews.llvm.org/D12542 llvm-svn: 246665
2015-08-31[llvm-readobj] Dump MachO Dysymtab command.Davide Italiano1-0/+8
Example output: File: <stdin> Format: Mach-O 64-bit x86-64 Arch: x86_64 AddressSize: 64bit Dysymtab { ilocalsym: 0 nlocalsym: 6 iextdefsym: 6 nextdefsym: 2 iundefsym: 8 nundefsym: 0 tocoff: 0 ntoc: 0 modtaboff: 0 nmodtab: 0 extrefsymoff: 0 nextrefsyms: 0 indirectsymoff: 0 nindirectsyms: 0 extreloff: 0 nextrel: 0 locreloff: 0 nlocrel: 0 } Differential Revision: http://reviews.llvm.org/D12496 llvm-svn: 246474
2015-08-31[llvm-readobj] Add pair of missing braces.Davide Italiano1-1/+2
This fixes a regression introduced in r246151. llvm-svn: 246453
2015-08-28llvm-readobj: Dump more info for COFF import libraries.Rui Ueyama1-6/+0
This patch teaches llvm-readobj to print out COFF import file header fields. llvm-svn: 246291
2015-08-28Re-apply r246276 - Object: Teach llvm-ar to create symbol table for COFF ↵Rui Ueyama1-0/+9
short import files This patch includes a fix for a llvm-readobj test. With this patch, the tool does no longer print out COFF headers for the short import file, but that's probably desirable because the header for the short import file is dummy. llvm-svn: 246283
2015-08-27[llvm-readobj] Add support for dumping MachO min version load command.Davide Italiano1-0/+6
Example output: File: <stdin> Format: Mach-O arm Arch: arm AddressSize: 32bit MinVersion { Cmd: LC_VERSION_MIN_IPHONEOS Size: 16 Version: 99.8.7 SDK: n/a } Differential Revision: http://reviews.llvm.org/D12373 llvm-svn: 246151
2015-08-21[llvm-readobj] Add support for MachO DataInCodeDataCommand.Davide Italiano1-0/+8
Example output: File: <stdin> Format: Mach-O arm Arch: arm AddressSize: 32bit DataInCode { Data offset: 300 Data size: 32 Data Regions [ DICE { Index: 0 Offset: 0 Length: 4 Kind: 1 } DICE { Index: 1 Offset: 4 Length: 4 Kind: 4 } DICE { Index: 2 Offset: 8 Length: 2 Kind: 3 } DICE { Index: 3 Offset: 10 Length: 1 Kind: 2 } ] } Differential Revision: http://reviews.llvm.org/D12084 llvm-svn: 245732
2015-08-07[llvm-readobj] Convert to range-loops.Davide Italiano1-4/+2
llvm-svn: 244300
2015-08-06Move to llvm-readobj code that is only used there.Rafael Espindola1-2/+2
lld might end up using a small part of this, but it will be in a much refactored form. For now this unblocks avoiding the full section scan in the ELFFile constructor. This also has a (very small) error handling improvement. llvm-svn: 244282
2015-07-24[llvm-reaobj] Display COFF-specific sections/tables only if the object is COFF.Davide Italiano1-9/+10
Just skip them otherwise. llvm-svn: 243086
2015-07-21Simplify printing the soname. NFC.Rafael Espindola1-14/+1
llvm-svn: 242786
2015-07-20Remove duplicated code.Rafael Espindola1-4/+4
Both ELFObjectFile and ELFFile had an implementation of getLoadName. llvm-svn: 242725
2015-07-20llvm-readobj: Handle invalid references to the string table.Rafael Espindola1-3/+3
llvm-svn: 242658
2015-07-20llvm-readobj: call exit(1) on error.Rafael Espindola1-7/+4
llvm-readobj exists for testing llvm. We can safely stop the program the first time we know the input in corrupted. This is in preparation for making it handle a few more broken files. llvm-svn: 242656
2015-07-20Refactor duplicated code. NFC.Rafael Espindola1-8/+9
llvm-svn: 242655
2015-07-09[Object][ELF] Support dumping hash-tables from files with no section table.Michael J. Spencer1-0/+6
This time without breaking the bots. llvm-svn: 241869
2015-07-09Temporarily reverting 241765, 241768, and 241772 to unbreak the build bots.Adrian Prantl1-6/+0
llvm-svn: 241781
2015-07-09[Object][ELF] Support dumping hash-tables from files with no section table.Michael J. Spencer1-0/+6
llvm-svn: 241765
2015-07-06Simplify. NFC.Rafael Espindola1-3/+1
llvm-svn: 241458
2015-06-29Don't return error_code from function that never fails.Rafael Espindola1-3/+2
llvm-svn: 241021
2015-06-26[StackMaps] Add a lightweight parser for stackmap version 1 sections.Lang Hames1-0/+9
The parser provides a convenient interface for reading llvm stackmap v1 sections in object files. This patch also includes a new option for llvm-readobj, '-stackmap', which uses the parser to pretty-print stackmap sections for debugging/testing purposes. llvm-svn: 240860
2015-06-25[Object][ELF] Add support for dumping dynamic relocations when sections are ↵Michael J. Spencer1-3/+6
stripped. llvm-svn: 240703
2015-06-25We don't need the targets to read objects.Rafael Espindola1-3/+0
llvm-svn: 240684
2015-06-16[llvm-readobj] Print MIPS .reginfo section contentSimon Atanasyan1-0/+6
llvm-svn: 239856
2015-05-07[llvm-readobj] Print .MIPS.abiflags section contentSimon Atanasyan1-1/+8
This change adds new flag -mips-abi-flags to the llvm-readobj. This flag forces printing of .MIPS.abiflags section content. https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking#10.2.1._.MIPS.abiflags llvm-svn: 236737
2015-04-13llvm-readobj: teach it to handle MachO Universal Archive correctlyDavid Blaikie1-7/+6
Patch by Chilledheart (rwindz0@gmail.com). Reviewed By: rafael Differential Revision: http://reviews.llvm.org/D8773 llvm-svn: 234758
2015-03-24[llvm-readobj] add support for macho universal binary.Rafael Espindola1-0/+17
Patch by Keyue Hu (Chilledheart)! llvm-svn: 233107
2015-02-18Modify llvm-readobj to dump symbol record bytes.Zachary Turner1-3/+8
This will help us study the format of individual symbol records more closely. Differential Revision: http://reviews.llvm.org/D7664 Reviewed by: Timur Iskhodzhanov llvm-svn: 229730