aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-04-08[llvm-objdump] Fix MC/ARM/arm-macho-calls.sFangrui Song1-2/+1
llvm-svn: 357880
2019-04-07[llvm-objdump] Split disassembleObject and simplify --{start,stop}-address ↵Fangrui Song1-109/+116
handling The main disassembly loop is hard to read due to special handling of ARM ELF data & ELF data. Split off the logic into two functions dumpARMELFData and dumpELFData. Hoist some checks outside of the loop. --start-address --stop-address have redundant checks and minor off-by-1 issues. Fix them. llvm-svn: 357869
2019-04-07[llvm-objdump] Fix split of source lines; don't ltrim source linesFangrui Song1-20/+16
If the file does not end with a newline, it may be dropped. Fix the splitting algorithm. Also delete an unnecessary SourceCache lookup. llvm-svn: 357858
2019-04-07[llvm-objdump] Simplify Expected<T> handling with unwrapOrErrorFangrui Song1-98/+43
llvm-svn: 357855
2019-04-07[llvm-objdump] Simplify disassembleObjectFangrui Song1-79/+48
* Use std::binary_search to replace some std::lower_bound * Use llvm::upper_bound to replace some std::upper_bound * Use format_hex and support::endian::read{16,32} llvm-svn: 357853
2019-04-07Change some StringRef::data() reinterpret_cast to bytes_begin() or ↵Fangrui Song1-2/+1
arrayRefFromStringRef() llvm-svn: 357852
2019-03-28Fix typoed variable name.Eric Christopher1-4/+4
NFCI. llvm-svn: 357138
2019-03-21[llvm-objdump] Support arg grouping for -j and -M (e.g. llvm-objdump -sj.foo ↵Jordan Rupprecht1-2/+3
-dMreg-names-raw) Summary: r354375 added support for most objdump groupings, but didn't add support for -j|--sections, because that wasn't possible. r354870 added --disassembler options, but grouping still wasn't available. r355185 supported values for grouped options. This just puts the three of them together. This supports -j in modes like `-s -j .foo`, `-sj .foo`, `-sj=.foo`, or `-sj.foo`, and similar for `-M`. Reviewers: ormris, jhenderson, ikudrin Reviewed By: jhenderson, ikudrin Subscribers: javed.absar, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59618 llvm-svn: 356697
2019-02-27[DebugInfo] add SectionedAddress to DebugInfo interfaces.Alexey Lapshin1-23/+27
That patch is the fix for https://bugs.llvm.org/show_bug.cgi?id=40703 "wrong line number info for obj file compiled with -ffunction-sections" bug. The problem happened with only .o files. If object file contains several .text sections then line number information showed incorrectly. The reason for this is that DwarfLineTable could not detect section which corresponds to specified address(because address is the local to the section). And as the result it could not select proper sequence in the line table. The fix is to pass SectionIndex with the address. So that it would be possible to differentiate addresses from various sections. With this fix llvm-objdump shows correct line numbers for disassembled code. Differential review: https://reviews.llvm.org/D58194 llvm-svn: 354972
2019-02-26[llvm-objdump] Implement -Mreg-names-raw/-std options.Igor Kudrin1-0/+13
The --disassembler-options, or -M, are used to customize the disassembler and affect its output. The two implemented options allow selecting register names on ARM: * With -Mreg-names-raw, the disassembler uses rNN for all registers. * With -Mreg-names-std it prints sp, lr and pc for r13, r14 and r15, which is the default behavior of llvm-objdump. Differential Revision: https://reviews.llvm.org/D57680 llvm-svn: 354870
2019-02-25[llvm-objdump] Add `Version References` dumperXing GUO1-1/+3
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-02-19Revert "Revert "[llvm-objdump] Allow short options without arguments to be ↵Matthew Voss1-18/+26
grouped"" - Tests that use multiple short switches now test them grouped and ungrouped. - Ensure the output of ungrouped and grouped variants is identical Differential Revision: https://reviews.llvm.org/D57904 llvm-svn: 354375
2019-02-19[yaml2obj] - Do not skip zeroes blocks if there are relocations against them.George Rimar1-10/+16
This is for -D -reloc combination. With this patch, we do not skip the zero bytes that have a relocation against them when -reloc is used. If -reloc is not used, then the behavior will be the same. Differential revision: https://reviews.llvm.org/D58174 llvm-svn: 354319
2019-02-14Revert "[llvm-objdump] Allow short options without arguments to be grouped"Matthew Voss1-26/+18
Reverted due to failures on the llvm-hexagon-elf. This reverts commit 77e1f27476c89f65eeb496d131065177e6417f23. llvm-svn: 354002
2019-02-14[llvm-objdump] Allow short options without arguments to be groupedMatthew Voss1-18/+26
Summary: https://bugs.llvm.org/show_bug.cgi?id=31679 Reviewers: kristina, jhenderson, grimar, jakehehrlich, rupprecht Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57904 llvm-svn: 353998
2019-02-01[llvm-objdump] - llvm-objdump can skip bytes at the end of a section.Sid Manning1-1/+1
Differential Revision: https://reviews.llvm.org/D57549 llvm-svn: 352900
2019-01-31[ELF] Return the section name when calling getSymbolName on a section symbol.Matt Davis1-1/+4
Summary: Previously, llvm-nm would report symbols for .debug and .note sections as: '?' with an empty section name: ``` 00000000 ? 00000000 ? ... ``` With this patch the output more closely resembles GNU nm: ``` 00000000 N .debug_abbrev 00000000 n .note.GNU-stack ... ``` This patch calls `getSectionName` for sections that belong to symbols of type `ELF::STT_SECTION`, which returns the name of the section from the section string table. Reviewers: Bigcheese, davide, jhenderson Reviewed By: davide, jhenderson Subscribers: rupprecht, jhenderson, llvm-commits Differential Revision: https://reviews.llvm.org/D57105 llvm-svn: 352785
2019-01-28[llvm-objdump] - Restore a piece of code removed by mistake in r352366.George Rimar1-0/+3
Seems when committed the r352366 ("[llvm-objdump] - Print LMAs when dumping section headers.") I resolved merge conflict incorrectly and removed this piece by mistake. Bots did not catch this yet, seems they are slow today, but the `X86/adjust-vma.test` test case fails locally for me without that. llvm-svn: 352383
2019-01-28[llvm-objdump] - Print LMAs when dumping section headers.George Rimar1-9/+36
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-28[llvm-objdump] - Fix comment. NFC.George Rimar1-1/+1
This was mentioned by James Henderson in review for https://reviews.llvm.org/D57051. llvm-svn: 352348
2019-01-28[llvm-objdump] - Implement the --adjust-vma option.George Rimar1-4/+38
GNU objdump's help says: "--adjust-vma: Add OFFSET to all displayed section addresses" In real life what it does is a bit more complicated (and IMO not always reasonable. For example, GNU objdump prints not only VMA, but also LMA for sections. And with --adjust-vma it adjusts LMA, but only when a section has relocations. llvm-objsump does not seem to support printing LMAs yet, but GNU's logic anyways does not make sense for me here). This patch tries to adjust VMA. I tried to implement a reasonable approach. I am not adjusting sections that are not allocatable. As, for example, adjusting debug sections VA's and rel[a] sections VA's should not make sense. This behavior seems to be GNU compatible. Differential revision: https://reviews.llvm.org/D57051 llvm-svn: 352347
2019-01-23[llvm-objdump] - Move common code to a new printRelocation() helper. NFC.George Rimar1-23/+20
This extracts the common code for printing relocations into a new helper function. llvm-svn: 351951
2019-01-23[llvm-objdump] - Move variable. NFC.George Rimar1-4/+5
It was too far from the place where it is used. llvm-svn: 351942
2019-01-23[llvm-objdump] - Split disassembleObject() into two methods. NFCI.George Rimar1-60/+69
Currently, disassembleObject() is a ~550 lines length function. This patch splits it into two, where first do all helper objects initializations and calls the second which does all the rest job. This is a straightforward split. Differential revision: https://reviews.llvm.org/D57020 llvm-svn: 351940
2019-01-22[llvm-objdump] - Introduce getRelocsMap() helper. NFCI.George Rimar1-22/+21
Currently disassembleObject() is a ~550 lines length function. This patch extracts the code that creates a section->their relocation mapping into a new helper function to simplify/reduce it a bit. Differential revision: https://reviews.llvm.org/D57019 llvm-svn: 351824
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-18Revert r351529 "[llvm-objdump][NFC] Improve readability."Clement Courbet1-34/+29
msan errors in ELF/strip-all.s. llvm-svn: 351556
2019-01-18Reland r351529 "[llvm-objdump][NFC] Improve readability."Clement Courbet1-29/+34
`SectionSymbol*` is cast from `void*` to `std::tuple<uint64_t, StringRef, uint8_t>` in AMDGPUSymbolizer, so it has to *be* one, not *act like* one. llvm-svn: 351553
2019-01-18[llvm-objdump] - Dump the archive headers when -all-headers is specified.George Rimar1-2/+2
When -all-headers is given it is supposed to dump all headers, but now it skips the archive headers for no reason. The patch fixes that. Differential revision: https://reviews.llvm.org/D56780 llvm-svn: 351547
2019-01-18[llvm-objdump] - Move getRelocationValueString and dependenices out of the ↵George Rimar1-426/+5
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-18[llvm-objdump] - Show aliases in -help.George Rimar1-34/+35
Currently llvm-objdump is inconsistent. When -help is specified it shows no aliases except two. Aliases are shown with -help-hidden though. GNU objdump also prints them by default. This patch does a change to always show all aliases when -help is given. Differential revision: https://reviews.llvm.org/D56853 llvm-svn: 351542
2019-01-18Revert r351529 "[llvm-objdump][NFC] Improve readability."Clement Courbet1-37/+28
Breaks labels-branch.s llvm-svn: 351534
2019-01-18[llvm-objdump][NFC] Improve readability.Clement Courbet1-28/+37
Summary: Introduce a `struct SectionSymbol` instead of `tuple<uint64_t, StringRef, uint8>`. Reviewers: jhenderson, davide Subscribers: rupprecht, llvm-commits Differential Revision: https://reviews.llvm.org/D56858 llvm-svn: 351529
2019-01-17[WebAssembly] Fixed objdump not parsing function headers.Wouter van Oortmerssen1-0/+6
Summary: objdump was interpreting the function header containing the locals declaration as instructions. To parse these without injecting target specific code in objdump, MCDisassembler::onSymbolStart was added to be implemented by the WebAssembly implemention. WasmObjectFile now returns a code offset for the "address" of a symbol, rather than the index. This is also more in-line with what other targets do. Also ensured that the AsmParser correctly puts each function in its own segment to enable this test case. Reviewers: sbc100, dschuff Subscribers: jgravelle-google, aheejin, sunfish, rupprecht, llvm-commits Differential Revision: https://reviews.llvm.org/D56684 llvm-svn: 351460
2019-01-17Move demangling function from llvm-objdump to Demangle libraryJames Henderson1-15/+0
This allows it to be used in an upcoming llvm-readobj change. A small change in internal behaviour of the function is to always call the microsoftDemangle function if the string does not have an itanium encoding prefix, rather than only if it starts with '?'. This is harmless because the microsoftDemangle function does the same check already. Reviewed by: grimar, erik.pilkington Differential Revision: https://reviews.llvm.org/D56721 llvm-svn: 351448
2019-01-17[llvm-objdump] - Fix comment. NFC.George Rimar1-1/+1
Forgot to address this one. llvm-svn: 351418
2019-01-17[llvm-objdump] - Simplify the getRelocationValueString. NFCI.George Rimar1-38/+22
This refactors the getRelocationValueString method. It is a bit overcomplicated and it is possible to reduce it without losing the functionality it seems. Differential revision: https://reviews.llvm.org/D56778 llvm-svn: 351417
2019-01-15[llvm-obdump] - Fix the help lines for -stop-address and -z.George Rimar1-4/+4
It was broken by me by mistake in r350823 during addressing the review comment before committing (changed not the right text line). llvm-svn: 351192
2019-01-15[llvm-objdump] - Cleanup the code. NFCI.George Rimar1-278/+250
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
2019-01-12[llvm-objdump] - Change the output for --all-headers.George Rimar1-5/+5
This is for https://bugs.llvm.org/show_bug.cgi?id=40008, it starts printing the file headers when --all-headers is given and do a minor cosmetic change. Differential revision: https://reviews.llvm.org/D56588 llvm-svn: 351006
2019-01-10[llvm-objdump] - Do not include reserved undefined symbol in -t output.George Rimar1-1/+8
This is https://bugs.llvm.org/show_bug.cgi?id=26892, GNU objdump hides the special symbol entry: SYMBOL TABLE: 000000000000a7e0 l F .text 00000000000003f9 bi_copymodules while llvm-objdump does not: SYMBOL TABLE: 0000000000000000 *UND* 00000000 000000000000a7e0 l F .text 000003f9 bi_copymodules Patch makes the behavior of the llvm-objdump to be consistent with the GNU objdump. Differential revision: https://reviews.llvm.org/D56076 llvm-svn: 350840
2019-01-10[llvm-objdump] - Implement -z/--disassemble-zeroes.George Rimar1-1/+41
This is https://bugs.llvm.org/show_bug.cgi?id=37151, GNU objdump spec says that "Normally the disassembly output will skip blocks of zeroes.", but currently, llvm-objdump prints them. The patch implements the -z/--disassemble-zeroes option and switches the default to always skip blocks of zeroes. Differential revision: https://reviews.llvm.org/D56083 llvm-svn: 350823
2019-01-09[llvm-objdump] - Print symbol addressed when dumping disassembly output (-d)George Rimar1-0/+3
When GNU objdump dumps the input with -d it prints the symbol addresses, for example: 0000000000000031 <foo>: 31: 00 00 add %al,(%rax) ... llvm-objdump currently does not do that. Patch changes the behavior to match the GNU objdump. That is useful for implementing -z/--disassemble-zeroes (D56083), it allows omitting first zero bytes and keep the information about the symbol address in the output. Differential revision: https://reviews.llvm.org/D56123 llvm-svn: 350726
2018-12-20[binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0Jordan Rupprecht1-3/+3
llvm-svn: 349710
2018-12-19[llvm-objdump] - Fix one more BB.George Rimar1-1/+4
Should fix the http://lab.llvm.org:8011/builders/polly-amd64-linux/builds/25876/steps/build/logs/stdio: /home/grosser/buildslave/polly-amd64-linux/llvm.src/tools/llvm-objdump/llvm-objdump.cpp:539:25: error: conditional expression is ambiguous; 'std::string' (aka 'basic_string<char>') can be converted to 'typename std::remove_reference<StringRef>::type' (aka 'llvm::StringRef') and vice versa Target = Demangle ? demangle(*SymName) : *SymName; llvm-svn: 349617
2018-12-19[llvm-objdump] - Fix BB.George Rimar1-16/+15
Move the helper method before the first incocation in the file. llvm-svn: 349614
2018-12-19[llvm-objdump] - Demangle the symbols when printing symbol table and ↵George Rimar1-27/+28
relocations. This is https://bugs.llvm.org/show_bug.cgi?id=40009, llvm-objdump does not demangle the symbols when prints symbol table and/or relocations. Patch teaches it to do that. Differential revision: https://reviews.llvm.org/D55821 llvm-svn: 349613
2018-11-17[llvm-objdump] Print a blank row at the end of sectionsXing GUO1-0/+1
Summary: When using option `-x` (--all-headers), it will print `Sections`, `Symbol Table`, `Program Header` ... `Sections` and `Symbol Table` will be connected together. Before: ``` Sections: Idx Name Size Address Type 0 00000000 0000000000000000 ... 29 .shstrtab 0000011a 0000000000000000 SYMBOL TABLE: ... ``` After: ``` Sections: Idx Name Size Address Type 0 00000000 0000000000000000 ... 29 .shstrtab 0000011a 0000000000000000 SYMBOL TABLE: ... ``` Reviewers: Higuoxing Reviewed By: Higuoxing Subscribers: llvm-commits, jhenderson Differential Revision: https://reviews.llvm.org/D54665 llvm-svn: 347135
2018-11-11[llvm-objdump] Use WithColor for error reportingJonas Devlieghere1-27/+38
Use helpers from Support/WithError.h to print errors. llvm-svn: 346623
2018-11-11[llvm-objdump] Add symbol 'O' for object dataKristina Brooks1-0/+2
Improve compatibility with GNU objdump by showing `O` next to global symbol names, instead of a blank space. Patch by Higuoxing (Xing). Reviewers: MaskRay Differential Revision: https://reviews.llvm.org/D54380 llvm-svn: 346610