aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.h
AgeCommit message (Collapse)AuthorFilesLines
2019-04-09[llvm-objdump] Migrate some functions from std::error_code to ErrorFangrui Song1-1/+0
llvm-svn: 357965
2019-04-08[llvm-objdump] Migrate relocation handling functions from error_code to ErrorFangrui Song1-16/+13
llvm-svn: 357920
2019-04-07[llvm-objdump] Simplify Expected<T> handling with unwrapOrErrorFangrui Song1-11/+14
llvm-svn: 357855
2019-02-25[llvm-objdump] Add `Version References` dumperXing GUO1-0/+1
Summary: Add symbol version dumper for [#30241](https://bugs.llvm.org/show_bug.cgi?id=30241) Reviewers: jhenderson, MaskRay, kristina, emaste, grimar Reviewed By: jhenderson, grimar Subscribers: grimar, rupprecht, jakehehrlich, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D54697 llvm-svn: 354782
2019-01-28[llvm-objdump] - Print LMAs when dumping section headers.George Rimar1-0/+3
When --section-headers is used, GNU objdump prints both LMA and VMA for sections. llvm-objdump does not do that what makes it's output be slightly inconsistent. Patch teaches llvm-objdump to print LMA/VMA for ELF file formats. The behavior for other formats remains unchanged. Differential revision: https://reviews.llvm.org/D57146 llvm-svn: 352366
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2019-01-18[llvm-objdump] - Move getRelocationValueString and dependenices out of the ↵George Rimar1-7/+76
llvm-objdump.cpp getRelocationValueString is a dispatcher function that calls the corresponding ELF/COFF/Wasm/MachO implementations that currently live in the llvm-objdump.cpp file. These implementations better be moved to ELFDump.cpp, COFFDump.cpp and other corresponding files, to move platform specific implementation out from the common logic. The patch does that. Also, I had to move ToolSectionFilter helper and SectionFilterIterator, SectionFilter to a header to make them available across the objdump code. Differential revision: https://reviews.llvm.org/D56842 llvm-svn: 351545
2019-01-15[llvm-objdump] - Cleanup the code. NFCI.George Rimar1-28/+28
This is a cosmetic cleanup for the llvm-objdump code. This patch: * Renames things to match the official LLVM code style (lower case -> upper case). * Removes few obviously excessive variables. * Moves a few lines closer to the place of use, reorders the code a bit to simplify it, to avoid doing excessive returns and to avoid using 'else` after returns. I focused only on a llvm-objdump.h/llvm-objdump.cpp files. Few changes in the MachODump.cpp and COFFDump.cpp are a result of llvm-objdump.h modification. Differential revision: https://reviews.llvm.org/D56637 llvm-svn: 351171
2018-08-20[llvm-objdump] Add ability to demangle COFF symbols.Zachary Turner1-1/+1
llvm-svn: 340221
2018-08-03objdump: Better handling of Mach-O universal binariesDave Lee1-0/+2
Summary: With Mach-O, there is a flag requirement discrepancy between working with universal binaries and thin binaries. Many flags that don't require the `-macho` flag (for example `-private-headers` and `-disassemble`) fail to work on universal binaries unless `-macho` is given. When this happens, the error message is unhelpful, stating: The file was not recognized as a valid object file. Which can lead to confusion. This change allows generic flags to be used on universal binaries with and without the `-macho` flag. This means flags that can be used for thin files can be used consistently with fat files too. To do this, the universal binary support within `ParseInputMachO()` is extracted into a new function. This new function is called directly from `DumpInput()` when the input binary is universal. Additionally the `-arch` flag validation in `ParseInputMachO()` was extracted to be reused. Reviewers: compnerd Reviewed By: compnerd Subscribers: keith, llvm-commits Differential Revision: https://reviews.llvm.org/D48702 llvm-svn: 338792
2018-07-25[llvm-objdump] Add dynamic section printing to private-headers optionPaul Semel1-0/+1
Differential Revision: https://reviews.llvm.org/D49016 llvm-svn: 337902
2018-07-18[llvm-objdump] Add -demangle (-C) optionPaul Semel1-0/+2
Differential Revision: https://reviews.llvm.org/D49043 llvm-svn: 337401
2018-07-11Revert "[llvm-objdump] Add -demangle (-C) option"Paul Semel1-2/+0
This reverts commit 3a44ccd156e0edd2e89226f8ed63928e227900bb. This reverts commit d5cfc836bb5552e20507d3612d13ff66ff9e36a0. llvm-svn: 336829
2018-07-11[llvm-objdump] Add -demangle (-C) optionPaul Semel1-0/+2
Differential Revision: https://reviews.llvm.org/D49043 llvm-svn: 336816
2018-07-04[llvm-objdump] Add --file-headers (-f) optionPaul Semel1-0/+1
llvm-svn: 336284
2018-06-27[llvm-objdump] Add -x --all-headers optionsFangrui Song1-0/+1
Reviewers: paulsemel, echristo Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48622 llvm-svn: 335785
2018-06-07[llvm-objdump] Add -R optionPaul Semel1-0/+2
This option prints dynamic relocation entries of the given file Differential Revision: https://reviews.llvm.org/D47493 llvm-svn: 334196
2017-03-20Add the rest of the error checking for Mach-O dyld compact bind entry errorsKevin Enderby1-8/+8
and test cases for each of the error checks. To do this more plumbing was needed so that the segment indexes and segment offsets can be checked. Basically what was done was the SegInfo from llvm-objdump’s MachODump.cpp was moved into libObject for Mach-O objects as BindRebaseSegInfo and it is only created when an iterator for bind or rebase entries are created. This commit really only adds the error checking and test cases for the bind table entires and the checking for the lazy bind and weak bind entries are still to be fully done as well as the rebase entires. Though some of the plumbing for those are added with this commit. Those other error checks and test cases will be added in follow on commits. Note, the two llvm_unreachable() calls should now actually be unreachable with the error checks in place and would take a logic bug in the error checking code to be reached if the segment indexes and segment offsets are used from a checked bind entry. Comments have been added to the methods that require the arguments to have been checked prior to calling. llvm-svn: 298292
2017-02-08llvm-objdump: make NoLeadingAddr work on more than just MachOSaleem Abdulrasool1-0/+1
Support printing the disassembly without the address on all formats rather than making it MachO specific. Patch by Jeff Muizelaar! llvm-svn: 294495
2016-11-30[WebAssembly] Add llvm-objdump support for wasm file formatDerek Schuff1-0/+1
This is the first part of an effort to add wasm binary support across all llvm tools. Patch by Sam Clegg Differential Revision: https://reviews.llvm.org/D26172 llvm-svn: 288251
2016-11-16General clean up of error handling in llvm-objdump to remove its use of ↵Kevin Enderby1-0/+1
report_fatal_error(). No real functional change with this commit. The problem with report_fatal_error() is it does not include the tool name and the file name the for which the error message was generated. Uses of report_fatal_error() were change to report_error() or error() to get a better error and to make the code smaller and cleaner. Also changed things like error(errorToErrorCode(SOrErr.takeError())) to use report_error() with a file name and the llvm::Error (as well as the ArchitectureName if available) so the error message is printed. llvm-svn: 287163
2016-08-18llvm-objdump: add coff import library symbol listing supportSaleem Abdulrasool1-0/+2
This adds behaviour similar to binutils' objdump which can show symbols in an import library. Differences from that stem around the fact that we do not create section symbols nor the all import import descriptor symbol reference. However, this does mean that the tool can serve as a possible replacement for the existing tool. llvm-svn: 279088
2016-06-28Finish cleaning up most of the error handling in libObject’s ↵Kevin Enderby1-0/+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-05-31Change llvm-objdump, llvm-nm and llvm-size when reporting an object file errorKevin Enderby1-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
2016-05-17Change llvm-objdump, llvm-nm and llvm-size when reporting an object file errorKevin Enderby1-1/+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
2016-04-18[NFC] Header cleanupMehdi Amini1-1/+2
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
2016-04-06Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump ↵Kevin Enderby1-0/+1
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
2016-01-26Re-submit r256008 "Improve DWARFDebugFrame::parse to also handle __eh_frame."Igor Laevsky1-0/+2
Originally this change was causing failures on windows buildbots. But those problems were fixed in r258806. llvm-svn: 258811
2016-01-13For llvm-objdump, add the option -private-header (without the trailing ’s’)Kevin Enderby1-0/+2
to only print the first private header. Which for Mach-O files only prints the Mach header and not the subsequent load commands. Which is used by scripts to match what the darwin otool(1) with the -h flag does without the -l flag. For non-Mach-O files it has the same functionality as -private-headers (with the trailing ’s’). rdar://24158331 llvm-svn: 257548
2015-12-29[llvm-objdump] Mark noreturn function as such.Davide Italiano1-1/+2
Match attribute in the header to make MSVC happy. llvm-svn: 256560
2015-12-20[llvm-objdump] Move COFF function to where it belongs.Davide Italiano1-0/+1
Ideally much more stuff should be moved out of llvm-objdump.cpp, but that will happen later. llvm-svn: 256118
2015-12-18Revert "Improve DWARFDebugFrame::parse to also handle __eh_frame."Pete Cooper1-2/+0
This reverts commit r256008. Its breaking multiple buildbots, although works for me locally. llvm-svn: 256013
2015-12-18Improve DWARFDebugFrame::parse to also handle __eh_frame.Pete Cooper1-0/+2
LLVM MC has single methods which can handle the output of EH frame and DWARF CIE's and FDE's. This code improves DWARFDebugFrame::parse to do the same for parsing. This also allows llvm-objdump to support the --dwarf=frames option which objdump supports. This option dumps the .eh_frame section using the new code in DWARFDebugFrame::parse. http://reviews.llvm.org/D15535 Reviewed by Rafael Espindola. llvm-svn: 256008
2015-12-08[llvm-objdump/MachO] Don't cut'n'paste the same code over and over.Davide Italiano1-0/+1
Use the appropriate helper instead. llvm-svn: 254990
2015-08-05[llvm-objdump] Call exit(1) on error, i.e. fail early.Davide Italiano1-1/+1
Previously we kept going on partly corrupted input, which might result in garbage being printed, or even worse, random crashes. Rafael mentioned that this is the GNU behavior as well, but after some discussion we both agreed it's probably better to emit a reasonable error message and exit. As a side-effect of this commit, now we don't rely on global state for error codes anymore. objdump was the last tool in the toolchain which needed to be converted. Hopefully the old behavior won't sneak into the tree again. llvm-svn: 244019
2015-07-29[llvm-objdump] Merging MachO DumpSections in to FilterSections. Simplifying ↵Colin LeMahieu1-2/+1
some predicate logic. llvm-svn: 243556
2015-07-29[llvm-objdump] Added -j flag to filter sections that are operated on.Colin LeMahieu1-1/+2
llvm-svn: 243526
2015-07-23[llvm-objdump] Add -D and --disassemble-all flags that attempt disassembly ↵Colin LeMahieu1-1/+2
on all sections instead of just text sections. llvm-svn: 243041
2015-07-08llvm-objdump: Replace the -macho -raw option with a generic -raw-clang-astAdrian Prantl1-1/+2
option that works with all object container formats. Now that clang modules/PCH are object containers this option is useful to to construct pipes like llvm-objdump -raw-clang-ast foo.pcm | llvm-bcanalyzer - to inspect the AST contents in a PCH container. Will be tested via clang. Belatedly addresses review feedback for r233390. llvm-svn: 241659
2015-06-07[objdump] Moving PrintImmHex out of MachODump and in to llvm-objdump and ↵Colin LeMahieu1-0/+1
setting instprinter appropriately. llvm-svn: 239265
2015-05-28[llvm] Parameterizing the output stream for dumpbytes and outputting ↵Colin LeMahieu1-1/+0
directly to stream. llvm-svn: 238453
2015-04-01Add the option -objc-meta-data to llvm-objdump used with -macho toKevin Enderby1-1/+1
print the Objective-C runtime meta data for Mach-O files. There are three types of Objective-C runtime meta data, Objc2 64-bit, Objc2 32-bit and Objc1 32-bit. This prints the first of these types. The changes to print the others will follow next. llvm-svn: 233840
2015-03-27Add a -raw option to the -section mode of llvm-objdump.Adrian Prantl1-0/+1
llvm-svn: 233390
2015-03-18[Objdump] DumpBytes of uint8_t from ArrayRef<uint8_t> instead of char from ↵Colin LeMahieu1-1/+1
StringRef. Removing reinterpret_casts. llvm-svn: 232659
2015-03-17Add the option, -dis-symname to llvm-objdump used with -macho andKevin Enderby1-0/+1
-disassemble to disassemble just one symbol’s instructions. llvm-svn: 232503
2015-03-16Add the options, -dylibs-used and -dylib-id to llvm-objdump used with -machoKevin Enderby1-0/+2
to print the Mach-O dynamic shared libraries used by a linked image or the library id of a shared library. llvm-svn: 232406
2015-03-13Add the option, -non-verbose to llvm-objdump used with -macho to print thingsKevin Enderby1-0/+1
using numeric values and not their symbolic constant names. The routines that print Mach-O stuff already had a verbose parameter and this change is just changing the passing true to passing !NonVerbose. With just a couple of fixes and a bunch of test case updates. llvm-svn: 232182
2015-03-11Add the option, -info-plist to llvm-objdump used with -macho to print theKevin Enderby1-0/+1
Mach-O info plist section as strings. llvm-svn: 231974
2015-01-31Add the -section option to llvm-objdump used with -macho that takes the argumentKevin Enderby1-0/+1
segname,sectname to specify a Mach-O section to print. The printing is based on the section type or section attributes. The printing of the module initialization and termination section types is printed with this change. Printing of other section types will be added next. llvm-svn: 227649
2015-01-27dd the option, -link-opt-hints to llvm-objdump used with -macho to print theKevin Enderby1-0/+1
Mach-O AArch64 linker optimization hints for ADRP code optimization. llvm-svn: 227246