summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [Object] Change object::SectionRef::getContents() to return Expected<StringRef>Fangrui Song2019-05-161-10/+7
| | | | | | | | Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360876
* [llvm-objdump] Print st_otherFangrui Song2019-05-101-6/+24
| | | | | | | | | | | Add support for ".hidden" ".internal" ".protected" and " 0x%02x" for other st_other bits used by some architectures. Reviewed By: sfertile Differential Revision: https://reviews.llvm.org/D61718 llvm-svn: 360439
* [llvm-objdump] - Print relocation record in a GNU format.George Rimar2019-05-071-11/+23
| | | | | | | | | | | | | | | This fixes the https://bugs.llvm.org/show_bug.cgi?id=41355. Previously with -r we printed relocation section name instead of the target section name. It was like this: "RELOCATION RECORDS FOR [.rel.text]" Now it is: "RELOCATION RECORDS FOR [.text]" Also when relocation target section has more than one relocation section, we did not combine the output. Now we do. Differential revision: https://reviews.llvm.org/D61312 llvm-svn: 360143
* [llvm-objdump] Print newlines before and after "Disassembly of section ...:"Fangrui Song2019-05-011-2/+2
| | | | | | | | | | | This improves readability and the behavior is consistent with GNU objdump. The new test test/tools/llvm-objdump/X86/disassemble-section-name.s checks we print newlines before and after "Disassembly of section ...:" Differential Revision: https://reviews.llvm.org/D61127 llvm-svn: 359668
* [llvm-objdump] Delete redundant checkFangrui Song2019-04-241-4/+1
| | | | llvm-svn: 359102
* [CommandLine] Provide parser<unsigned long> instantiation to allow ↵Fangrui Song2019-04-241-5/+6
| | | | | | | | | | | | | cl::opt<uint64_t> on LP64 platforms Summary: And migrate opt<unsigned long long> to opt<uint64_t> Fixes PR19665 Differential Revision: https://reviews.llvm.org/D60933 llvm-svn: 359068
* [llvm-objdump] Fix End in disassemblyObject after rL358806Fangrui Song2019-04-201-3/+3
| | | | llvm-svn: 358809
* [llvm-objdump] Don't disassemble symbols before SectionAddrFangrui Song2019-04-201-4/+6
| | | | | | | | | This was caught by UBSAN tools/llvm-objdump/X86/macho-disassembly-g-dsym.test tools/llvm-objdump/X86/hex-displacement.test llvm-svn: 358806
* [llvm-objdump] Simplify --{start,stop}-addressFangrui Song2019-04-201-23/+13
| | | | llvm-svn: 358803
* Change some llvm::{lower,upper}_bound to llvm::bsearch. NFCFangrui Song2019-04-171-22/+19
| | | | llvm-svn: 358564
* [llvm-objdump] Align instructions to a tab stop in disassembly outputFangrui Song2019-04-161-5/+18
| | | | | | | | | | | | | | | | | | | | | | | This relands D60376/rL358405, with the difference: sed 'y/\t/ /' -> tr '\t' ' ' BSD sed doesn't support escape characters for the 'y' command. I didn't use it in rL358405 because it was not listed at https://llvm.org/docs/GettingStarted.html#software but it should be available. Original description: In GNU objdump, -w/--wide aligns instructions in the disassembly output. This patch does the same to llvm-objdump. However, we always use the wide format (-w/--wide is ignored), because the narrow format (instructions are misaligned) is probably not very useful. In llvm-readobj, we made a similar decision: always use the wide format, accept but ignore -W/--wide. To save some columns, we change the tab before hex bytes (controlled by --[no-]show-raw-insn) to a space. llvm-svn: 358474
* [llvm-objdump] Simplify PrintHelpMessage() logicFangrui Song2019-04-161-28/+9
| | | | | | | | This relands rL358418. It missed one test that should also use -macho Note, all the other -private-header -exports-trie tests are used together with -macho. llvm-svn: 358472
* Revert r358405: "[llvm-objdump] Align instructions to a tab stop in ↵Alex Lorenz2019-04-151-18/+5
| | | | | | | | | disassembly output" The test fails on darwin due to a sed error: sed: 1: "y/\t/ /": transform strings are not the same length llvm-svn: 358459
* Revert r358418: "[llvm-objdump] Simplify PrintHelpMessage() logic"Alex Lorenz2019-04-151-9/+28
| | | | | | | This reverts commit r358418 as it broke `test/Object/objdump-export-list` on Darwin. llvm-svn: 358443
* [llvm-objdump] Simplify PrintHelpMessage() logicFangrui Song2019-04-151-28/+9
| | | | llvm-svn: 358418
* [llvm-objdump] Wrap things in namespace llvmFangrui Song2019-04-151-35/+33
| | | | llvm-svn: 358417
* [llvm-objdump] Reorganize cl::opt variables and move Mach-O specifics to ↵Fangrui Song2019-04-151-224/+168
| | | | | | MachODump.cpp llvm-svn: 358415
* [llvm-objdump] Align instructions to a tab stop in disassembly outputFangrui Song2019-04-151-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In GNU objdump, -w/--wide aligns instructions in the disassembly output. This patch does the same to llvm-objdump. However, we always use the wide format (-w/--wide is ignored), because the narrow format (instructions are misaligned) is probably not very useful. In llvm-readobj, we made a similar decision: always use the wide format, accept but ignore -W/--wide. To save some columns, we change the tab before hex bytes (controlled by --[no-]show-raw-insn) to a space. Reviewers: rupprecht, jhenderson, grimar Reviewed By: jhenderson Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60376 llvm-svn: 358405
* [llvm-objdump] Don't print trailing space in dumpBytesFangrui Song2019-04-101-3/+3
| | | | | | | In disassembly output, dumpBytes prints a space, followed by a tab printed by printInstr. Remove the extra space. llvm-svn: 358045
* [llvm-objdump] Accept and ignore --wide/-wFangrui Song2019-04-101-0/+4
| | | | | | | | | This is similar to what we do for llvm-readobj (--wide/-W is for GNU readelf compatibility). The test will be added in D60376. llvm-svn: 358043
* [llvm-objdump] Migrate some functions from std::error_code to ErrorFangrui Song2019-04-091-10/+3
| | | | llvm-svn: 357965
* [llvm-objdump] Migrate relocation handling functions from error_code to ErrorFangrui Song2019-04-081-3/+9
| | | | llvm-svn: 357920
* [llvm-objdump] Fix MC/ARM/arm-macho-calls.sFangrui Song2019-04-081-2/+1
| | | | llvm-svn: 357880
* [llvm-objdump] Split disassembleObject and simplify --{start,stop}-address ↵Fangrui Song2019-04-071-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
* [llvm-objdump] Fix split of source lines; don't ltrim source linesFangrui Song2019-04-071-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
* [llvm-objdump] Simplify Expected<T> handling with unwrapOrErrorFangrui Song2019-04-071-98/+43
| | | | llvm-svn: 357855
* [llvm-objdump] Simplify disassembleObjectFangrui Song2019-04-071-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
* Change some StringRef::data() reinterpret_cast to bytes_begin() or ↵Fangrui Song2019-04-071-2/+1
| | | | | | arrayRefFromStringRef() llvm-svn: 357852
* Fix typoed variable name.Eric Christopher2019-03-281-4/+4
| | | | | | NFCI. llvm-svn: 357138
* [llvm-objdump] Support arg grouping for -j and -M (e.g. llvm-objdump -sj.foo ↵Jordan Rupprecht2019-03-211-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
* [DebugInfo] add SectionedAddress to DebugInfo interfaces.Alexey Lapshin2019-02-271-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
* [llvm-objdump] Implement -Mreg-names-raw/-std options.Igor Kudrin2019-02-261-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
* [llvm-objdump] Add `Version References` dumperXing GUO2019-02-251-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
* Revert "Revert "[llvm-objdump] Allow short options without arguments to be ↵Matthew Voss2019-02-191-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
* [yaml2obj] - Do not skip zeroes blocks if there are relocations against them.George Rimar2019-02-191-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
* Revert "[llvm-objdump] Allow short options without arguments to be grouped"Matthew Voss2019-02-141-26/+18
| | | | | | | | Reverted due to failures on the llvm-hexagon-elf. This reverts commit 77e1f27476c89f65eeb496d131065177e6417f23. llvm-svn: 354002
* [llvm-objdump] Allow short options without arguments to be groupedMatthew Voss2019-02-141-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
* [llvm-objdump] - llvm-objdump can skip bytes at the end of a section.Sid Manning2019-02-011-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D57549 llvm-svn: 352900
* [ELF] Return the section name when calling getSymbolName on a section symbol.Matt Davis2019-01-311-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
* [llvm-objdump] - Restore a piece of code removed by mistake in r352366.George Rimar2019-01-281-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
* [llvm-objdump] - Print LMAs when dumping section headers.George Rimar2019-01-281-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
* [llvm-objdump] - Fix comment. NFC.George Rimar2019-01-281-1/+1
| | | | | | | This was mentioned by James Henderson in review for https://reviews.llvm.org/D57051. llvm-svn: 352348
* [llvm-objdump] - Implement the --adjust-vma option.George Rimar2019-01-281-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
* [llvm-objdump] - Move common code to a new printRelocation() helper. NFC.George Rimar2019-01-231-23/+20
| | | | | | This extracts the common code for printing relocations into a new helper function. llvm-svn: 351951
* [llvm-objdump] - Move variable. NFC.George Rimar2019-01-231-4/+5
| | | | | | It was too far from the place where it is used. llvm-svn: 351942
* [llvm-objdump] - Split disassembleObject() into two methods. NFCI.George Rimar2019-01-231-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
* [llvm-objdump] - Introduce getRelocsMap() helper. NFCI.George Rimar2019-01-221-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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-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
* Revert r351529 "[llvm-objdump][NFC] Improve readability."Clement Courbet2019-01-181-34/+29
| | | | | | msan errors in ELF/strip-all.s. llvm-svn: 351556
* Reland r351529 "[llvm-objdump][NFC] Improve readability."Clement Courbet2019-01-181-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
OpenPOWER on IntegriCloud