aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
AgeCommit message (Collapse)AuthorFilesLines
2018-08-08[ADT] Normalize empty triple componentsPetr Hosek1-1/+0
LLVM triple normalization is handling "unknown" and empty components differently; for example given "x86_64-unknown-linux-gnu" and "x86_64-linux-gnu" which should be equivalent, triple normalization returns "x86_64-unknown-linux-gnu" and "x86_64--linux-gnu". autoconf's config.sub returns "x86_64-unknown-linux-gnu" for both "x86_64-linux-gnu" and "x86_64-unknown-linux-gnu". This changes the triple normalization to behave the same way, replacing empty triple components with "unknown". This addresses PR37129. Differential Revision: https://reviews.llvm.org/D50219 llvm-svn: 339294
2018-08-03objdump: Better handling of Mach-O universal binariesDave Lee1-0/+3
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-26[ADT] Replace std::isprint by llvm::isPrint.Michael Kruse1-2/+2
The standard library functions ::isprint/std::isprint have platform- and locale-dependent behavior which makes LLVM's output less predictable. In particular, regression tests my fail depending on the implementation of these functions. Implement llvm::isPrint in StringExtras.h with a standard behavior and replace all uses of ::isprint/std::isprint by a call it llvm::isPrint. The function is inlined and does not look up language settings so it should perform better than the standard library's version. Such a replacement has already been done for isdigit, isalpha, isxdigit in r314883. gtest does the same in gtest-printers.cc using the following justification: // Returns true if c is a printable ASCII character. We test the // value of c directly instead of calling isprint(), which is buggy on // Windows Mobile. inline bool IsPrintableAscii(wchar_t c) { return 0x20 <= c && c <= 0x7E; } Similar issues have also been encountered by Julia: https://github.com/JuliaLang/julia/issues/7416 I noticed the problem myself when on Windows isprint('\t') started to evaluate to true (see https://stackoverflow.com/questions/51435249) and thus caused several unit tests to fail. The result of isprint doesn't seem to be well-defined even for ASCII characters. Therefore I suggest to replace isprint by a platform-independent version. Differential Revision: https://reviews.llvm.org/D49680 llvm-svn: 338034
2018-07-25[llvm-objdump] Add dynamic section printing to private-headers optionPaul Semel1-2/+4
Differential Revision: https://reviews.llvm.org/D49016 llvm-svn: 337902
2018-07-18[llvm-objdump] Add -demangle (-C) optionPaul Semel1-1/+37
Differential Revision: https://reviews.llvm.org/D49043 llvm-svn: 337401
2018-07-18[llvm-objdump] - An attempt to fix BB after r337361.George Rimar1-2/+2
Seems r337361 is the reason of the following ARM BB failures: http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick http://lab.llvm.org:8011/builders/clang-cmake-armv8-full/builds/4633 Reason is unclear to me, other bots are OK. If this will not help, I'll revert r337361. llvm-svn: 337371
2018-07-18[llvm-objdump] - Stop reporting bogus section IDs.George Rimar1-4/+3
Imagine we have a file with few sections, and one of them is .foo with index N != 0. Problem is that when llvm-objdump is given a -section=.foo parameter it lists .foo as a section at index 0. That makes impossible to write test cases which needs to find the index of the particular section, while ignoring dumping of others. The patch fixes that. Differential revision: https://reviews.llvm.org/D49372 llvm-svn: 337361
2018-07-11Revert "[llvm-objdump] Add -demangle (-C) option"Paul Semel1-37/+1
This reverts commit 3a44ccd156e0edd2e89226f8ed63928e227900bb. This reverts commit d5cfc836bb5552e20507d3612d13ff66ff9e36a0. llvm-svn: 336829
2018-07-11[llvm-objdump] Add -demangle (-C) optionPaul Semel1-1/+37
Differential Revision: https://reviews.llvm.org/D49043 llvm-svn: 336816
2018-07-05[llvm-objdump] Add --archive-headers (-a) optionPaul Semel1-5/+83
llvm-svn: 336357
2018-07-04[llvm-objdump] Add --file-headers (-f) optionPaul Semel1-0/+24
llvm-svn: 336284
2018-06-28Handle absolute symbols as branch targets in disassembly.Sterling Augustine1-21/+35
https://reviews.llvm.org/D48554 llvm-svn: 335903
2018-06-27[llvm-objdump] Add -x --all-headers optionsFangrui Song1-0/+9
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-17/+70
This option prints dynamic relocation entries of the given file Differential Revision: https://reviews.llvm.org/D47493 llvm-svn: 334196
2018-06-01Implemented sane default for llvm-objdump's relocation Value formatDaniel Cederman1-72/+10
Summary: "Unknown" for platforms that were not manually added into the switch did not make sense at all. Now it prints Target + addend for all elf-machines that were not explicitly mentioned. Addresses PR21059 and PR25124. Original author: fedor.sergeev Reviewers: jyknight, espindola, fedor.sergeev Reviewed By: jyknight Subscribers: eraman, dcederman, jfb, dschuff, aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D36464 llvm-svn: 333726
2018-05-14Hexagon: Put relocations after instructions not packets.Sid Manning1-290/+319
Change relocation output so that relocation information follows individual instructions rather than clustering them at the end of packets. This change required shifting block of code but the actual change is in HexagonPrettyPrinter's PrintInst. Differential Revision: https://reviews.llvm.org/D46728 llvm-svn: 332283
2018-05-01Remove @brief commands from doxygen comments, too.Adrian Prantl1-3/+3
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
2018-04-26[WebAssembly] objdump: Don't assume all relocations have symbolsSam Clegg1-2/+6
Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D46134 llvm-svn: 330959
2018-04-26[WebAssembly] Implement getRelocationValueString()Sam Clegg1-1/+9
And use it in llvm-objdump. Differential Revision: https://reviews.llvm.org/D46092 llvm-svn: 330957
2018-04-19[llvm-objdump] Print "..." instead of random data for virtual sectionsFrancis Visoiu Mistrih1-0/+7
When disassembling with -D, skip virtual sections by printing "..." for each symbol. This patch also implements `MachOObjectFile::isSectionVirtual`. Test case comes from: ``` .zerofill __DATA,__common,_data64unsigned,472,3 ``` Differential Revision: https://reviews.llvm.org/D45824 llvm-svn: 330342
2018-04-13Define InitLLVM to do common initialization all at once.Rui Ueyama1-7/+2
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
2018-04-01[tools] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang1-3/+3
Summary: r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort. Refer the comments section in D44363 for a list of all the required patches. Reviewers: JDevlieghere, zturner, echristo, dberris, friss Reviewed By: echristo Subscribers: gbedwell, llvm-commits Differential Revision: https://reviews.llvm.org/D45141 llvm-svn: 328943
2018-03-26[AMDGPU] Improve disassembler error handlingTim Corringham1-16/+33
Summary: llvm-objdump now disassembles unrecognised opcodes as data, using the .long directive. We treat unrecognised opcodes as being 32 bit values, so move along 4 bytes rather than the single byte which previously resulted in a cascade of bogus disassembly following an unrecognised opcode. While no solution can always disassemble code that contains embedded data correctly this provides a significant improvement. The disassembler will now cope with an arbitrary length section as it no longer truncates it to a multiple of 4 bytes, and will use the .byte directive for trailing bytes. Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits Differential Revision: https://reviews.llvm.org/D44685 llvm-svn: 328553
2018-03-09[llvm-objdump] Support disassembling by symbol nameRafael Auler1-14/+30
Summary: Add a new option -df to llvm-objdump that takes function names as arguments and instructs the disassembler to only dump those function contents. Based on code originally written by Bill Nell. Reviewers: espindola, JDevlieghere Differential Revision: https://reviews.llvm.org/D44224 llvm-svn: 327164
2018-02-23[DebugInfo] Support DWARF v5 source code embedding extensionScott Linder1-10/+16
In DWARF v5 the Line Number Program Header is extensible, allowing values with new content types. In this extension a content type is added, DW_LNCT_LLVM_source, which contains the embedded source code of the file. Add new optional attribute for !DIFile IR metadata called source which contains source text. Use this to output the source to the DWARF line table of code objects. Analogously extend METADATA_FILE in Bitcode and .file directive in ASM to support optional source. Teach llvm-dwarfdump and llvm-objdump about the new values. Update the output format of llvm-dwarfdump to make room for the new attribute on file_names entries, and support embedded sources for the -source option in llvm-objdump. Differential Revision: https://reviews.llvm.org/D42765 llvm-svn: 325970
2018-02-02Fix typoAlex Denisov1-1/+1
llvm-svn: 324123
2017-12-28Avoid int to string conversion in Twine or raw_ostream contexts.Benjamin Kramer1-1/+1
Some output changes from uppercase hex to lowercase hex, no other functionality change intended. llvm-svn: 321526
2017-12-18Fix more inconsistent line endings. NFC.Dimitry Andric1-7/+7
llvm-svn: 321016
2017-11-03Fix a crash in llvm-objdump when printing a bad x86_64 relocation in a Mach-OKevin Enderby1-2/+13
file with a bad section number. rdar://35207539 llvm-svn: 317373
2017-11-03Add llvm::for_each as a range-based extensions to <algorithm> and make use ↵Aaron Ballman1-8/+7
of it in some cases where it is a more clear alternative to std::for_each. llvm-svn: 317356
2017-09-19Allow public Triple deduction from ObjectFiles.Vlad Tsyrklevich1-20/+2
Move logic that allows for Triple deduction from an ObjectFile object out of llvm-objdump.cpp into a public factory, found in the ObjectFile class. This should allow other tools in the future to use this logic without reimplementation. Patch by Mitch Phillips Differential Revision: https://reviews.llvm.org/D37719 llvm-svn: 313605
2017-09-18[dwarfdump] Make .eh_frame an alias for .debug_frameJonas Devlieghere1-2/+1
This patch makes the `.eh_frame` extension an alias for `.debug_frame`. Up till now it was only possible to dump the section using objdump, but not with dwarfdump. Since the two are essentially interchangeable, we dump whichever of the two is present. As a workaround, this patch also adds parsing for 3 currently unimplemented CFA instructions: `DW_CFA_def_cfa_expression`, `DW_CFA_expression`, and `DW_CFA_val_expression`. Because I lack the required knowledge, I just parse the fields without actually creating the instructions. Finally, this also fixes the typo in the `.debug_frame` section name which incorrectly contained a trailing `s`. Differential revision: https://reviews.llvm.org/D37852 llvm-svn: 313530
2017-09-12Remove unneccessary string copies from method invocations.Vlad Tsyrklevich1-6/+6
Summary: Change string parameter 'File' to be passed by const-reference to reduce copies. Patch by Mitch Phillips Reviewers: vlad.tsyrklevich Reviewed By: vlad.tsyrklevich Subscribers: Eugene.Zelenko, llvm-commits Differential Revision: https://reviews.llvm.org/D37652 llvm-svn: 312994
2017-09-11llvm-dwarfdump: Replace -debug-dump=sect option with individual options.Adrian Prantl1-1/+1
As discussed on llvm-dev in http://lists.llvm.org/pipermail/llvm-dev/2017-September/117301.html this changes the command line interface of llvm-dwarfdump to match the one used by the dwarfdump utility shipping on macOS. In addition to being shorter to type this format also has the advantage of allowing more than one section to be specified at the same time. In a nutshell, with this change $ llvm-dwarfdump --debug-dump=info $ llvm-dwarfdump --debug-dump=apple-objc becomes $ dwarfdump --debug-info --apple-objc Differential Revision: https://reviews.llvm.org/D37714 llvm-svn: 312970
2017-08-07[llvm-objdump] Use PRIx64 for output of ARM64_RELOC_ADDENDSimon Dardis1-1/+1
llvm-svn: 310250
2017-08-02Don't pass the code model to MCRafael Espindola1-1/+1
I was surprised to see the code model being passed to MC. After all, it assembles code, it doesn't create it. The one place it is used is in the expansion of .cfi directives to handle .eh_frame being more that 2gb away from the code. As far as I can tell, gnu assembler doesn't even have an option to enable this. Compiling a c file with gcc -mcmodel=large produces a regular looking .eh_frame. This is probably because in practice linker parse and recreate .eh_frames. In llvm this is used because the JIT can place the code and .eh_frame very far apart. Ideally we would fix the jit and delete this option. This is hard. Apart from confusion another problem with the current interface is that most callers pass CodeModel::Default, which is bad since MC has no way to map it to the target default if it actually needed to. This patch then replaces the argument with a boolean with a default value. The vast majority of users don't ever need to look at it. In fact, only CodeGen and llvm-mc use it and llvm-mc just to enable more testing. llvm-svn: 309884
2017-07-19Use delegation instead of inheritance.Rafael Espindola1-2/+2
This changes DwarfContext to delegate to DwarfObject instead of having pure virtual methods. With this DwarfContextInMemory is replaced with an implementation of DwarfObject that is local to a .cpp file. llvm-svn: 308543
2017-07-13[llvm-objdump] Properly print MachO aarch64 addend relocationsMartin Storsjo1-1/+4
Previously such relocations fell into the last case for local symbols, using the relocation addend as symbol index, leading to a crash. Differential Revision: https://reviews.llvm.org/D35239 llvm-svn: 307927
2017-07-13[llvm-objdump] Correctly distinguish between the MachO upper/lower16 relocationsMartin Storsjo1-1/+1
All other code in MachODump.cpp uses the same comparison, ((r_length & 0x1) == 1), for distinguishing between the two, while the code in llvm-objdump.cpp seemed to be incorrect. Differential Revision: https://reviews.llvm.org/D35240 llvm-svn: 307882
2017-06-27[WebAssembly] Add support for printing relocations with llvm-objdumpSam Clegg1-2/+18
Differential Revision: https://reviews.llvm.org/D34658 llvm-svn: 306461
2017-06-01[DWARF] Introduce Dump OptionsAdrian Prantl1-1/+4
This commit introduces a structure that holds all the flags that control the pretty printing of dwarf output. Patch by Spyridoula Gravani! Differential Revision: https://reviews.llvm.org/D33749 llvm-svn: 304446
2017-04-25[llvm-objdump] Don't attempt to print lines beyond the end of filePetr Hosek1-1/+4
This may trigger a segfault in llvm-objdump when the line number stored in debug infromation points beyond the end of file; lines in LineBuffer are stored in std::vector which is allocated in chunks, so even if the debug info points beyond the end of the file, this doesn't necessarily trigger the segfault unless the line number points beyond the allocated space. Differential Revision: https://reviews.llvm.org/D32466 llvm-svn: 301347
2017-03-20Add the rest of the error checking for Mach-O dyld compact bind entry errorsKevin Enderby1-9/+9
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-03-07llvm-objdump: handle line numbers and source options for amdgpu objectsKonstantin Zhuravlyov1-0/+3
Differential Revision: https://reviews.llvm.org/D30679 llvm-svn: 297193
2017-02-08llvm-objdump: make NoLeadingAddr work on more than just MachOSaleem Abdulrasool1-3/+8
Support printing the disassembly without the address on all formats rather than making it MachO specific. Patch by Jeff Muizelaar! llvm-svn: 294495
2017-02-08Use dynamic symbols for ELF disassemblySam Parker1-1/+50
Disassembly currently begins from addresses obtained from the objects symbol table. For ELF, add the dynamic symbols to the list if no static symbols are available so that we can more successfully disassemble stripped binaries. Differential Revision: https://reviews.llvm.org/D29632 llvm-svn: 294430
2017-01-18[ARM] Create objdump subtarget from build attrsSam Parker1-2/+19
Enable an ELFObjectFile to read the its arm build attributes to produce a target triple with a specific ARM architecture. llvm-objdump now uses this functionality to automatically produce a more accurate target. Differential Revision: https://reviews.llvm.org/D28769 llvm-svn: 292366
2017-01-13Revert r291903 and r291898. Reason: they break check-lld on the bots.Ivan Krasin1-19/+2
Summary: Revert [ARM] Fix ubig32_t read in ARMAttributeParser Now using support functions to read data instead of trying to perform casts. =========================================================== Revert [ARM] Enable objdump to construct triple for ARM Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Subscribers: llvm-commits, samparker, aemerson, mgorny Differential Revision: https://reviews.llvm.org/D28683 llvm-svn: 291911
2017-01-13[ARM] Enable objdump to construct triple for ARMSam Parker1-2/+19
Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Differential Revision: https://reviews.llvm.org/D28281 llvm-svn: 291898
2016-12-13[bpf] change llvm-objdump to print dec instead of hexAlexei Starovoitov1-0/+23
since bpf instruction stream is multiple of 8 change llvm-objdump to print decimal instruction number instead of hex address, so that users don't have to do this math manually to match kernel verifier output Signed-off-by: Alexei Starovoitov <ast@kernel.org> llvm-svn: 289569