aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-01-13For llvm-objdump, add the option -private-header (without the trailing ’s’)Kevin Enderby1-2/+22
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
2016-01-12[WebAssembly] Add a EM_WEBASSEMBLY value, and several bits of code that use it.Dan Gohman1-0/+17
A request has been made to the official registry, but an official value is not yet available. This patch uses a temporary value in order to support development. When an official value is recieved, the value of EM_WEBASSEMBLY will be updated. llvm-svn: 257517
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-25[llvm-objdump] Use stderr and not stdout for fatal errors.Davide Italiano1-2/+2
llvm-svn: 256423
2015-12-20[llvm-objdump] Move COFF function to where it belongs.Davide Italiano1-50/+1
Ideally much more stuff should be moved out of llvm-objdump.cpp, but that will happen later. llvm-svn: 256118
2015-12-19[llvm-objdump] Fail early if we can't parse the object header.Davide Italiano1-4/+5
llvm-svn: 256108
2015-12-18Revert "Improve DWARFDebugFrame::parse to also handle __eh_frame."Pete Cooper1-13/+1
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-1/+13
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-17[llvm-objdump] Use report_fatal_error() for a more uniform error handling.Davide Italiano1-29/+13
llvm-svn: 255871
2015-12-08[llvm-objdump/MachO] Don't cut'n'paste the same code over and over.Davide Italiano1-1/+1
Use the appropriate helper instead. llvm-svn: 254990
2015-12-03[llvm-objdump] Use report_fatal_error() if we can't find a target.Davide Italiano1-8/+2
llvm-svn: 254654
2015-11-18Fix LLD testsuite fallout from r253429David Majnemer1-4/+4
llvm-svn: 253432
2015-11-18[llvm-objdump] Use the COFF export table for additional symbolsDavid Majnemer1-57/+118
Most linked executables do not have a symbol table in COFF. However, it is pretty typical to have some export entries. Use those entries to inform the disassembler about potential function definitions and call targets. llvm-svn: 253429
2015-11-05Reapply r250906 with many suggested updates from Rafael Espindola.Kevin Enderby1-1/+4
The needed lld matching changes to be submitted immediately next, but this revision will cause lld failures with this alone which is expected. This removes the eating of the error in Archive::Child::getSize() when the characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. These changes will require corresponding changes to the lld project. That will be committed immediately after this change. But this revision will cause lld failures with this alone which is expected. llvm-svn: 252192
2015-11-04[ELF] elfiamcu triple should imply e_machine == EM_IAMCUMichael Kuperstein1-0/+1
Differential Revision: http://reviews.llvm.org/D14109 llvm-svn: 252043
2015-10-21Backing out commit r250906 as it broke lld.Kevin Enderby1-6/+1
llvm-svn: 250908
2015-10-21This removes the eating of the error in Archive::Child::getSize() when the ↵Kevin Enderby1-1/+6
characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. Also corrected the code where the size gets us to the “at the end of the archive” which is OK but past the end of the archive will return object_error::parse_failed now. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. llvm-svn: 250906
2015-10-07Stop linking all target libraries in llvm-nm and llvm-objdump.Pete Cooper1-1/+0
llvm-nm only needs the target to parse module level assembly in bitcode. It doesn't need a disassembler or codegen. llvm-objdump needs to be able to disassemble a file, but doesn't need asm parsers or codegen. This reduces the sizes of these tools by a few MB each, depending on how many backends are linked in. llvm-svn: 249632
2015-10-01[PATCH] D13360: [llvm-objdump] Teach -d about AArch64 mapping symbolsDavide Italiano1-0/+49
AArch64 uses $d* and $x* to interleave between text and data. llvm-objdump didn't know about this so it ended up printing garbage. This patch is a first step towards a solution of the problem. Differential Revision: http://reviews.llvm.org/D13360 llvm-svn: 249083
2015-10-01[llvm-objdump] Fix time of check to time of use bug.Davide Italiano1-3/+0
There's already a test that covers this situation, so we should be fine. llvm-svn: 248976
2015-09-24[objdump] Make iterator operator* return a reference.Benjamin Kramer1-1/+1
This is closer to the expected behavior of an iterator and avoids awkward warnings from clang's -Wrange-loop-analysis below. llvm-svn: 248497
2015-09-15Revert r247692: Replace Triple with a new TargetTuple in MCTargetDesc/* and ↵Daniel Sanders1-3/+2
related. NFC. Eric has replied and has demanded the patch be reverted. llvm-svn: 247702
2015-09-15Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* ↵Daniel Sanders1-2/+3
and related. NFC. Summary: This is the first patch in the series to migrate Triple's (which are ambiguous) to TargetTuple's (which aren't). For the moment, TargetTuple simply passes all requests to the Triple object it holds. Once it has replaced Triple, it will start to implement the interface in a more suitable way. This change makes some changes to the public C++ API. In particular, InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer() now take TargetTuples instead of Triples. The other public C++ API's have been left as-is for the moment to reduce patch size. This commit also contains a trivial patch to clang to account for the C++ API change. Thanks go to Pavel Labath for fixing LLDB for me. Reviewers: rengolin Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D10969 llvm-svn: 247692
2015-09-15Revert r247684 - Replace Triple with a new TargetTuple ...Daniel Sanders1-3/+2
LLDB needs to be updated in the same commit. llvm-svn: 247686
2015-09-15Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.Daniel Sanders1-2/+3
Summary: This is the first patch in the series to migrate Triple's (which are ambiguous) to TargetTuple's (which aren't). For the moment, TargetTuple simply passes all requests to the Triple object it holds. Once it has replaced Triple, it will start to implement the interface in a more suitable way. This change makes some changes to the public C++ API. In particular, InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer() now take TargetTuples instead of Triples. The other public C++ API's have been left as-is for the moment to reduce patch size. This commit also contains a trivial patch to clang to account for the C++ API change. Reviewers: rengolin Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D10969 llvm-svn: 247683
2015-08-10Use higher level functions in llvm-objdump.Rafael Espindola1-17/+12
This matches the rest of llvm-objdump better and isolates it from upcoming changes to ELFFile. llvm-svn: 244500
2015-08-07Convert getSymbolSection to return an ErrorOr.Rafael Espindola1-2/+3
This function can actually fail since the symbol contains an index to the section and that can be invalid. llvm-svn: 244375
2015-08-06[llvm-objdump] Add missing call to exit(1).Davide Italiano1-0/+1
Reported by: Rafael Espindola. llvm-svn: 244184
2015-08-05[llvm-objdump] Call exit(1) on error, i.e. fail early.Davide Italiano1-69/+31
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-08-03[llvm-objdump] Range-loopify. NFC intended.Davide Italiano1-3/+2
llvm-svn: 243905
2015-07-29[llvm-objdump] Inverting logic to match the word "predicate". Returning ↵Colin LeMahieu1-4/+4
true when we want it rather than when we want to discard it. llvm-svn: 243558
2015-07-29[llvm-objdump] Merging MachO DumpSections in to FilterSections. Simplifying ↵Colin LeMahieu1-14/+15
some predicate logic. llvm-svn: 243556
2015-07-29[llvm-objdump] Added -j flag to filter sections that are operated on.Colin LeMahieu1-15/+86
llvm-svn: 243526
2015-07-23[llvm-objdump] Add -D and --disassemble-all flags that attempt disassembly ↵Colin LeMahieu1-2/+11
on all sections instead of just text sections. llvm-svn: 243041
2015-07-10Add missing 'const'. I don't think this is strictly required, but someDaniel Jasper1-1/+1
compiler configuration is giving me an error and it seems to be recommended anyway. llvm-svn: 241892
2015-07-09[llvm-objdump] Require that jump targets shown in -d are functionsDavid Majnemer1-6/+17
Don't let the disassembler pick call <.text> if a function happens to live at the start of the section by only using function symbols. llvm-svn: 241830
2015-07-08llvm-objdump: Replace the -macho -raw option with a generic -raw-clang-astAdrian Prantl1-3/+50
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-07-07[llvm-objdump] Print the call target next to the instructionDavid Majnemer1-0/+36
GNU binutils provides this behavior. objdump -r doesn't really help when you aren't dealing with relocation object files. llvm-svn: 241631
2015-07-07Delete UnknownAddress. It is a perfectly valid symbol value.Rafael Espindola1-7/+0
getSymbolValue now returns a value that in convenient for most callers: * 0 for undefined * symbol size for common symbols * offset/address for symbols the rest Code that needs something more specific can check getSymbolFlags. llvm-svn: 241605
2015-07-06Simplify. NFC.Rafael Espindola1-3/+1
llvm-svn: 241456
2015-07-03Return ErrorOr from getSymbolAddress.Rafael Espindola1-10/+11
It can fail trying to get the section on ELF and COFF. This makes sure the error is handled. llvm-svn: 241366
2015-07-02Return ErrorOr from SymbolRef::getName.Rafael Espindola1-12/+18
This function can really fail since the string table offset can be out of bounds. Using ErrorOr makes sure the error is checked. Hopefully a lot of the boilerplate code in tools/* can go away once we have a diagnostic manager in Object. llvm-svn: 241297
2015-07-02Expose getRel and getRela to reduce code duplication.Rafael Espindola1-19/+10
llvm-svn: 241266
2015-07-01Return ErrorOr from getSection.Rafael Espindola1-8/+18
This also improves the logic of what is an error: * getSection(uint_32): only return an error if the index is out of bounds. The index 0 corresponds to a perfectly valid entry. * getSection(Elf_Sym): Returns null for symbols that normally don't have sections and error for out of bound indexes. In many places this just moves the report_fatal_error up the stack, but those can then be fixed in smaller patches. llvm-svn: 241156
2015-06-30Don't return error_code from a function that doesn't fail.Rafael Espindola1-3/+2
llvm-svn: 241042
2015-06-30Move function to the only file that uses it.Rafael Espindola1-2/+35
llvm-svn: 241040
2015-06-30Don't return error_code from a function that doesn't fail.Rafael Espindola1-5/+2
llvm-svn: 241039
2015-06-29Don't return error_code from function that never fails.Rafael Espindola1-8/+4
llvm-svn: 241021
2015-06-29Convert obj->getSymbolName to sym->getName.Rafael Espindola1-1/+1
I doesn't depend on the object anymore. llvm-svn: 240996
2015-06-29Factor out the checking of string tables.Rafael Espindola1-1/+5
This moves the error checking for string tables to getStringTable which returns an ErrorOr<StringRef>. This improves error checking, makes it uniform across all string tables and makes it possible to check them once instead of once per name. llvm-svn: 240950