summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj
Commit message (Collapse)AuthorAgeFilesLines
...
* Move a free function out of ELFFile.Rafael Espindola2016-11-031-8/+8
| | | | llvm-svn: 285920
* replace a report_fatal_error with a ErrorOr.Rafael Espindola2016-11-031-4/+4
| | | | llvm-svn: 285910
* Replace a report_fatal_error with an ErrorOr.Rafael Espindola2016-11-032-4/+5
| | | | llvm-svn: 285905
* Avoid a report_fatal_error in sections().Rafael Espindola2016-11-022-15/+15
| | | | | | | Have it return a ErrorOr<Range> and delete section_begin and section_end. llvm-svn: 285807
* [RISCV] Add RISC-V ELF definesAlex Bradbury2016-11-011-0/+1
| | | | | | | | | | Add the necessary definitions for RISC-V ELF files, including relocs. Also make necessary trivial change to ELFYaml, llvm-objdump, and llvm-readobj in order to work with RISC-V ELFs. Differential Revision: https://reviews.llvm.org/D23557 llvm-svn: 285708
* [CodeView] Refactor serialization to use StreamInterface.Zachary Turner2016-10-201-18/+29
| | | | | | | | | | | | | | | | | | | This was all using ArrayRef<>s before which presents a problem when you want to serialize to or deserialize from an actual PDB stream. An ArrayRef<> is really just a special case of what can be handled with StreamInterface though (e.g. by using a ByteStream), so changing this to use StreamInterface allows us to plug in a PDB stream and get all the record serialization and deserialization for free on a MappedBlockStream. Subsequent patches will try to remove TypeTableBuilder and TypeRecordBuilder in favor of class that operate on Streams as well, which should allow us to completely merge the reading and writing codepaths for both types and symbols. Differential Revision: https://reviews.llvm.org/D25831 llvm-svn: 284762
* Remove LLVM_NOEXCEPT and replace it with noexceptReid Kleckner2016-10-191-2/+2
| | | | | | | Now that we have dropped MSVC 2013, all supported compilers support noexcept and we can drop this portability macro. llvm-svn: 284672
* [llvm-readobj] - Teach readobj to print ↵George Rimar2016-10-181-0/+4
| | | | | | | | | | | | | | | | | | | | PT_OPENBSD_RANDOMIZE/PT_OPENBSD_WXNEEDED headers. These are OpenBSD specific program headers and currently we support them in LLD. Description of headers (just in case) available here: http://man.openbsd.org/OpenBSD-current/man5/elf.5 OpenBSD commits were: For PT_OPENBSD_RANDOMIZE: https://github.com/openbsd/src/commit/c494713c450d98da3f2e1451ee8c7fb675a7c461 For PT_OPENBSD_WXNEEDED: https://github.com/openbsd/src/commit/2a5a8fc7e30928c2cff57cfe5fb491c90d8478ad Differential revision: https://reviews.llvm.org/D25616 llvm-svn: 284471
* Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini2016-10-081-1/+1
| | | | | | | | | | | | | | | template The core of the change is supposed to be NFC, however it also fixes what I believe was an undefined behavior when calling: va_start(ValueArgs, Desc); with Desc being a StringRef. Differential Revision: https://reviews.llvm.org/D25342 llvm-svn: 283671
* Refactor Symbol visitor code.Zachary Turner2016-10-071-2/+3
| | | | | | | | | | | | | Type visitor code had already been refactored previously to decouple the visitor and the visitor callback interface. This was necessary for having the flexibility to visit in different ways (for example, dumping to yaml, reading from yaml, dumping to ScopedPrinter, etc). This patch merely implements the same visitation pattern for symbol records that has already been implemented for type records. llvm-svn: 283609
* Refactor to use getSectionContentsAsArray.Rafael Espindola2016-10-061-1/+1
| | | | | | This centralizes quite a bit of error checking. llvm-svn: 283454
* Refactor duplicated typedefs. NFC.Rafael Espindola2016-10-061-29/+9
| | | | llvm-svn: 283453
* Use range loop. NFC.Rafael Espindola2016-10-061-8/+8
| | | | llvm-svn: 283447
* [Stackmap] Added callsite counts to emitted function information.Sanjoy Das2016-09-144-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: It was previously not possible for tools to use solely the stackmap information emitted to reconstruct the return addresses of callsites in the map, which is necessary to use the information to walk a stack. This patch adds per-function callsite counts when emitting the stackmap section in order to resolve the problem. Note that this slightly alters the stackmap format, so external tools parsing these maps will need to be updated. **Problem Details:** Records only store their offset from the beginning of the function they belong to. While these records and the functions are output in program order, it is not possible to determine where the end of one function's records are without the callsite count when processing the records to compute return addresses. Patch by Kavon Farvardin! Reviewers: atrick, ributzka, sanjoy Subscribers: nemanjai Differential Revision: https://reviews.llvm.org/D23487 llvm-svn: 281532
* [pdb] Write PDB TPI Stream from Yaml.Zachary Turner2016-09-091-3/+10
| | | | | | | | | | This writes the full sequence of type records described in Yaml to the TPI stream of the PDB file. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D24316 llvm-svn: 281063
* [llvm-readobj] - Teach readobj to print DT_AUXILIARY dynamic tag in human ↵George Rimar2016-09-021-0/+4
| | | | | | | | | | readable form. Previously DT_AUXILIARY was unknown, patch fixes that. Differential revision: https://reviews.llvm.org/D24138 llvm-svn: 280471
* Fix the MSVC 2013 build by using Elf_Word instead of making a local typedefReid Kleckner2016-08-311-6/+4
| | | | llvm-svn: 280304
* llvm-readobj: speculative fix for MSVCSaleem Abdulrasool2016-08-301-1/+1
| | | | | | Use the typedef rather than using to type alias the typename. llvm-svn: 280158
* Revert "ELFDumper: Unversioned symbols must not have trailing @"Hemant Kulkarni2016-08-301-3/+0
| | | | | | | | This reverts commit 8df7a877949e8782a3a28e3ecdb0770c1e444056. Fixing other repositories and adding changes together. llvm-svn: 280152
* ELFDumper: Unversioned symbols must not have trailing @Hemant Kulkarni2016-08-301-0/+3
| | | | llvm-svn: 280140
* llvm-readobj: add support for printing GNU NotesSaleem Abdulrasool2016-08-303-0/+145
| | | | | | | | | Add support for printing the GNU Notes. This allows an easy way to view the build id for a binary built with the build id. Currently, this only handles the GNU notes, though it would be easy to extend for other note types (default, FreeBSD, NetBSD, etc). Only the GNU style is supported currently. llvm-svn: 280131
* llvm-readobj: handle import libraries with -coff-exportsSaleem Abdulrasool2016-08-181-0/+2
| | | | | | | | `link -dump -exports` lists exported symbols from import libraries as well as normal dlls. Ensure that we can handle import libraries as well in llvm-readobj. llvm-svn: 279069
* Replace "fallthrough" comments with LLVM_FALLTHROUGHJustin Bogner2016-08-171-1/+1
| | | | | | | This is a mechanical change of comments in switches like fallthrough, fall-through, or fall-thru to use the LLVM_FALLTHROUGH macro instead. llvm-svn: 278902
* CodeView: extract the OMF Directory HeaderSaleem Abdulrasool2016-08-091-6/+8
| | | | | | | | | | | | The DebugDirectory contains a pointer to the CodeView info structure which is a derivative of the OMF debug directory. The structure has evolved a bit over time, and PDB 2.0 used a slightly different definition from PDB 7.0. Both of these are specific to CodeView and not COFF. Reflect this by moving the structure definitions into the DebugInfo/CodeView headers. Define a generic DebugInfo union type that can be used to pass around a reference to the DebugInfo irrespective of the versioning. NFC. llvm-svn: 278075
* [CodeView] Decouple record deserialization from visitor dispatch.Zachary Turner2016-08-052-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, our use case for the visitor has been to take a stream of bytes representing a type stream, deserialize the records in sequence, and do something with them, where "something" is determined by how the user implements a particular set of callbacks on an abstract class. For actually writing PDBs, however, we want to do the reverse. We have some kind of description of the list of records in their in-memory format, and we want to process each one. Perhaps by serializing them to a byte stream, or perhaps by converting them from one description format (Yaml) to another (in-memory representation). This was difficult in the current model because deserialization and invoking the callbacks were tightly coupled. With this patch we change this so that TypeDeserializer is itself an implementation of the particular set of callbacks. This decouples deserialization from the iteration over a list of records and invocation of the callbacks. TypeDeserializer is initialized with another implementation of the callback interface, so that upon deserialization it can pass the deserialized record through to the next set of callbacks. In a sense this is like an implementation of the Decorator design pattern, where the Deserializer is a decorator. This will be useful for writing Pdbs from yaml, where we have a description of the type records in Yaml format. In this case, the visitor implementation would have each visitation callback method implemented in such a way as to extract the proper set of fields from the Yaml, and it could maintain state that builds up a list of these records. Finally at the end we can pass this information through to another set of callbacks which serializes them into a byte stream. Reviewed By: majnemer, ruiu, rnk Differential Revision: https://reviews.llvm.org/D23177 llvm-svn: 277871
* [CodeView] Use llvm::Error instead of std::error_code.Zachary Turner2016-08-042-0/+9
| | | | | | | This eliminates the remnants of std::error_code from the DebugInfo libraries. llvm-svn: 277758
* [msf] Resubmit "Rename Msf -> MSF".Zachary Turner2016-07-293-3/+3
| | | | | | | | | | | | | Previously this change was submitted from a Windows machine, so changes made to the case of filenames and directory names did not survive the commit, and as a result the CMake source file names and the on-disk file names did not match on case-sensitive file systems. I'm resubmitting this patch from a Linux system, which hopefully allows the case changes to make it through unfettered. llvm-svn: 277213
* Revert "[msf] Rename Msf to MSF."Zachary Turner2016-07-293-3/+3
| | | | | | This reverts commit 4d1557ffac41e079bcb1abbcf04f512474dcd6fe. llvm-svn: 277194
* [msf] Rename Msf to MSF.Zachary Turner2016-07-293-3/+3
| | | | | | | | In a previous patch, it was suggested to use all caps instead of rolling caps for initialisms, so this patch changes everything to do this. llvm-svn: 277190
* [pdb] Refactor library to more clearly separate reading/writingZachary Turner2016-07-281-2/+2
| | | | | | | Reviewed By: amccarth, ruiu Differential Revision: https://reviews.llvm.org/D22693 llvm-svn: 277019
* [msf] Create LLVMDebugInfoMsfZachary Turner2016-07-223-2/+4
| | | | | | | | | | | | | | This provides a better layering of responsibilities among different aspects of PDB writing code. Some of the MSF related code was contained in CodeView, and some was in PDB prior to this. Further, we were often saying PDB when we meant MSF, and the two are actually independent of each other since in theory you can have other types of data besides PDB data in an MSF. So, this patch separates the MSF specific code into its own library, with no dependencies on anything else, and DebugInfoCodeView and DebugInfoPDB take dependencies on DebugInfoMsf. llvm-svn: 276458
* llvm-readobj: add some more aliasesSaleem Abdulrasool2016-07-201-0/+4
| | | | | | | Alias -d and -t from readelf in llvm-readobj which effectively replaces the tool. llvm-svn: 276075
* BPF: Use official ELF e_machine valueAlexei Starovoitov2016-07-151-0/+1
| | | | | | | | | The same value for EM_BPF is being propagated to glibc, elfutils, and binutils. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org> llvm-svn: 275633
* [Object] Re-apply r275316 now that I have the corresponding LLD patch ready.Lang Hames2016-07-141-4/+15
| | | | llvm-svn: 275361
* [Object] Revert r275316, Archive::child_iterator changes, while I update lld.Lang Hames2016-07-141-15/+4
| | | | | | Should fix the bots broken by r275316. llvm-svn: 275353
* [Object] Change Archive::child_iterator for better interop with Error/Expected.Lang Hames2016-07-131-4/+15
| | | | | | | | | | | | | | | | | | | | | | | See http://reviews.llvm.org/D22079 Changes the Archive::child_begin and Archive::children to require a reference to an Error. If iterator increment fails (because the archive header is damaged) the iterator will be set to 'end()', and the error stored in the given Error&. The Error value should be checked by the user immediately after the loop. E.g.: Error Err; for (auto &C : A->children(Err)) { // Do something with archive child C. } // Check the error immediately after the loop. if (Err) return Err; Failure to check the Error will result in an abort() when the Error goes out of scope (as guaranteed by the Error class). llvm-svn: 275316
* Finish cleaning up most of the error handling in libObject’s ↵Kevin Enderby2016-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MachOUniversalBinary and its clients to use the new llvm::Error model for error handling. Changed getAsArchive() from ErrorOr<...> to Expected<...> so now all interfaces there use the new llvm::Error model for return values. In the two places it had if (!Parent) this is actually a program error so changed from returning errorCodeToError(object_error::parse_failed) to calling report_fatal_error() with a message. In getObjectForArch() added error messages to its two llvm::Error return values instead of returning errorCodeToError(object_error::arch_not_found) with no error message. For the llvm-obdump, llvm-nm and llvm-size clients since the only binary files in Mach-O Universal Binaries that are supported are Mach-O files or archives with Mach-O objects, updated their logic to generate an error when a slice contains something like an ELF binary instead of ignoring it. And added a test case for that. The last error stuff to be cleaned up for libObject’s MachOUniversalBinary is the use of errorOrToExpected(Archive::create(ObjBuffer)) which needs Archive::create() to be changed from ErrorOr<...> to Expected<...> first, which I’ll work on next. llvm-svn: 274079
* Thread Expected<...> up from libObject’s getSymbolAddress() for symbols to ↵Kevin Enderby2016-06-242-13/+30
| | | | | | | | | | | | | | | | | | | | | allow a good error message to be produced. This is nearly the last libObject interface that used ErrorOr and the last one that appears in llvm/include/llvm/Object/MachO.h . For Mach-O objects this is just a clean up because it’s version of getSymbolAddress() can’t return an error. I will leave it to the experts on COFF and ELF to actually add meaning full error messages in their tests if they wish. And also leave it to these experts to change the last two ErrorOr interfaces in llvm/include/llvm/Object/ObjectFile.h for createCOFFObjectFile() and createELFObjectFile() if they wish. Since there are no test cases for COFF and ELF error cases with respect to getSymbolAddress() in the test suite this is no functional change (NFC). llvm-svn: 273701
* [llvm-readobj] - Teach llvm-readobj to print dependencies of SHT_GNU_verdef ↵George Rimar2016-06-221-18/+26
| | | | | | | | | | | | | | | and refactor dumping method. This patch changes single method of llvm-readobj. It teaches SHT_GNU_verdef dumper to print version dependencies, also it removes few fields from output that can be dumped with other keys and slightly refactors code. Testcase was also modified to match the changes. Change is required for testcases of upcoming lld patches. Differential revision: http://reviews.llvm.org/D21552 llvm-svn: 273417
* Delete some dead code.Rafael Espindola2016-06-211-16/+0
| | | | | | Found by gcc 6. llvm-svn: 273303
* Resubmit "[pdb] Change type visitor pattern to be dynamic."Zachary Turner2016-06-161-4/+4
| | | | | | | There was a regression introduced during type stream merging when visiting a field list record. This has been fixed in this patch. llvm-svn: 272929
* Revert "[pdb] Change type visitor pattern to be dynamic."Zachary Turner2016-06-161-2/+2
| | | | | | | | This reverts commit fb0dd311e1ad945827b8ffd5354f4810e2be1579. This breaks some llvm-readobj tests. llvm-svn: 272927
* [pdb] Change type visitor pattern to be dynamic.Zachary Turner2016-06-161-2/+2
| | | | | | | | | | | | | | | This allows better catching of compiler errors since we can use the override keyword to verify that methods are actually overridden. Also in this patch I've changed from storing a boolean Error code everywhere to returning an llvm::Error, to propagate richer error information up the call stack. Reviewed By: ruiu, rnk Differential Revision: http://reviews.llvm.org/D21410 llvm-svn: 272926
* Add support for writing through StreamInterface.Zachary Turner2016-06-101-2/+2
| | | | | | | | | | | This adds method and tests for writing to a PDB stream. With this, even a PDB stream which is discontiguous can be treated as a sequential stream of bytes for the purposes of writing. Reviewed By: ruiu Differential Revision: http://reviews.llvm.org/D21157 llvm-svn: 272369
* Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith2016-06-091-1/+1
| | | | | | | looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
* [llvm-readobj] - Teach llvm-readobj to dump .gnu.version_r sectionsGeorge Rimar2016-06-071-0/+55
| | | | | | | | | | SHT_GNU_verneed (.gnu.version_r) is a version dependency section. It was the last symbol versioning relative section that was not dumped, now it is. Differential revision: http://reviews.llvm.org/D21024 llvm-svn: 271998
* [codeview] Dump line number and column information.Zachary Turner2016-06-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | To facilitate this, a couple of changes had to be made: 1. `ModuleSubstream` got moved from `DebugInfo/PDB` to `DebugInfo/CodeView`, and various codeview related types are defined there. It turns out `DebugInfo/CodeView/Line.h` already defines many of these structures, but this is really old code that is not endian aware, doesn't interact well with `StreamInterface` and not very helpful for getting stuff out of a PDB. Eventually we should migrate the old readobj `COFFDumper` code to these new structures, or at least merge their functionality somehow. 2. A `ModuleSubstream` visitor is introduced. Depending on where your module substream array comes from, different subsets of record types can be expected. We are already hand parsing these substream arrays in many places especially in `COFFDumper.cpp`. In the future we can migrate these paths to the visitor as well, which should reduce a lot of code in `COFFDumper.cpp`. Differential Revision: http://reviews.llvm.org/D20936 Reviewed By: ruiu, majnemer llvm-svn: 271621
* Rename IMAGE_DEBUG_TYPE_NO_TIMESTAMP to IMAGE_DEBUG_TYPE_REPRODavid Majnemer2016-06-021-1/+2
| | | | | | This matches the COFF spec llvm-svn: 271549
* [COFF] Expose the PE debug data directory and dump itReid Kleckner2016-06-023-1/+63
| | | | | | | | | | | | This directory is used to find if there is a PDB associated with an executable. I plan to use this functionality to teach llvm-symbolizer whether it should use DIA or DWARF to symbolize a given DLL. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D20885 llvm-svn: 271539
* Change llvm-objdump, llvm-nm and llvm-size when reporting an object file errorKevin Enderby2016-05-311-3/+8
| | | | | | | | | | | | | | | | | | | when the object is from a slice of a Mach-O Universal Binary use something like "foo.o (for architecture i386)" as part of the error message when expected. Also fixed places in these tools that were ignoring object file errors from MachOUniversalBinary::getAsObjectFile() when the code moved on to see if the slice was an archive. To do this MachOUniversalBinary::getAsObjectFile() and MachOUniversalBinary::getObjectForArch() were changed from returning ErrorOr<...> to Expected<...> then that was threaded up to its users. Converting these interfaces 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 two places yet to be fully converted. llvm-svn: 271332
OpenPOWER on IntegriCloud