summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj/llvm-readobj.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-readobj] Generic hex-dump optionPaul Semel2018-07-251-2/+2
| | | | | | | | | | Helpers are available to make this option file format independant. This patch adds the feature for Wasm file format. It doesn't change the behavior of the other file format handling. Differential Revision: https://reviews.llvm.org/D49545 llvm-svn: 337896
* [llvm-readobj] Generic -string-dump optionPaul Semel2018-07-181-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D49470 llvm-svn: 337408
* MC: Implement support for new .addrsig and .addrsig_sym directives.Peter Collingbourne2018-07-171-0/+5
| | | | | | | | | Part of the address-significance tables proposal: http://lists.llvm.org/pipermail/llvm-dev/2018-May/123514.html Differential Revision: https://reviews.llvm.org/D47744 llvm-svn: 337328
* [llvm-readobj] Add -hex-dump (-x) optionPaul Semel2018-07-111-0/+10
| | | | | | Differential Revision: https://reviews.llvm.org/D48281 llvm-svn: 336782
* [llvm-readobj] Add experimental support for SHT_RELR sectionsJake Ehrlich2018-06-281-0/+4
| | | | | | | | | | | | | | | This change adds experimental support for SHT_RELR sections, proposed here: https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg Definitions for the new ELF section type and dynamic array tags, as well as the encoding used in the new section are all under discussion and are subject to change. Use with caution! Author: rahulchaudhry Differential Revision: https://reviews.llvm.org/D47919 llvm-svn: 335922
* [llvm-readobj] Add -string-dump (-p) optionPaul Semel2018-06-151-0/+10
| | | | | | | | This option prints the section content as a string. Differential Revision: https://reviews.llvm.org/D47989 llvm-svn: 334834
* [MC] Add assembler support for .cg_profile.Michael J. Spencer2018-06-021-0/+4
| | | | | | | | | | | | | | | Object FIle Representation At codegen time this is emitted into the ELF file a pair of symbol indices and a weight. In assembly it looks like: .cg_profile a, b, 32 .cg_profile freq, a, 11 .cg_profile freq, b, 20 When writing an ELF file these are put into a SHT_LLVM_CALL_GRAPH_PROFILE (0x6fff4c02) section as (uint32_t, uint32_t, uint64_t) tuples as (from symbol index, to symbol index, weight). Differential Revision: https://reviews.llvm.org/D44965 llvm-svn: 333823
* Remove @brief commands from doxygen comments, too.Adrian Prantl2018-05-011-6/+6
| | | | | | | | | | | | | | | | | This is a follow-up to r331272. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done https://reviews.llvm.org/D46290 llvm-svn: 331275
* Define InitLLVM to do common initialization all at once.Rui Ueyama2018-04-131-8/+3
| | | | | | | | | | | We have a few functions that virtually all command wants to run on process startup/shutdown. This patch adds InitLLVM class to do that all at once, so that we don't need to copy-n-paste boilerplate code to each llvm command's main() function. Differential Revision: https://reviews.llvm.org/D45602 llvm-svn: 330046
* CodeGen: support an extension to pass linker options on ELFSaleem Abdulrasool2018-01-301-0/+7
| | | | | | | | | | | | | | | | | | Introduce an extension to support passing linker options to the linker. These would be ignored by older linkers, but newer linkers which support this feature would be able to process the linker. Emit a special discarded section `.linker-option`. The content of this section is a pair of strings (key, value). The key is a type identifier for the parameter. This allows for an argument free parameter that will be processed by the linker with the value being the parameter. As an example, `lib` identifies a library to be linked against, traditionally the `-l` argument for Unix-based linkers with the parameter being the library name. Thanks to James Henderson, Cary Coutant, Rafael Espinolda, Sean Silva for the valuable discussion on the design of this feature. llvm-svn: 323783
* [llvm-readobj] Consistent use of ScopedPrinterSam Clegg2018-01-101-18/+21
| | | | | | | | | There were a few places where outs() was being used directly rather than the ScopedPrinter object. Differential Revision: https://reviews.llvm.org/D41370 llvm-svn: 322141
* Remove redundant includes from tools.Michael Zolotukhin2017-12-131-4/+0
| | | | llvm-svn: 320631
* Split TypeTableBuilder into two classes.Zachary Turner2017-11-301-3/+3
| | | | llvm-svn: 319456
* [llvm-readobj] Fix mismatched line endingsZachary Turner2017-11-301-7/+7
| | | | llvm-svn: 319453
* Add llvm::for_each as a range-based extensions to <algorithm> and make use ↵Aaron Ballman2017-11-031-8/+7
| | | | | | of it in some cases where it is a more clear alternative to std::for_each. llvm-svn: 317356
* llvm-readobj: Print AMDGPU note contentsKonstantin Zhuravlyov2017-10-141-8/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D38752 llvm-svn: 315819
* [llvm-readobj] Teach readobj to dump .res files (WindowsResource).Marek Sokolowski2017-09-201-0/+13
| | | | | | | | | | This enables readobj to output Windows resource files (.res). This way, we'll be able to test .res outputs without comparing them byte-by-byte with "magic binary files" generated by MS toolchain. Differential Revision: https://reviews.llvm.org/D38058 llvm-svn: 313790
* [llvm-readobj] Install llvm-readelf aliasPetr Hosek2017-07-191-1/+6
| | | | | | | | | | | Install an llvm-readelf symlink to llvm-readobj. When invoked as *readelf*, default to -elf-output-style=GNU. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D33869 llvm-svn: 308408
* [llvm-readobj] Accept (and ignore) --wide (-W) command-line switchPetr Hosek2017-07-181-0/+9
| | | | | | | | | | | | | Accept and ignore --wide/-W. In GNU readelf this switch is necessary to get the output format that's consistent between 32-bit and 64-bit targets. llvm-readobj always produces that output format. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D33873 llvm-svn: 308396
* [llvm-readobj] Accept -S as an alias for --sectionsPetr Hosek2017-07-181-1/+5
| | | | | | | | | | | | | | | In GNU readelf, the short option for --sections is upper-case -S. Note that GNU uses lower-case -s to mean --symbols, while LLVM uses -s to mean --sections and -t to mean --symbols (-t has yet a different meaning in GNU). So command-line uses with -S can now be compatible, but uses with -s or -t are still incompatible. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D33872 llvm-svn: 308392
* [llvm-readobj] Dump the COFF image load configReid Kleckner2017-06-221-0/+7
| | | | | | | | This includes the safe SEH tables and the control flow guard function table. LLD will emit the guard table soon, and I need a tool that dumps them for testing. llvm-svn: 305979
* [llvm-readobj] Improve errors on invalid binarySam Clegg2017-05-101-18/+3
| | | | | | | | | | | | | | The previous code was discarding the error message from createBinary() by calling errorToErrorCode(). This meant that such error were always reported unhelpfully as "Invalid data was encountered while parsing the file". Other tools such as llvm-objdump already produce a more the error message in this case. Differential Revision: https://reviews.llvm.org/D32985 llvm-svn: 302664
* [llvm-readobj] Dump COFF Resources section.Zachary Turner2017-04-271-0/+6
| | | | | | | | | | | | This patch dumps the raw bytes of the .rsrc sections that are present in COFF object and executable files. Subsequent patches will parse this information and dump in a more human readable format. Differential Revision: https://reviews.llvm.org/D32463 Patch By: Eric Beckmann llvm-svn: 301578
* [PDB] Split item and type records when merging type streamsReid Kleckner2017-03-241-4/+6
| | | | | | | | | | | | Summary: MSVC does this when producing a PDB. Reviewers: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31316 llvm-svn: 298717
* [AMDGPU] Restructure code object metadata creationKonstantin Zhuravlyov2017-03-221-5/+6
| | | | | | | | | | | | | | | | | - Rename runtime metadata -> code object metadata - Make metadata not flow - Switch enums to use ScalarEnumerationTraits - Cleanup and move AMDGPUCodeObjectMetadata.h to AMDGPU/MCTargetDesc - Introduce in-memory representation for attributes - Code object metadata streamer - Create metadata for isa and printf during EmitStartOfAsmFile - Create metadata for kernel during EmitFunctionBodyStart - Finalize and emit metadata to .note during EmitEndOfAsmFile - Other minor improvements/bug fixes Differential Revision: https://reviews.llvm.org/D29948 llvm-svn: 298552
* [WebAssembly] Add wasm support for llvm-readobjDerek Schuff2017-01-301-0/+2
| | | | | | | | | | | Create a WasmDumper subclass of ObjDumper to support Webassembly binary files. Patch by Sam Clegg Differential Revision: https://reviews.llvm.org/D27355 llvm-svn: 293569
* llvm-readobj: remove leading dash in '-a' option (ARMAttributesShort)Mehdi Amini2016-12-231-1/+1
| | | | | | cl::opt does not accept such option llvm-svn: 290465
* AMDGPU: Emit runtime metadata version 2 as YAMLYaxun Liu2016-12-141-0/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D25046 llvm-svn: 289674
* Make the Error class constructor protectedMehdi Amini2016-11-111-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
* [CodeView] Hook up CodeViewRecordIO to type serialization path.Zachary Turner2016-11-081-5/+5
| | | | | | | | | | | | 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
* 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
* [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: add support for printing GNU NotesSaleem Abdulrasool2016-08-301-0/+6
| | | | | | | | | 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
* [CodeView] Decouple record deserialization from visitor dispatch.Zachary Turner2016-08-051-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-041-0/+8
| | | | | | | This eliminates the remnants of std::error_code from the DebugInfo libraries. llvm-svn: 277758
* 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
* [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
* 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
* [COFF] Expose the PE debug data directory and dump itReid Kleckner2016-06-021-0/+7
| | | | | | | | | | | | 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
* 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
* [codeview] Add type stream merging prototypeReid Kleckner2016-05-141-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Print MIPS .MIPS.options section contentSimon Atanasyan2016-05-041-0/+6
| | | | | | | | | .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 llvm-readobj/StreamWriter to Support.Zachary Turner2016-05-031-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
* [llvm-readobj] Add ELF hash histogram printingHemant Kulkarni2016-04-111-0/+7
| | | | | | 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
OpenPOWER on IntegriCloud