aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
AgeCommit message (Collapse)AuthorFilesLines
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
2018-11-11[Support] Make error banner optional in logAllUnhandledErrorsJonas Devlieghere1-2/+2
In a lot of places an empty string was passed as the ErrorBanner to logAllUnhandledErrors. This patch makes that argument optional to simplify the call sites. llvm-svn: 346604
2018-10-31[llvm-objdump] Mark syms/t flags as NotHidden. NFC.Kristina Brooks1-0/+1
Slight improvement to help output of llvm-objdump that exposes the shorter -t flag for -syms instead of it being hidden away. llvm-svn: 345704
2018-10-31[llvm-objdump] Add --reloc alias for -r (PR39407)Kristina Brooks1-1/+5
This addresses PR39407 (https://bugs.llvm.org/show_bug.cgi?id=39407) improving compatibility with GNU binutils counterparts. Reviewed By: kristina Patch by Higuoxing (Xing). Differential Revision: https://reviews.llvm.org/D53804 llvm-svn: 345703
2018-10-31[llvm-objdump] support '--syms' as an alias of -tKristina Brooks1-2/+3
This adds support for '--syms' as an alias of '-t' for llvm-objdump, fixing PR39406 (https://bugs.llvm.org/show_bug.cgi?id=39406). Patch by Higuoxing (Xing). Differential Revision: https://reviews.llvm.org/D53803 llvm-svn: 345697
2018-10-29[llvm-objdump] Don't crash when using `-a` on non-archivesJames Henderson1-4/+4
This fixes PR39402. The crash was caused when dereferencing nullptr in DumpObject and printArchiveChild. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D53690 Patch by Xing GUO llvm-svn: 345503
2018-10-29[llvm-objdump] Add '--full-contents' as alias for '-s'James Henderson1-1/+5
This fixes PR39404. Reviewed By: jhenderson Patch by Xing Guo Differential Revision: https://reviews.llvm.org/D53576 llvm-svn: 345495
2018-10-19[llvm-objdump] Fix --file-headers (-f) optionPetar Jovanovic1-1/+4
Changed the format call to match the surrounding code. Previously it was printing an unsigned int while the return type being printed was long unsigned int or wider. This caused problems for big-endian systems which were discovered on mips64. Also, the printed address had less characters than it should because the character count was directly obtained from the number of bytes in the address. The tests were adapted to fit this fix and now use longer addresses. Patch by Milos Stojanovic. Differential Revision: https://reviews.llvm.org/D53403 llvm-svn: 344818
2018-09-27llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)Fangrui Song1-3/+3
Summary: The convenience wrapper in STLExtras is available since rL342102. Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits Differential Revision: https://reviews.llvm.org/D52573 llvm-svn: 343163
2018-08-24[llvm-objdump] Label calls to the PLT.Joel Galenson1-0/+36
Differential Revision: https://reviews.llvm.org/D50204 llvm-svn: 340611
2018-08-20[llvm-objdump] Add ability to demangle COFF symbols.Zachary Turner1-14/+14
llvm-svn: 340221