aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.h
AgeCommit message (Collapse)AuthorFilesLines
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
2015-01-23Add the option, -data-in-code, to llvm-objdump used with -macho to print the ↵Kevin Enderby1-0/+1
Mach-O data in code table. llvm-svn: 226921
2015-01-22Add the option, -indirect-symbols, used with -macho to print the Mach-O ↵Kevin Enderby1-0/+1
indirect symbol table to llvm-objdump. llvm-svn: 226848
2015-01-20For llvm-objdump, hook up existing options to work when using -macho (the ↵Kevin Enderby1-0/+9
Mach-O parser). llvm-svn: 226612
2015-01-15Add the option, -archive-headers, used with -macho to print the Mach-O ↵Kevin Enderby1-0/+1
archive headers to llvm-objdump. llvm-svn: 226228
2015-01-09Add the option, -universal-headers, used with -macho to print the Mach-O ↵Kevin Enderby1-0/+1
universal headers to llvm-objdump. llvm-svn: 225537
2015-01-07Slightly refactor things for llvm-objdump and the -macho option so it can be ↵Kevin Enderby1-1/+13
used with options other than just -disassemble so that universal files can be used with other options combined with -arch options. No functional change to existing options and use. One test case added for the additional functionality with a universal file an a -arch option. llvm-svn: 225383
2014-11-12Remove the now unused StringRefMemoryObject.h.Rafael Espindola1-1/+0
llvm-svn: 221755
2014-09-24Flush out enough of llvm-objdump’s SymbolizerSymbolLookUp() for Mach-O ↵Kevin Enderby1-0/+1
files to get the literal string “Hello world” printed as a comment on the instruction that loads the pointer to it. For now this is just for x86_64. So for object files with relocation entries it produces things like: leaq L_.str(%rip), %rax ## literal pool for: "Hello world\n" and similar for fully linked images like executables: leaq 0x4f(%rip), %rax ## literal pool for: "Hello world\n" Also to allow testing against darwin’s otool(1), I hooked up the existing -no-show-raw-insn option to the Mach-O parser code, added the new Mach-O only -full-leading-addr option to match otool(1)'s printing of addresses and also added the new -print-imm-hex option. llvm-svn: 218423
2014-09-16[llvm-objdump] for mach-o add -bind, -lazy-bind, and -weak-bind optionsNick Kledzik1-0/+3
This finishes the ability of llvm-objdump to print out all information from the LC_DYLD_INFO load command. The -bind option prints out symbolic references that dyld must resolve immediately. The -lazy-bind option prints out symbolc reference that are lazily resolved on first use. The -weak-bind option prints out information about symbols which dyld must try to coalesce across images. llvm-svn: 217853
2014-09-12[llvm-objdump] support -rebase option for mach-o to dump rebasing infoNick Kledzik1-0/+1
Similar to my previous -exports-trie option, the -rebase option dumps info from the LC_DYLD_INFO load command. The rebasing info is a list of the the locations that dyld needs to adjust if a mach-o image is not loaded at its preferred address. Since ASLR is now the default, images almost never load at their preferred address, and thus need to be rebased by dyld. llvm-svn: 217709
2014-08-30Object/llvm-objdump: allow dumping of mach-o exports trieNick Kledzik1-1/+1
MachOObjectFile in lib/Object currently has no support for parsing the rebase, binding, and export information from the LC_DYLD_INFO load command in final linked mach-o images. This patch adds support for parsing the exports trie data structure. It also adds an option to llvm-objdump to dump that export info. I did the exports parsing first because it is the hardest. The information is encoded in a trie structure, but the standard ObjectFile way to inspect content is through iterators. So I needed to make an iterator that would do a non-recursive walk through the trie and maintain the concatenation of edges needed for the current string prefix. I plan to add similar support in MachOObjectFile and llvm-objdump to parse/display the rebasing and binding info too. llvm-svn: 216808
2014-08-22Add the start of the support for llvm-objdump’s -private-headers for ↵Kevin Enderby1-0/+1
Mach-O files. This adds the printing of the mach header. Load command printing will be next. llvm-svn: 216285
2014-08-13Canonicalize header guards into a common format.Benjamin Kramer1-2/+2
Add header guards to files that were missing guards. Remove #endif comments as they don't seem common in LLVM (we can easily add them back if we decide they're useful) Changes made by clang-tidy with minor tweaks. llvm-svn: 215558
2014-08-06Add the -mcpu= option to llvm-objdump for use with the disassemblers.Kevin Enderby1-0/+2
Also make the disassembler created with the Mach-O parser (the -m option) pick up the Target specific attributes specified with -mattr option. llvm-svn: 215032
2014-08-01llvm-objdump: implement printing for MachO __compact_unwind info.Tim Northover1-0/+3
llvm-svn: 214509
2014-06-13Remove all uses of 'using std::error_code' from headers.Rafael Espindola1-3/+1
llvm-svn: 210866
2014-06-12Don't use 'using std::error_code' in include/llvm.Rafael Espindola1-0/+1
This should make sure that most new uses use the std prefix. llvm-svn: 210835
2014-06-11Use std::error_code instead of llvm::error_code.Rafael Espindola1-1/+0
The idea of this patch is to turn llvm/Support/system_error.h into a transitional header that just brings in the erorr_code api to the llvm namespace. I will remove it shortly afterwards. The cases where the general idea needed some tweaking: * std::errc is a namespace in msvc, so we cannot use "using std::errc". I could add an #ifdef, but there were not that many uses, so I just added std:: to them in this patch. * Template specialization had to be moved to the std namespace in this patch set already. * The msvc implementation of default_error_condition doesn't seem to provide the same transformations as we need. Not too surprising since the standard doesn't actually say what "equivalent" means. I fixed the problem by keeping our old mapping and using it at error_code construction time. Despite these shortcomings I think this is still a good thing. Some reasons: * The different implementations of system_error might improve over time. * It removes 925 lines of code from llvm already. * It removes 6313 bytes from the text segment of the clang binary when it is built with gcc and 2816 bytes when building with clang and libstdc++. llvm-svn: 210687
2013-09-27Re-submit r191472 with a fix for big endian.Rui Ueyama1-1/+2
llvm-objdump: Dump COFF import table if -private-headers option is given. llvm-svn: 191557