aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump
AgeCommit message (Collapse)AuthorFilesLines
2016-11-30[WebAssembly] Add llvm-objdump support for wasm file formatDerek Schuff4-0/+32
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-29Add to llvm-objdump the -no-leading-headers option with the use of the ↵Kevin Enderby1-6/+11
-macho option. In some cases the leading headers of the file name, archive member and architecture slice name in the output of lvm-objdump is not wanted so the tool’s output can be directly used by scripts. This matches the -X option of the Apple otool(1) program. rdar://28491674 llvm-svn: 288199
2016-11-20Fix spelling mistakes in Tools/Tests comments. NFC.Simon Pilgrim1-1/+1
Identified by Pedro Giffuni in PR27636. llvm-svn: 287489
2016-11-16General clean up of error handling in llvm-objdump to remove its use of ↵Kevin Enderby2-40/+54
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-11-16[ELF] Convert ELF.h to Expected<T>.Davide Italiano2-17/+18
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-15General clean up of Mach-O error handling in llvm-objdump.Kevin Enderby1-173/+72
To get a good error message for all files that could contain Mach-O files the code in llvm-objdump needs to use the archive member name and name of the architecture of a slice of a universal file in those cases where the error come from a Mach-O file in an archive or a universal file. Most of this is fixed by moving the call to checkSymbolTable() into ProcessMachO() and calling it when the operation needs the symbol table. And then calling the form of report_error() that has the ArchiveName and ArchitectureName arguments. One other place needed to call this form of report_error() also with these arguments. Also changed the code in MachODump.cpp to not use report_fatal_error() and use report_error() instead to make the code smaller and cleaner. All cases of this are for errors with the symbol table which should now never be tripped since checkSymbolTable() should be called first to get a good error message in these cases. llvm-svn: 287050
2016-11-15llvm-objdump: deal with unexpected object files more gracefully.Tim Northover1-8/+18
Specifically, we don't want to segfault on release builds, so print the problem instead. llvm-svn: 287022
2016-11-14Add a checkSymbolTable() method to the MachOObjectFile class.Kevin Enderby1-0/+3
The philosophy of the error checking in libObject for Mach-O files is that the constructor will check the load commands so for their tables the offsets and sizes are properly contained in the file. But there is no checking of the entries of any of the tables. For the contents of the tables themselves the methods accessing the contents of the entries return errors as needed. In some cases this however makes it difficult or cumbersome to produce a good error message which would include the tool name, file name, archive member, and name of the architecture of a slice of a universal file the error occurred in. So idea is that there will be a method to check a table which can be called up front before using it allowing a good error message to be produced before a table is used. And if only verification of the Mach-O file and its tables are wanted a new possible method checkAllTables() could be added to call all of the methods to check all the tables at some time when such methods exist. The checkSymbolTable() is the first of such methods to check one of the Mach-O file tables. This method initially will used in llvm-objdump’s DisassembleMachO() routine before it gets the section and symbol information. As if there are problems with the symbol table currently the error is first encountered by the bool operator() in the SymbolSorter() struct which passed to std::sort(). In this case there is no context as to the file name the symbol which results a poor error message: LLVM ERROR: truncated or malformed object (bad string index: 22 for symbol at index 1) with the added call to the checkSymbolTable() method the error message includes the tool name and file name: llvm-objdump: 'macho-invalid-symbol-strx': truncated or malformed object (bad string table index: 22 past the end of string table, for symbol at index 1) llvm-svn: 286887
2016-11-11Make the Error class constructor protectedMehdi Amini2-6/+7
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-04Remove dead code trying to handle when the amount of data read isChandler Carruth1-12/+2
insufficient to populate the expected struct. Prior to this we already bailed out of the routine when this situation comes up, so none of this code had any effect. If someone wants to bring it back to handle these cases, fixing the earlier conditions and adding the necessary test cases that actually exercises it, they can always revert this and go from there. Both of these were noticed by PVS-Studio due to the identical (dead) condition. llvm-svn: 285989
2016-11-03Add support for the ARM_THREAD_STATE64 andKevin Enderby1-0/+84
in llvm-objdump for Mach-O files add the printing of the ARM_THREAD_STATE64 in the same format as otool-classic(1) on darwin. To do this the 64-bit ARM general tread state needed to be defined in include/llvm/Support/MachO.h . rdar://28985800 llvm-svn: 285967
2016-11-03Replace a report_fatal_error with an ErrorOr.Rafael Espindola1-1/+4
llvm-svn: 285942
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-31Fix an unconditional break in checkMachOAndArchFlagsDavid Majnemer1-24/+20
Found by PVS-Studio. llvm-svn: 285598
2016-10-26llvm-objdump: Make some error messages more consistentJustin Bogner1-2/+2
Most of the version of report_error were quoting the filename and printing a colon between the file name and the error message, but this one wasn't doing either of those. Fix the output to be more consistent. llvm-svn: 285252
2016-10-21For llvm-objdump for Mach-O files add printing ofKevin Enderby1-2/+69
the ARM_THREAD_STATE in the same format as otool-classic(1) on darwin. Also remove an extra space in printing the initprot to make the output match otool-classic(1) on darwin. rdar://28851457 llvm-svn: 284852
2016-10-08Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini1-2/+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-06[AMDGPU] Disassembler: print label names in branch instructionsSam Kolton1-2/+16
Summary: Add AMDGPUSymbolizer for finding names for labels from ELF symbol table. Initialize MCObjectFileInfo with some default values. Reviewers: vpykhtin, artem.tamazov, tstellarAMD Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, tony-tye Differential Revision: https://reviews.llvm.org/D24802 llvm-svn: 283450
2016-10-01Use StringRef instead of raw pointers in MCAsmInfo/MCInstrInfo APIs (NFC)Mehdi Amini1-1/+1
llvm-svn: 283018
2016-09-30[llvm-objdump] Switch to a range loop. NFCI.Davide Italiano1-5/+3
llvm-svn: 282982
2016-09-28[AVR] Allow llvm-objdump to handle AVR ELF filesDylan McKay1-0/+1
llvm-svn: 282585
2016-09-26Revert "[AMDGPU] Disassembler: print label names in branch instructions"Sam Kolton1-12/+0
This reverts commit 6c6dbe625263ec9fcf8de0df27263cf147cde550. llvm-svn: 282396
2016-09-26[AMDGPU] Disassembler: print label names in branch instructionsSam Kolton1-0/+12
Summary: Add AMDGPUSymbolizer for finding names for labels from ELF symbol table. Reviewers: vpykhtin, artem.tamazov, tstellarAMD Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, tony-tye Differential Revision: https://reviews.llvm.org/D24802 llvm-svn: 282394
2016-09-18[llvm-objump] Simplify the code. NFCI.Davide Italiano1-23/+12
llvm-svn: 281844
2016-09-12llvm-objdump: Add --start-address and --stop-address optionsHemant Kulkarni1-4/+41
Differential Revision: https://reviews.llvm.org/D24160 llvm-svn: 281232
2016-09-08llvm-objdump: add missing ) in help output, NFCSaleem Abdulrasool1-1/+1
Add a missing ')' in the help output. NFC. llvm-svn: 281000
2016-09-06Add an c++ itanium demangler to llvm.Rafael Espindola3-17/+7
This adds a copy of the demangler in libcxxabi. The code also has no dependencies on anything else in LLVM. To enforce that I added it as another library. That way a BUILD_SHARED_LIBS will fail if anyone adds an use of StringRef for example. The no llvm dependency combined with the fact that this has to build on linux, OS X and Windows required a few changes to the code. In particular: No constexpr. No alignas On OS X at least this library has only one global symbol: __ZN4llvm16itanium_demangleEPKcPcPmPi My current plan is: Commit something like this Change lld to use it Change lldb to use it as the fallback Add a few #ifdefs so that exactly the same file can be used in libcxxabi to export abi::__cxa_demangle. Once the fast demangler in lldb can handle any names this implementation can be replaced with it and we will have the one true demangler. llvm-svn: 280732
2016-08-25llvm-objdump: ELF: Handle code and data mix in all scenariosHemant Kulkarni1-11/+94
Differential Revision: https://reviews.llvm.org/D23621 llvm-svn: 279770
2016-08-18llvm-objdump: Add Hexagon printer changes for -S/-l optionsHemant Kulkarni1-0/+4
Differential Revision: https://reviews.llvm.org/D23521 llvm-svn: 279161
2016-08-18llvm-objdump: add coff import library symbol listing supportSaleem Abdulrasool3-0/+43
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-08-17[AMDGPU] llvm-objdump: Skip amd_kernel_code_t only at the begining of kernel ↵Sam Kolton1-20/+47
symbol. Summary: This change fix bug in AMDGPU disassembly. Previously, presence of symbols other than kernel symbols caused objdump to skip begining of those symbols. Reviewers: tstellarAMD, vpykhtin, Bigcheese, ruiu Subscribers: kzhuravl, arsenm Differential Revision: http://reviews.llvm.org/D21966 llvm-svn: 278921
2016-08-15llvm-objdump: Implement source[line numbers] interleavingHemant Kulkarni2-15/+113
Differential Revsion: https://reviews.llvm.org/D22932 llvm-svn: 278725
2016-08-12Use the range variant of find/find_if instead of unpacking begin/endDavid Majnemer2-15/+14
If the result of the find is only used to compare against end(), just use is_contained instead. No functionality change is intended. llvm-svn: 278469
2016-08-12Use the range variant of find_if instead of unpacking begin/endDavid Majnemer1-15/+11
No functionality change is intended. llvm-svn: 278443
2016-08-03Reapply "More fixes to get good error messages for bad archives."Vedant Kumar1-4/+14
This reverts commit the revert commit r277627. The build errors mentioned in r277627 were likely caused by an unclean build directory. Sorry for the noise. llvm-svn: 277630
2016-08-03Revert "More fixes to get good error messages for bad archives."Vedant Kumar1-14/+4
This reverts commit r277540. It breaks the build with: ../lib/Object/Archive.cpp:264:41: error: return type of out-of-line definition of 'llvm::object::ArchiveMemberHeader::getUID' differs from that in the declaration Expected<unsigned> ArchiveMemberHeader::getUID() const { ~~~~~~~~~~~~~~~~~~ ^ include/llvm/Object/Archive.h:53:12: note: previous declaration is here unsigned getUID() const; ~~~~~~~~ ^ llvm-svn: 277627
2016-08-02More fixes to get good error messages for bad archives.Kevin Enderby1-4/+14
Fixed the last incorrect uses of llvm_unreachable() in the code which were actually just cases of errors in the input Archives. llvm-svn: 277540
2016-07-31[COFF] Remove a duplicate import_directory_table_entry definitionDavid Majnemer1-1/+1
We had import_directory_table_entry and coff_import_directory_table_entry, remove one. Also, factor out the logic which determins if a descriptor is a terminator. llvm-svn: 277296
2016-07-29The next step along the way to getting good error messages for bad archives.Kevin Enderby2-7/+15
As mentioned in commit log for r276686 this next step is adding a new method in the ArchiveMemberHeader class to get the full name that does proper error checking, and can be use for error messages. To do this the name of ArchiveMemberHeader::getName() is changed to ArchiveMemberHeader::getRawName() to be consistent with Archive::Child::getRawName(). Then the “new” method is the addition of a new implementation of ArchiveMemberHeader::getName() which gets the full name and provides proper error checking. Which is mostly a rewrite of what was Archive::Child::getName() and cleaning up incorrect uses of llvm_unreachable() in the code which were actually just cases of errors in the input Archives. Then Archive::Child::getName() is changed to return Expected<> and use the new implementation of ArchiveMemberHeader::getName() . Also needed to change Archive::getMemoryBufferRef() with these changes to return Expected<> as well to propagate Errors up. As well as changing Archive::isThinMember() to return Expected<> . llvm-svn: 277177
2016-07-19Next step along the way to getting good error messages for bad archives.Kevin Enderby1-12/+20
This step builds on Lang Hames work to change Archive::child_iterator for better interoperation with Error/Expected. Building on that it is now possible to return an error message when the size field of an archive contains non-decimal characters. llvm-svn: 276025
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-14llvm-objdump: extend __mh_execute_header handling to other special symsTim Northover1-5/+7
We don't need to print any of the special __mh_*_header symbols when disassembling. Since they point at the beginning of the segment (not where the actual code is) they're pretty misleading. Should also fix lld bots. llvm-svn: 275498
2016-07-14llvm-objdump: handle stubbed and malformed dylibs betterTim Northover1-2/+12
We were quite happy to read past the end of the valid section data when disassembling. Instead we entirely skip stub dylibs, and tell the user what's happened if their section only has partial data. llvm-svn: 275487
2016-07-14[Object] Re-apply r275316 now that I have the corresponding LLD patch ready.Lang Hames2-32/+24
llvm-svn: 275361
2016-07-14[Object] Revert r275316, Archive::child_iterator changes, while I update lld.Lang Hames2-24/+32
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 Hames2-32/+24
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 Enderby3-3/+26
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-26[Object, COFF] An import data directory might not consist soley of importsDavid Majnemer1-10/+16
The last import is the penultimate entry, the last entry is nulled out. Data beyond the null entry should not be considered to hold import entries. This fixes PR28302. N.B. I am working on a reduced testcase, the one in PR28302 is too large. llvm-svn: 273790
2016-06-24Thread Expected<...> up from libObject’s getSymbolAddress() for symbols to ↵Kevin Enderby2-10/+16
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-21Update llvm-obdump(1) to print FAT_MAGIC_64 for Darwin’s 64-bit universal ↵Kevin Enderby1-3/+6
files with the -macho and -universal-headers flags. Just a follow on to r273207, I missed updating the printing of the fat magic number when the universal file is a 64-bit universal file. rdar://26899493 llvm-svn: 273324