summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj
Commit message (Collapse)AuthorAgeFilesLines
...
* [COFFDumper] Make sure there is sufficient padding left in the checksumDavid Majnemer2016-05-281-0/+2
| | | | llvm-svn: 271143
* [llvm-readobj] Validate the string table offset before using itDavid Majnemer2016-05-281-2/+8
| | | | llvm-svn: 271139
* Use consume instead of manually using drop_frontDavid Majnemer2016-05-281-2/+2
| | | | llvm-svn: 271137
* [pdb] Finish conversion to zero copy pdb access.Zachary Turner2016-05-281-5/+40
| | | | | | | | | | | | | | This converts remaining uses of ByteStream, which was still left in the symbol stream and type stream, to using the new StreamInterface zero-copy classes. RecordIterator is finally deleted, so this is the only way left now. Additionally, more error checking is added when iterating the various streams. With this, the transition to zero copy pdb access is complete. llvm-svn: 271101
* Remove unused global variable.Zachary Turner2016-05-241-11/+0
| | | | llvm-svn: 270610
* Add FIXMEs to all derived classes of std::error_category.Peter Collingbourne2016-05-241-0/+3
| | | | | | | | This helps make clear that we're moving away from std::error_code. Differential Revision: http://reviews.llvm.org/D20592 llvm-svn: 270604
* Remove unused variable breaking -Werror builds.Zachary Turner2016-05-241-2/+1
| | | | llvm-svn: 270529
* Make a symbol visitor and use it to dump CV symbols.Zachary Turner2016-05-231-732/+51
| | | | | | | Differential Revision: http://reviews.llvm.org/D20534 Reviewed By: rnk llvm-svn: 270511
* [codeview] Refactor symbol records to use same pattern as types.Zachary Turner2016-05-231-274/+325
| | | | | | | | | | | This will pave the way to introduce a full fledged symbol visitor similar to how we have a type visitor, thus allowing the same dumping code to be used in llvm-readobj and llvm-pdbdump. Differential Revision: http://reviews.llvm.org/D20384 Reviewed By: rnk llvm-svn: 270475
* [llvm-readobj] - Teach readobj to recognize SHF_COMPRESSED flag.George Rimar2016-05-211-2/+10
| | | | | | | | | | | | | | | | | | | | | | | Main problem here was that SHF_COMPRESSED has the same value with XCORE_SHF_CP_SECTION, which was included as standart (common) flag. As far I understand xCore is a family of controllers and it that means it's constant should be processed separately, only if e_machine == EM_XCORE, otherwise llvm-readobj would output different constants twice for compressed section: Flags [ .. SHF_COMPRESSED (0x800) .. XCORE_SHF_CP_SECTION (0x800) .. ] what probably does not make sence if you're not working with xcore file. Differential revision: http://reviews.llvm.org/D20273 llvm-svn: 270320
* Delete default in fully covered switch.Rafael Espindola2016-05-181-1/+0
| | | | llvm-svn: 269872
* [codeview] Some cleanup of Symbol Records.Zachary Turner2016-05-171-62/+63
| | | | | | | | | | | | | | * Reworks the CVSymbolTypes.def to work similarly to TypeRecords.def. * Moves some enums from SymbolRecords.h to CodeView.h to maintain consistency with how we do type records. * Generalize a few simple things like the record prefix * Define the leaf enum and the kind enum similar to how we do with tyep records. Differential Revision: http://reviews.llvm.org/D20342 Reviewed By: amccarth, rnk llvm-svn: 269867
* Change llvm-objdump, llvm-nm and llvm-size when reporting an object file errorKevin Enderby2016-05-171-6/+9
| | | | | | | | | | | | | | | | | | | | | when the object is in an archive to use something like libx.a(foo.o) as part of the error message. Also changed llvm-objdump and llvm-size to be like llvm-nm and ignore non-object files in archives and not produce any error message. To do this Archive::Child::getAsBinary() was changed from ErrorOr<...> to Expected<...> then that was threaded up to its users. Converting this interface to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now the use of errorToErrorCode() is still used in one place yet to be fully converted. Again 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 comments for those. llvm-svn: 269784
* Remove extra semicolon to fix warning. NFC.Michael Kuperstein2016-05-161-1/+1
| | | | llvm-svn: 269722
* [codeview] Add type stream merging prototypeReid Kleckner2016-05-144-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This code is intended to be used as part of LLD's PDB writing. Until that exists, this is exposed via llvm-readobj for testing purposes. Type stream merging uses the following algorithm: - Begin with a new empty stream, and a new empty hash table that maps from type record contents to new type index. - For each new type stream, maintain a map from source type index to destination type index. - For each record, copy it and rewrite its type indices to be valid in the destination type stream. - If the new type record is not already present in the destination stream hash table, append it to the destination type stream, assign it the next type index, and update the two hash tables. - If the type record already exists in the destination stream, discard it and update the type index map to forward the source type index to the existing destination type index. Reviewers: zturner, ruiu Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20122 llvm-svn: 269521
* llvm-readobj: Fix GNU style entry point print widthHemant Kulkarni2016-05-121-1/+1
| | | | llvm-svn: 269376
* llvm-readobj: Change Hex output for GNU style dynamic table printHemant Kulkarni2016-05-121-3/+4
| | | | | | | Dynamic table when printed shows uppercase tag/values. This changes it to lower case when printing in GNU style llvm-svn: 269368
* llvm-readobj: Fix the GNU section header flags for SHF_MASKPROC and SHF_MASKOSHemant Kulkarni2016-05-121-2/+4
| | | | llvm-svn: 269338
* Make CodeView record serialization more generic.Zachary Turner2016-05-121-12/+13
| | | | | | | | | | | This introduces a variadic template and some helper macros to safely and correctly deserialize many types of common record fields while maintaining error checking. Differential Revision: http://reviews.llvm.org/D20183 Reviewed By: rnk, amccarth llvm-svn: 269315
* [codeview] Move dumper into lib/DebugInfo/CodeViewReid Kleckner2016-05-052-811/+9
| | | | | | So that we can call it from llvm-pdbdump. llvm-svn: 268580
* [codeview] Add a type visitor to help abstract away type stream handlingReid Kleckner2016-05-041-485/+448
| | | | | | | | | | | | | | | | | | Summary: Port the dumper in llvm-readobj over to it. I'm planning to use this visitor to power type stream merging. While we're at it, try to switch from StringRef to ArrayRef<uint8_t> in some places. Reviewers: zturner, amccarth Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D19899 llvm-svn: 268535
* [llvm-readobj] Print MIPS .MIPS.options section contentSimon Atanasyan2016-05-043-7/+68
| | | | | | | | | .MIPS.options section specifies miscellaneous options to be applied to an object file. LLVM as well as modern versions of GNU tools emit the only type of the options - ODK_REGINFO. The patch teaches llvm-readobj to print details of the ODK_REGINFO and skip contents of other options. llvm-svn: 268478
* Move CodeViewTypeStream to DebugInfo/CodeViewZachary Turner2016-05-031-137/+14
| | | | | | | | | | | | | Ability to parse codeview type streams is also needed by DebugInfoPDB for parsing PDBs, so moving this into a library gives us this option. Since DebugInfoPDB had already hand rolled some code to do this, that code is now convereted over to using this common abstraction. Differential Revision: http://reviews.llvm.org/D19887 Reviewed By: dblaikie, amccarth llvm-svn: 268454
* [codeview] Maintain the type enum-to-classname mapping in the .def fileReid Kleckner2016-05-031-23/+5
| | | | | | This way it will be easy to stamp out something like a type visitor. llvm-svn: 268347
* Move llvm-readobj/StreamWriter to Support.Zachary Turner2016-05-0314-485/+55
| | | | | | | | | 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
* NFC: An iterator for stepping through CodeView type stream in llvm-readobjAdrian McCarthy2016-05-021-39/+125
| | | | | | | | | | | | This is a small refactoring step toward moving CodeView type stream logic from llvm-readobj to a library. It abstracts the logic of stepping through the stream into an iterator class and updates llvm-readobj to use that iterator. This has no functional change; llvm-readobj produces identical output. The next step is to abstract the parsing of the different leaf types and then move that and the iterator into a library. Since this is my first contrib outside LLDB, please let me know if I'm messing up on any of the LLVM style guidelines, idioms, or patterns. Differential Revision: http://reviews.llvm.org/D19746 llvm-svn: 268334
* [codeview] Isolate type dumping from object file stateReid Kleckner2016-05-021-18/+38
| | | | | | | | | | | | | | This isolates the state we use for type dumping from the knowledge of object files. We can use CVTypeDumper to dump types from anywhere in memory now. NFC Reviewers: zturner Differential Revision: http://reviews.llvm.org/D19824 llvm-svn: 268300
* Thread Expected<...> up from libObject’s getType() for symbols to allow ↵Kevin Enderby2016-05-023-8/+13
| | | | | | | | | | | | | | | | | | | | | | llvm-objdump to produce a good error message. Produce another specific error message for a malformed Mach-O file when a symbol’s section index is more than the number of sections. The existing test case in test/Object/macho-invalid.test for macho-invalid-section-index-getSectionRawName now reports the error with the message indicating that a symbol at a specific index has a bad section index and that bad section index value. Again converting interfaces to Expected<> from ErrorOr<> does involve touching a number of places. Where the existing code reported the error with a string message or an error code it was converted to do the same. 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(NameOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. llvm-svn: 268298
* [codeview] Don't dump type stream bytes unless asked toReid Kleckner2016-05-021-1/+2
| | | | llvm-svn: 268271
* [llvm-readobj] Dump hash as part of -version-info.Davide Italiano2016-05-021-0/+1
| | | | llvm-svn: 268210
* Thread Expected<...> up from libObject’s getName() for symbols to allow ↵Kevin Enderby2016-04-206-23/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | llvm-objdump to produce a good error message. Produce another specific error message for a malformed Mach-O file when a symbol’s string index is past the end of the string table. The existing test case in test/Object/macho-invalid.test for macho-invalid-symbol-name-past-eof now reports the error with the message indicating that a symbol at a specific index has a bad sting index and that bad string index value. Again converting interfaces to Expected<> from ErrorOr<> does involve touching a number of places. Where the existing code reported the error with a string message or an error code it was converted to do the same. There is some code for this that could be factored into a routine but I would like to leave that for the code owners post-commit to do as they want for handling an llvm::Error. An example of how this could be done is shown in the diff in lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h which had a Check() routine already for std::error_code so I added one like it for llvm::Error . 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(NameOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there fixes needed to lld 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: 266919
* [NFC] Header cleanupMehdi Amini2016-04-181-1/+0
| | | | | | | | | | | | | | Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
* [codeview] Dump char16_t and char32_t simple typesReid Kleckner2016-04-151-0/+2
| | | | llvm-svn: 266465
* [llvm-readobj] Add ELF hash histogram printingHemant Kulkarni2016-04-113-0/+129
| | | | | | Differential Revision: http://reviews.llvm.org/D18907 llvm-svn: 265967
* Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump ↵Kevin Enderby2016-04-061-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
* Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining ↵Duncan P. N. Exon Smith2016-04-051-87/+51
| | | | | | | | | | files; other minor fixes." This reverts commit r265454 since it broke the build. E.g.: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/ llvm-svn: 265459
* Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; ↵Eugene Zelenko2016-04-051-51/+87
| | | | | | | | | | | | other minor fixes. Some Include What You Use suggestions were used too. Use anonymous namespaces in source files. Differential revision: http://reviews.llvm.org/D18778 llvm-svn: 265454
* Use ArrayRef for contiguous areas in ELF. NFC.Rafael Espindola2016-04-051-9/+9
| | | | | | This just simplifies the code a bit. More so in lld. llvm-svn: 265403
* Silencing warnings from MSVC 2015 Update 2. All of these changes silence ↵Aaron Ballman2016-03-301-3/+3
| | | | | | "C4334 '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)". NFC. llvm-svn: 264929
* [llvm-readobj] NFC: Remove unneeded parenthesisHemant Kulkarni2016-03-291-6/+6
| | | | llvm-svn: 264731
* [llvm-readobj] Support GNU style dyn-relocationsHemant Kulkarni2016-03-291-20/+108
| | | | | | http://reviews.llvm.org/D18534 llvm-svn: 264693
* [llvm-readobj] NFC Replace case by macros for PT_* enumsHemant Kulkarni2016-03-281-24/+16
| | | | llvm-svn: 264595
* Fix Narrowing conversion warning introduced by r264415Hemant Kulkarni2016-03-251-1/+1
| | | | llvm-svn: 264419
* [llvm-readobj] Impl GNU style program headers printHemant Kulkarni2016-03-251-20/+226
| | | | | | | | readelf -lW Differential Revision: http://reviews.llvm.org/D18372 llvm-svn: 264415
* [llvm-readobj] Decode st_other symbol's flagsSimon Atanasyan2016-03-241-1/+41
| | | | | | | | | The patch supports common STV_xxx visibility flags and MIPS specific STO_MIPS_xxx flags. Differential Revision: http://reviews.llvm.org/D18447 llvm-svn: 264300
* Fix a crash in running llvm-objdump -t with an invalid Mach-O file alreadyKevin Enderby2016-03-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the test suite. While this is not really an interesting tool and option to run on a Mach-O file to show the symbol table in a generic libObject format it shouldn’t crash. The reason for the crash was in MachOObjectFile::getSymbolType() when it was calling MachOObjectFile::getSymbolSection() without checking its return value for the error case. What makes this fix require a fair bit of diffs is that the method getSymbolType() is in the class ObjectFile defined without an ErrorOr<> so I needed to add that all the sub classes.  And all of the uses needed to be updated and the return value needed to be checked for the error case. The MachOObjectFile version of getSymbolType() “can” get an error in trying to come up with the libObject’s internal SymbolRef::Type when the Mach-O symbol symbol type is an N_SECT type because the code is trying to select from the SymbolRef::ST_Data or SymbolRef::ST_Function values for the SymbolRef::Type. And it needs the Mach-O section to use isData() and isBSS to determine if it will return SymbolRef::ST_Data. One other possible fix I considered is to simply return SymbolRef::ST_Other when MachOObjectFile::getSymbolSection() returned an error. But since in the past when I did such changes that “ate an error in the libObject code” I was asked instead to push the error out of the libObject code I chose not to implement the fix this way. As currently written both the COFF and ELF versions of getSymbolType() can’t get an error. But if isReservedSectionNumber() wanted to check for the two known negative values rather than allowing all negative values or the code wanted to add the same check as in getSymbolAddress() to use getSection() and check for the error then these versions of getSymbolType() could return errors. At the end of the day the error printed now is the generic “Invalid data was encountered while parsing the file” for object_error::parse_failed. In the future when we thread Lang’s new TypedError for recoverable error handling though libObject this will improve. And where the added // Diagnostic(… comment is, it would be changed to produce and error message like “bad section index (42) for symbol at index 8” for this case. llvm-svn: 264187
* [llvm-readobj] Impl GNU style symbols printingHemant Kulkarni2016-03-211-40/+174
| | | | | | | | Implements "readelf -sW and readelf -DsW" Differential Revision: http://reviews.llvm.org/D18224 llvm-svn: 263952
* [llvm-readobj] Impl GNU style printing of sections and relocationsHemant Kulkarni2016-03-153-269/+646
| | | | | | Differential Revision: http://reviews.llvm.org/D17523 llvm-svn: 263561
* [MachO] Add MachO alt-entry directive support.Lang Hames2016-03-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the MachO .alt_entry assembly directive, and uses it for global aliases with non-zero GEP offsets. The alt_entry flag indicates that a symbol should be layed out immediately after the preceding symbol. Conceptually it introduces an alternate entry point for a function or data structure. E.g.: safe_foo: // check preconditions for foo .alt_entry fast_foo fast_foo: // body of foo, can assume preconditions. The .alt_entry flag is also implicitly set on assembly aliases of the form: a = b + C where C is a non-zero constant, since these have the same effect as an alt_entry symbol: they introduce a label that cannot be moved relative to the preceding one. Setting the alt_entry flag on aliases of this form fixes http://llvm.org/PR25381. llvm-svn: 263521
* [llvm-readobj] Enable GNU style section group printHemant Kulkarni2016-03-091-34/+87
| | | | | | Differential Revision: http://reviews.llvm.org/D17822 llvm-svn: 263050
OpenPOWER on IntegriCloud