aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-readobj
AgeCommit message (Collapse)AuthorFilesLines
2016-12-06[llvm-readobj] - Teach readobj to print PT_OPENBSD_BOOTDATA headerGeorge Rimar1-0/+1
These are OpenBSD specific program headers. OpenBSD commit: https://github.com/openbsd/src/commit/d39116912b9536bd77326260dc5c6e593fd4ee24 It is required for fixing PR31288. Differential revision: https://reviews.llvm.org/D27456 llvm-svn: 288831
2016-11-23llvm-readobj: Use hash tables to print dynamic symbols.Hemant Kulkarni1-1/+108
-symbols prints both .symtab and .dynsym symbols for GNU style in ELF. -dyn-symbols prints symbols looking up through hash tables. This helps validate hash tables. llvm-svn: 287786
2016-11-16[ELF] Convert ELF.h to Expected<T>.Davide Italiano1-12/+13
This has two advantages: 1) We slowly move away from ErrorOr to the new handling interface, in the hope of having an uniform error handling in LLVM, eventually. 2) We're starting to have *meaningful* error messages for invalid object ELF files, rather than a generic "parse error". At some point we should include also the offset to improve the quality of the diagnostic. llvm-svn: 287081
2016-11-11Make the Error class constructor protectedMehdi Amini1-1/+1
This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable. Differential Revision: https://reviews.llvm.org/D26481 llvm-svn: 286561
2016-11-08[CodeView] Hook up CodeViewRecordIO to type serialization path.Zachary Turner3-16/+14
Previously support had been added for using CodeViewRecordIO to read (deserialize) CodeView type records. This patch adds support for writing those same records. With this patch, reading and writing of CodeView type records finally uses a single codepath. Differential Revision: https://reviews.llvm.org/D26253 llvm-svn: 286304
2016-11-03Remove the last use of report_fatal_error from ELF.h.Rafael Espindola2-7/+7
llvm-svn: 285955
2016-11-03Add error handling to getEntry.Rafael Espindola2-9/+13
Issue found by inspection. llvm-svn: 285951
2016-11-03Replace a report_fatal_error with an ErrorOr.Rafael Espindola1-5/+5
llvm-svn: 285942
2016-11-03Delete some dead code and add a missing "0x" prefix to a hex string inChandler Carruth1-2/+1
llvm-readobj. Another bug caught by PVS-Studio. It'd be nice to actually have a test for this, but I found it by inspection from PVS-Studio. llvm-svn: 285937
2016-11-03Move a free function out of ELFFile.Rafael Espindola1-8/+8
llvm-svn: 285920
2016-11-03replace a report_fatal_error with a ErrorOr.Rafael Espindola1-4/+4
llvm-svn: 285910
2016-11-03Replace a report_fatal_error with an ErrorOr.Rafael Espindola2-4/+5
llvm-svn: 285905
2016-11-02Avoid a report_fatal_error in sections().Rafael Espindola2-15/+15
Have it return a ErrorOr<Range> and delete section_begin and section_end. llvm-svn: 285807
2016-11-01[RISCV] Add RISC-V ELF definesAlex Bradbury1-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
2016-10-20[CodeView] Refactor serialization to use StreamInterface.Zachary Turner1-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
2016-10-19Remove LLVM_NOEXCEPT and replace it with noexceptReid Kleckner1-2/+2
Now that we have dropped MSVC 2013, all supported compilers support noexcept and we can drop this portability macro. llvm-svn: 284672
2016-10-18[llvm-readobj] - Teach readobj to print ↵George Rimar1-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
2016-10-08Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini1-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
2016-10-07Refactor Symbol visitor code.Zachary Turner1-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
2016-10-06Refactor to use getSectionContentsAsArray.Rafael Espindola1-1/+1
This centralizes quite a bit of error checking. llvm-svn: 283454
2016-10-06Refactor duplicated typedefs. NFC.Rafael Espindola1-29/+9
llvm-svn: 283453
2016-10-06Use range loop. NFC.Rafael Espindola1-8/+8
llvm-svn: 283447
2016-09-14[Stackmap] Added callsite counts to emitted function information.Sanjoy Das4-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
2016-09-09[pdb] Write PDB TPI Stream from Yaml.Zachary Turner1-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
2016-09-02[llvm-readobj] - Teach readobj to print DT_AUXILIARY dynamic tag in human ↵George Rimar1-0/+4
readable form. Previously DT_AUXILIARY was unknown, patch fixes that. Differential revision: https://reviews.llvm.org/D24138 llvm-svn: 280471
2016-08-31Fix the MSVC 2013 build by using Elf_Word instead of making a local typedefReid Kleckner1-6/+4
llvm-svn: 280304
2016-08-30llvm-readobj: speculative fix for MSVCSaleem Abdulrasool1-1/+1
Use the typedef rather than using to type alias the typename. llvm-svn: 280158
2016-08-30Revert "ELFDumper: Unversioned symbols must not have trailing @"Hemant Kulkarni1-3/+0
This reverts commit 8df7a877949e8782a3a28e3ecdb0770c1e444056. Fixing other repositories and adding changes together. llvm-svn: 280152
2016-08-30ELFDumper: Unversioned symbols must not have trailing @Hemant Kulkarni1-0/+3
llvm-svn: 280140
2016-08-30llvm-readobj: add support for printing GNU NotesSaleem Abdulrasool3-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
2016-08-18llvm-readobj: handle import libraries with -coff-exportsSaleem Abdulrasool1-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
2016-08-17Replace "fallthrough" comments with LLVM_FALLTHROUGHJustin Bogner1-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
2016-08-09CodeView: extract the OMF Directory HeaderSaleem Abdulrasool1-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
2016-08-05[CodeView] Decouple record deserialization from visitor dispatch.Zachary Turner2-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
2016-08-04[CodeView] Use llvm::Error instead of std::error_code.Zachary Turner2-0/+9
This eliminates the remnants of std::error_code from the DebugInfo libraries. llvm-svn: 277758
2016-07-29[msf] Resubmit "Rename Msf -> MSF".Zachary Turner3-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
2016-07-29Revert "[msf] Rename Msf to MSF."Zachary Turner3-3/+3
This reverts commit 4d1557ffac41e079bcb1abbcf04f512474dcd6fe. llvm-svn: 277194
2016-07-29[msf] Rename Msf to MSF.Zachary Turner3-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
2016-07-28[pdb] Refactor library to more clearly separate reading/writingZachary Turner1-2/+2
Reviewed By: amccarth, ruiu Differential Revision: https://reviews.llvm.org/D22693 llvm-svn: 277019
2016-07-22[msf] Create LLVMDebugInfoMsfZachary Turner3-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
2016-07-20llvm-readobj: add some more aliasesSaleem Abdulrasool1-0/+4
Alias -d and -t from readelf in llvm-readobj which effectively replaces the tool. llvm-svn: 276075
2016-07-15BPF: Use official ELF e_machine valueAlexei Starovoitov1-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
2016-07-14[Object] Re-apply r275316 now that I have the corresponding LLD patch ready.Lang Hames1-4/+15
llvm-svn: 275361
2016-07-14[Object] Revert r275316, Archive::child_iterator changes, while I update lld.Lang Hames1-15/+4
Should fix the bots broken by r275316. llvm-svn: 275353
2016-07-13[Object] Change Archive::child_iterator for better interop with Error/Expected.Lang Hames1-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
2016-06-28Finish cleaning up most of the error handling in libObject’s ↵Kevin Enderby1-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
2016-06-24Thread Expected<...> up from libObject’s getSymbolAddress() for symbols to ↵Kevin Enderby2-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
2016-06-22[llvm-readobj] - Teach llvm-readobj to print dependencies of SHT_GNU_verdef ↵George Rimar1-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
2016-06-21Delete some dead code.Rafael Espindola1-16/+0
Found by gcc 6. llvm-svn: 273303
2016-06-16Resubmit "[pdb] Change type visitor pattern to be dynamic."Zachary Turner1-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