aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-06-20[llvm-objdump] Switch between ARM/Thumb based on mapping symbols.Eli Friedman1-29/+80
The ARMDisassembler changes allow changing between ARM and Thumb mode based on the MCSubtargetInfo, rather than the Target, which simplifies the other changes a bit. I'm not really happy with adding more target-specific logic to tools/llvm-objdump/, but there isn't any easy way around it: the logic in question specifically applies to disassembling an object file, and that code simply isn't located in lib/Target, at least at the moment. Differential Revision: https://reviews.llvm.org/D60927 llvm-svn: 363903
2019-06-19[llvm-objdump] Remove unnecessary indentation when dumping ELF data.Yuanfang Chen1-3/+1
Reviewers: MaskRay, jhenderson, rupprecht Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63393 llvm-svn: 363858
2019-06-19Test commit accessYuanfang Chen1-0/+1
llvm-svn: 363763
2019-06-18[llvm-objdump] Tidy up AMDGCNPrettyPrinterFangrui Song1-13/+13
llvm-svn: 363650
2019-06-17[llvm-objdump] Use %08 instead of %016 to print leading addresses for 32-bit ↵Fangrui Song1-7/+6
binaries Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D63398 llvm-svn: 363539
2019-06-11Symbolize: Replace the Options constructor with in-class initialization. NFCI.Peter Collingbourne1-3/+4
This is not only less code but also clearer at the use site. Differential Revision: https://reviews.llvm.org/D63113 llvm-svn: 363024
2019-06-07[llvm-objdump] Fix Bugzilla ID 41862 to support checking addresses of ↵Jordan Rupprecht1-2/+2
disassembled object Summary: This fixes the bugzilla id,41862 to support dealing with checking stop address against start address to support this not being a proper object to check the disasembly against like gnu objdump currently does. Reviewers: jakehehrlich, rupprecht, echristo, jhenderson, grimar Reviewed By: jhenderson Subscribers: MaskRay, smeenai, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61969 Patch by Nicholas Krause! llvm-svn: 362847
2019-06-07[llvm-objdump] Add warning if --disassemble-functions specifies an unknown ↵Michael Pozulp1-0/+12
symbol Summary: Fixes Bug 41904 https://bugs.llvm.org/show_bug.cgi?id=41904 Re-land r362768 after it was reverted in r362826. Reviewers: jhenderson, rupprecht, grimar, MaskRay Reviewed By: jhenderson, rupprecht, MaskRay Subscribers: dexonsmith, rupprecht, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62275 llvm-svn: 362838
2019-06-07Revert "[llvm-objdump] Add warning if --disassemble-functions specifies an ↵Vlad Tsyrklevich1-12/+0
unknown symbol" This reverts commit 50f61af3f304a03f10d9ecb0828829f0a72d0099, it used the function introduced in the previous revert of 0bddef79019a23ab14fcdb27028e55e484674c88. llvm-svn: 362826
2019-06-07[llvm-objdump] Print source when subsequent lines in the translation unit ↵Michael Pozulp1-2/+3
come from the same line in two different headers. Reviewers: grimar, rupprecht, jhenderson Reviewed By: grimar, jhenderson Subscribers: llvm-commits, jhenderson Tags: #llvm Differential Revision: https://reviews.llvm.org/D62461 llvm-svn: 362771
2019-06-07[llvm-objdump] Add warning if --disassemble-functions specifies an unknown ↵Michael Pozulp1-0/+12
symbol Summary: Fixes Bug 41904 https://bugs.llvm.org/show_bug.cgi?id=41904 Reviewers: jhenderson, rupprecht, grimar, MaskRay Reviewed By: jhenderson, rupprecht, MaskRay Subscribers: dexonsmith, rupprecht, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62275 llvm-svn: 362768
2019-06-05[llvm-objdump] - Disassemble non-executable sections if specifically requested.George Rimar1-1/+2
This is https://bugs.llvm.org/show_bug.cgi?id=41897. Previously -d + -j .data had no effect, that wasn't consistent with GNU, which proccesses .data in that case. With this patch we follow this behavior. Diffeential revision: https://reviews.llvm.org/D62848 llvm-svn: 362596
2019-05-23[Object] object::ELFObjectFile::symbol_begin(): skip symbol index 0Fangrui Song1-5/+0
For clients iterating the symbol table, none expects to handle index 0 (STN_UNDEF). Skip it to improve consistency with other binary formats. Clients that need STN_UNDEF (e.g. lld) can use getSectionContentsAsArray(). A test will be added in D62148. Reviewed By: mtrent Differential Revision: https://reviews.llvm.org/D62296 llvm-svn: 361506
2019-05-22[llvm-objdump] Dump inline relocations if the relocated section is specified ↵Fangrui Song1-17/+17
with --section This fixes PR41886: llvm-objdump -d -r -j .text doesn't show inline relocations of .text While here, switch to stable_sort() because we don't want to change the order of relocations applied to the same location. gABI says consecutive relocation records are composed together and their order matters. In practise it is difficult to see relocations applied to the same location not consecutive, we just have to keep the relative order of relocations with the same offset. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D62253 llvm-svn: 361395
2019-05-22Properly categorize llvm-objdump optionsSerge Guelton1-48/+80
Filters out noise, and distinguish Mach-O related options from others. Differential Revision: https://reviews.llvm.org/D62195 llvm-svn: 361351
2019-05-21[llvm-objdump] Make --disassemble-functions imply -dGeorge Rimar1-1/+2
Fixes https://bugs.llvm.org/show_bug.cgi?id=41903 Patch by Mike Pozulp! Differential revision: https://reviews.llvm.org/D62054 llvm-svn: 361240
2019-05-16Recommit [Object] Change object::SectionRef::getContents() to return ↵Fangrui Song1-10/+7
Expected<StringRef> r360876 didn't fix 2 call sites in clang. Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360892
2019-05-16Revert r360876 "[Object] Change object::SectionRef::getContents() to return ↵Hans Wennborg1-7/+10
Expected<StringRef>" It broke the Clang build, see llvm-commits thread. > Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. > > Follow-up of D61781. llvm-svn: 360878
2019-05-16[Object] Change object::SectionRef::getContents() to return Expected<StringRef>Fangrui Song1-10/+7
Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360876
2019-05-10[llvm-objdump] Print st_otherFangrui Song1-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
2019-05-07[llvm-objdump] - Print relocation record in a GNU format.George Rimar1-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
2019-05-01[llvm-objdump] Print newlines before and after "Disassembly of section ...:"Fangrui Song1-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
2019-04-24[llvm-objdump] Delete redundant checkFangrui Song1-4/+1
llvm-svn: 359102
2019-04-24[CommandLine] Provide parser<unsigned long> instantiation to allow ↵Fangrui Song1-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
2019-04-20[llvm-objdump] Fix End in disassemblyObject after rL358806Fangrui Song1-3/+3
llvm-svn: 358809
2019-04-20[llvm-objdump] Don't disassemble symbols before SectionAddrFangrui Song1-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
2019-04-20[llvm-objdump] Simplify --{start,stop}-addressFangrui Song1-23/+13
llvm-svn: 358803
2019-04-17Change some llvm::{lower,upper}_bound to llvm::bsearch. NFCFangrui Song1-22/+19
llvm-svn: 358564
2019-04-16[llvm-objdump] Align instructions to a tab stop in disassembly outputFangrui Song1-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
2019-04-16[llvm-objdump] Simplify PrintHelpMessage() logicFangrui Song1-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
2019-04-15Revert r358405: "[llvm-objdump] Align instructions to a tab stop in ↵Alex Lorenz1-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
2019-04-15Revert r358418: "[llvm-objdump] Simplify PrintHelpMessage() logic"Alex Lorenz1-9/+28
This reverts commit r358418 as it broke `test/Object/objdump-export-list` on Darwin. llvm-svn: 358443
2019-04-15[llvm-objdump] Simplify PrintHelpMessage() logicFangrui Song1-28/+9
llvm-svn: 358418
2019-04-15[llvm-objdump] Wrap things in namespace llvmFangrui Song1-35/+33
llvm-svn: 358417
2019-04-15[llvm-objdump] Reorganize cl::opt variables and move Mach-O specifics to ↵Fangrui Song1-224/+168
MachODump.cpp llvm-svn: 358415
2019-04-15[llvm-objdump] Align instructions to a tab stop in disassembly outputFangrui Song1-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
2019-04-10[llvm-objdump] Don't print trailing space in dumpBytesFangrui Song1-3/+3
In disassembly output, dumpBytes prints a space, followed by a tab printed by printInstr. Remove the extra space. llvm-svn: 358045
2019-04-10[llvm-objdump] Accept and ignore --wide/-wFangrui Song1-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
2019-04-09[llvm-objdump] Migrate some functions from std::error_code to ErrorFangrui Song1-10/+3
llvm-svn: 357965
2019-04-08[llvm-objdump] Migrate relocation handling functions from error_code to ErrorFangrui Song1-3/+9
llvm-svn: 357920
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