summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj
Commit message (Collapse)AuthorAgeFilesLines
* [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
* Fix typo. NFC.Tim Northover2016-03-012-3/+3
| | | | llvm-svn: 262405
* [lanai] Add ELF enum value and relocations.Jacques Pienaar2016-03-011-1/+2
| | | | | | | | | | Add ELF enum value and relocations for Lanai backed. General Lanai backend discussion on llvm-dev thread "[RFC] Lanai backend" (http://lists.llvm.org/pipermail/llvm-dev/2016-February/095118.html). Differential Revision: http://reviews.llvm.org/D17008 llvm-svn: 262394
* Reverts change r261907 and r261918Hemant Kulkarni2016-02-253-682/+265
| | | | llvm-svn: 261927
* Fix endianness issue on BE machines introduced by r261907Hemant Kulkarni2016-02-251-3/+4
| | | | llvm-svn: 261918
* [llvm-readobj] Enable GNU style sections and relocations printingHemant Kulkarni2016-02-253-265/+681
| | | | | | http://reviews.llvm.org/D17523 llvm-svn: 261907
* Remove uses of builtin comma operator.Richard Trieu2016-02-181-11/+11
| | | | | | Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261270
* [readobj] Remove uneeded braces in case statement.Michael J. Spencer2016-02-171-2/+1
| | | | llvm-svn: 261170
* Represent the dynamic table itself with a DynRegionInfo.Rafael Espindola2016-02-171-12/+17
| | | | | | | | | | | | The dynamic table is also an array of a fixed structure, so it can be represented with a DynReginoInfo. No major functionality change. The extra error checking is covered by existing tests with a broken dynamic program header. Idea extracted from r260488. I did the extra cleanups. llvm-svn: 261107
* Add a unwrapOrError utility and use it to simplify ELFDumper.cpp.Rafael Espindola2016-02-172-119/+77
| | | | | | Utility extracted from r260488. llvm-svn: 261103
* Change how readobj stores info about dynamic symbols.Rafael Espindola2016-02-171-44/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to keep both a section and a pointer to the first symbol. The oddity of keeping a section for dynamic symbols is because there is a DT_SYMTAB but no DT_SYMTABZ, so to print the table we have to find the size via a section table. The reason for still keeping a pointer to the first symbol is because we want to be able to print relocation tables even if the section table is missing (it is mandatory only for files used in linking). With this patch we keep just a DynRegionInfo. This then requires changing a few places that were asking for a Elf_Shdr but actually just needed the first symbol. The test change is to delete the program header pointer. Now that we use the information of both DT_SYMTAB and .dynsym, we don't depend on the sh_entsize of .dynsym if we see DT_SYMTAB. Note: It is questionable if it is worth it putting the effort to report broken sh_entsize given that in files with no section table we have to assume it is sizeof(Elf_Sym), but that is for another change. Extracted from r260488. llvm-svn: 261099
* Reapply r260489.Rafael Espindola2016-02-161-0/+29
| | | | | | | | | | Original commit message: [readobj] Dump DT_JMPREL relocations when outputting dynamic relocations. The bits of r260488 it depends on have been committed. llvm-svn: 260970
* Introduce a getAsRange helper.Rafael Espindola2016-02-161-25/+9
| | | | | | | | | This requires making an error message a bit more generic, but that seems a reasonable tradeoff. Extracted from r260488 but simplified a bit. llvm-svn: 260967
* Move DynRegionInfo out of the ELFDumper.Rafael Espindola2016-02-161-11/+11
| | | | | | | | This reduces indentation in preparation to adding a bit more code to it. Extracted from r260488. llvm-svn: 260963
* This reverts commit r260488 and r260489.Rafael Espindola2016-02-162-187/+98
| | | | | | | | | | | Original messages: Revert "[readobj] Handle ELF files with no section table or with no program headers." Revert "[readobj] Dump DT_JMPREL relocations when outputting dynamic relocations." r260489 depends on r260488 and among other issues r260488 deleted error handling code. llvm-svn: 260962
* [codeview] Dump def range lengths in hexReid Kleckner2016-02-111-3/+3
| | | | | | | It makes it easier to correlate with assembly dumps, which are typically given with hex offsets. llvm-svn: 260619
* [readobj] Dump DT_JMPREL relocations when outputting dynamic relocations.Michael J. Spencer2016-02-111-0/+28
| | | | llvm-svn: 260489
* [readobj] Handle ELF files with no section table or with no program headers.Michael J. Spencer2016-02-112-98/+159
| | | | | | | | This adds support for finding the dynamic table and dynamic symbol table via the section table or the program header table. If there's no section table an attempt is made to figure out the length of the dynamic symbol table. llvm-svn: 260488
* [readobj] Move dynamic table parsing to a new function. NFC.Michael J. Spencer2016-02-111-5/+14
| | | | llvm-svn: 260487
* [readobj] Sort switch by enum value.Michael J. Spencer2016-02-111-29/+29
| | | | | | | Sort by enum value, but keep related entries adjacent. This makes it easier to compare against documentation. llvm-svn: 260486
* [readobj] Parse sections before dynamic table.Michael J. Spencer2016-02-111-36/+36
| | | | | | | NFC. This code will be expanded to handle dynamic tables that don't have a PT_DYNAMIC. llvm-svn: 260485
* Fix const confusion while lambda function usageHemant Kulkarni2016-02-111-24/+26
| | | | llvm-svn: 260484
* Fix build failure caused in r260430Hemant Kulkarni2016-02-111-1/+1
| | | | llvm-svn: 260471
* [llvm-readobj] Option to emit readelf like outputHemant Kulkarni2016-02-105-283/+412
| | | | | | | | | 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
* Revert "[llvm-readobj] Option to emit readelf like output"Hemant Kulkarni2016-02-105-411/+283
| | | | | | This reverts commit a58765909660a7195b32e0cc8c7476168b913750. llvm-svn: 260397
* [llvm-readobj] Option to emit readelf like outputHemant Kulkarni2016-02-105-283/+411
| | | | | | | | | 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
* [llvm-readobj][ELF] Show MIPS GOT content when there is another zero-sized ↵Simon Atanasyan2016-02-091-40/+25
| | | | | | | | | | | | | section at the same address It is possible to have .got section and one or more zero-sized section at the same address. This patch first checks that GOT (or GOT PLT) section should have non-zero size using corresponding dynamic tags. Then it looks up not empty section at the specified address. Differential Revision: http://reviews.llvm.org/D16968 llvm-svn: 260245
* [codeview] Dump a missing field and change its signednessReid Kleckner2016-02-051-0/+2
| | | | llvm-svn: 259904
* Correctly handle {Always,Never}StepIntoLineDavid Majnemer2016-02-041-8/+9
| | | | llvm-svn: 259806
OpenPOWER on IntegriCloud