aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-04-09[llvm-objdump][NFC] MachODump.cpp interface cleanupHubert Tong1-3/+3
Continuing from D77388, this patch moves interface declarations associated with `MachODump.cpp` into the headers corresponding to the file that defines the variable. At the same time, these externs are moved into the `llvm::objdump` namespace. The externs defined in `MachODump.cpp` that are not referenced outside of it are given internal linkage. This patch does not rename the external functions defined by `MachODump.cpp` that are not clearly named as being specific to Mach-O. Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D77730
2020-04-08[llvm-objdump] Fix unstable disassembly output for sections with same addressJames Henderson1-1/+1
When two sections shared the same address, the disassembly code was using pointer values when sorting (see the SectionRef less than operator). Since those values aren't guaranteed to have a specific order, this meant the disassembly code would sometimes change which section to pick when finding symbols targeted by calls in fully linked objects. This change fixes the non-determinism, so that the same section is always picked. This might have a negative impact in that now a section without any symbol might be picked over a section with symbols, but this will be addressed in a later commit. Fixes https://bugs.llvm.org/show_bug.cgi?id=45411. Reviewed by: grimar, MaskRay Differential Revision: https://reviews.llvm.org/D77640
2020-04-06[llvm-objdump][NFC] Declare command-line externs in headers with namespaceHubert Tong1-73/+65
Summary: This patch moves the forward declarations of command-line `cl::*` externs in `MachODump.cpp` and `llvm-objdump.cpp` into the headers corresponding to the file that defines the variable. At the same time, these externs are moved into the `llvm::objdump` namespace. The externs that are not referenced outside their defining translation unit are made static. This does not factor out uses of the Mach-O options from `llvm-objdump.cpp`. Reviewers: jhenderson, MaskRay, DiggerLin, jasonliu, daltenty Reviewed By: jhenderson, MaskRay Subscribers: rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77388
2020-04-06[llvm-objdump][XCOFF] Use symbol index+symbol name + storage mapping class ↵diggerlin1-19/+51
as label for -D SUMMARY: For the llvm-objdump -D, the symbol name is used as a label in the disassembly for the specific address (when a symbol address is equal to the virtual address in the dump). In XCOFF, multiple symbols may have the same name, being differentiated by their storage mapping class. It is helpful to print the QualName and not just the name when forming the output label for a csect symbol. The symbol index further removes any ambiguity caused by duplicate names. To maintain compatibility with the binutils objdump, the XCOFF-specific --symbol-description option is added to enable the enhanced format. Reviewers: hubert.reinterpretcast, James Henderson, Jason Liu ,daltenty Subscribers: wuzish, nemanjai, hiraditya Differential Revision: https://reviews.llvm.org/D72973
2020-04-05[llvm-objdump] Simplify conditional statements (isa<...>(Obj) => ↵vgxbj1-8/+8
Obj->isSomeFile()) Summary: Simplify some conditional statements. Reviewers: jhenderson, MaskRay, rupprecht Reviewed By: MaskRay, rupprecht Subscribers: rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75899
2020-04-05[llvm-objdump] Teach `llvm-objdump` dump dynamic symbols.vgxbj1-124/+160
Summary: This patch is to teach `llvm-objdump` dump dynamic symbols (`-T` and `--dynamic-syms`). Currently, this patch is not fully compatible with `gnu-objdump`, but I would like to continue working on this in next few patches. It has two issues. 1. Some symbols shouldn't be marked as global(g). (`-t/--syms` has same issue as well) (Fixed by D75659) 2. `gnu-objdump` can dump version information and *dynamically* insert before symbol name field. `objdump -T a.out` gives: ``` DYNAMIC SYMBOL TABLE: 0000000000000000 w D *UND* 0000000000000000 _ITM_deregisterTMCloneTable 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 printf 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __libc_start_main 0000000000000000 w D *UND* 0000000000000000 __gmon_start__ 0000000000000000 w D *UND* 0000000000000000 _ITM_registerTMCloneTable 0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.2.5 __cxa_finalize ``` `llvm-objdump -T a.out` gives: ``` DYNAMIC SYMBOL TABLE: 0000000000000000 w D *UND* 0000000000000000 _ITM_deregisterTMCloneTable 0000000000000000 g DF *UND* 0000000000000000 printf 0000000000000000 g DF *UND* 0000000000000000 __libc_start_main 0000000000000000 w D *UND* 0000000000000000 __gmon_start__ 0000000000000000 w D *UND* 0000000000000000 _ITM_registerTMCloneTable 0000000000000000 w DF *UND* 0000000000000000 __cxa_finalize ``` Reviewers: jhenderson, grimar, MaskRay, espindola Reviewed By: jhenderson, grimar Subscribers: emaste, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75756
2020-04-02[llvm-objdump][COFF][NFC] Split format-specific interfaces; add namespaceHubert Tong1-0/+2
Summary: This patch addresses, for the interfaces implemented by `COFFDump.cpp`, multiple issues identified with the current structure of `llvm-objdump.h` in the review of D72973. This patch moves implementation details of the tool into an `llvm::objdump` namespace for external linkage names, splits the implementation details into separate headers for each implementation file, and uses qualified names when declaring members of the `llvm::objdump` namespace in place of leaving the namespace definition open. Reviewers: jhenderson, DiggerLin, jasonliu, daltenty, MaskRay Reviewed By: jhenderson, MaskRay Subscribers: MaskRay, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77285
2020-03-27[llvm-objdump][XCOFF][AIX] Implement -r optionjasonliu1-0/+3
Summary: Implement several XCOFF hooks to get '-r' option working for llvm-objdump -r. Reviewer: DiggerLin, hubert.reinterpretcast, jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D75131
2020-03-26[llvm-objdump] Fix typo. NFCFangrui Song1-3/+3
2020-03-26[X86InstPrinter] Change printPCRelImm to print the target address in ↵Fangrui Song1-3/+9
hexadecimal form ``` // llvm-objdump -d output (before) 400000: e8 0b 00 00 00 callq 11 400005: e8 0b 00 00 00 callq 11 // llvm-objdump -d output (after) 400000: e8 0b 00 00 00 callq 0x400010 400005: e8 0b 00 00 00 callq 0x400015 // GNU objdump -d. The lack of 0x is not ideal because the result cannot be re-assembled 400000: e8 0b 00 00 00 callq 400010 400005: e8 0b 00 00 00 callq 400015 ``` In llvm-objdump, we pass the address of the next MCInst. Ideally we should just thread the address of the current address, unfortunately we cannot call X86MCCodeEmitter::encodeInstruction (X86MCCodeEmitter requires MCInstrInfo and MCContext) to get the length of the MCInst. MCInstPrinter::printInst has other callers (e.g llvm-mc -filetype=asm, llvm-mca) which set Address to 0. They leave MCInstPrinter::PrintBranchImmAsAddress as false and this change is a no-op for them. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D76580
2020-03-26[MCInstPrinter] Pass `Address` parameter to MCOI::OPERAND_PCREL typed ↵Fangrui Song1-0/+1
operands. NFC Follow-up of D72172 and D72180 This patch passes `uint64_t Address` to print methods of PC-relative operands so that subsequent target specific patches can change `*InstPrinter::print{Operand,PCRelImm,...}` to customize the output. Add MCInstPrinter::PrintBranchImmAsAddress which is set to true by llvm-objdump. ``` // Current llvm-objdump -d output aarch64: 20000: bl #0 ppc: 20000: bl .+4 x86: 20000: callq 0 // Ideal output aarch64: 20000: bl 0x20000 ppc: 20000: bl 0x20004 x86: 20000: callq 0x20005 // GNU objdump -d. The lack of 0x is not ideal because the result cannot be re-assembled aarch64: 20000: bl 20000 ppc: 20000: bl 0x20004 x86: 20000: callq 20005 ``` In `lib/Target/X86/X86GenAsmWriter1.inc` (generated by `llvm-tblgen -gen-asm-writer`): ``` case 12: // CALL64pcrel32, CALLpcrel16, CALLpcrel32, EH_SjLj_Setup, JCXZ, JECXZ, J... - printPCRelImm(MI, 0, O); + printPCRelImm(MI, Address, 0, O); return; ``` Some targets have 2 `printOperand` overloads, one without `Address` and one with `Address`. They should annotate derived `Operand` properly with `let OperandType = "OPERAND_PCREL"`. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D76574
2020-03-25[llvm-objdump] Replace array_pod_sort with llvm::stable_sortFangrui Song1-5/+8
llvm-objdump.cpp has 3 array_pod_sort() calls used for symbolization. array_pod_start() calls qsort() internally and can have different behaviors across different libcs. Use llvm::stable_sort instead. Reviewed By: davidb, thopre Differential Revision: https://reviews.llvm.org/D76739
2020-03-16Revert "[llvm-objdump] Display locations of variables alongside disassembly"Nico Weber1-472/+66
Makes tests fail on Windows, see https://reviews.llvm.org/D70720#1924542 This reverts commit 3a5ddedadb671e485ce5c638142817879ac14a8c, and follow-ups: f4cb9c919e28276222873453cf85de9e5a3c7be5 042eb0482aa758057c4f77616a4696cdb21b4fcc c0cf5f5da9a7bf1bdf43ed53287b0f634fc53045 18649f48139932377c2a2909f1fb600bf5cf6e57 f62b898c1f5dd77e68b53570dc2679877bcbe4c2
2020-03-16[llvm-objdump] Add llvm_unreachable to silence GCC warning. NFC.Martin Storsjö1-0/+1
GCC 7 warned about control reaching the end of the non-void function, despite all 7 LineChar values being handled in the switch.
2020-03-16[llvm-objdump] Display locations of variables alongside disassemblyOliver Stannard1-66/+471
This adds the --debug-vars option to llvm-objdump, which prints locations (registers/memory) of source-level variables alongside the disassembly based on DWARF info. A vertical line is printed for each live-range, with a label at the top giving the variable name and location, and the position and length of the line indicating the program counter range in which it is valid. Currently, this only works for object files, not executables or shared libraries. Differential revision: https://reviews.llvm.org/D70720
2020-03-15[llvm-objdump] Require long options to use double-dash --long-optionFangrui Song1-1/+3
As announced here: http://lists.llvm.org/pipermail/llvm-dev/2019-April/131786.html
2020-03-13Fix `-Wunused-variable`. NFC.Michael Liao1-1/+1
2020-03-13[llvm-objdump] --syms: print 'u' for STB_GNU_UNIQUEFangrui Song1-0/+2
GCC when configured with --enable-gnu-unique (default on glibc>=2.11) emits STB_GNU_UNIQUE for certain objects which are otherwise emitted as STT_OBJECT, such as an inline function's static local variable or its guard variable, and a static data member of a template. Clang does not implement -fgnu-unique. Implementing it as a binding is strange and the feature itself is considered by some as a misfeature. Reviewed By: grimar, jhenderson Differential Revision: https://reviews.llvm.org/D75797
2020-03-13[llvm-objdump] --syms: print 'i' for STT_GNU_IFUNCFangrui Song1-1/+6
Reviewed By: grimar, Higuoxing, jhenderson Differential Revision: https://reviews.llvm.org/D75793
2020-03-09[llvm-objdump] Rename --disassemble-functions to --disassemble-symbolsFangrui Song1-18/+16
https://bugs.llvm.org/show_bug.cgi?id=41910 The feature can disassemble data and the new option name reflects its more generic usage. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D75816
2020-03-05[llvm-objdump] -d: print `00000000 <foo>:` instead of `00000000 foo:`Fangrui Song1-1/+1
The new behavior matches GNU objdump. A pair of angle brackets makes tests slightly easier. `.foo:` is not unique and thus cannot be used in a `CHECK-LABEL:` directive. Without `-LABEL`, the CHECK line can match the `Disassembly of section` line and causes the next `CHECK-NEXT:` to fail. ``` Disassembly of section .foo: 0000000000001634 .foo: ``` Bdragon: <> has metalinguistic connotation. it just "feels right" Reviewed By: rupprecht Differential Revision: https://reviews.llvm.org/D75713
2020-03-05[llvm-objdump] --syms: make flags closer to GNU objdumpFangrui Song1-1/+1
This fixes several issues. The behavior changes are: A SHN_COMMON symbol does not have the 'g' flag. An undefined symbol does not have 'g' or 'l' flag. A STB_GLOBAL SymbolRef::ST_Unknown symbol has the 'g' flag. A STB_LOCAL SymbolRef::ST_Unknown symbol has the 'l' flag. Reviewed By: rupprecht Differential Revision: https://reviews.llvm.org/D75659
2020-03-04[llvm-objdump] --syms: print st_size as "%016" PRIx64 instead of "%08" ↵Fangrui Song1-1/+1
PRIx64 for 64-bit objects This is GNU objdump's behavior and it is reasonable to match. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D75588
2020-02-21[llvm-objdump] Print method name from debug info in disassembly output.Jordan Rupprecht1-24/+54
Summary: GNU objdump prints the method name in disassembly output, and upon further investigation this seems to come from debug info, not the symbol table. Some additional refactoring is necessary to make this work even when the line number is 0/the filename is unknown. The added test case includes a note for this scenario. See http://llvm.org/PR41341 for more info. Reviewers: dblaikie, MaskRay, jhenderson Reviewed By: MaskRay Subscribers: ormris, jvesely, aprantl, kerbowa, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D74507
2020-02-12[llvm-objdump] Print file format in lowercase to match GNU output.Jordan Rupprecht1-1/+1
Summary: GNU objdump prints the file format in lowercase, e.g. `elf64-x86-64`. llvm-objdump prints `ELF64-x86-64` right now, even though piping that into llvm-objcopy refuses that as a valid arch to use. As an example of a problem this causes, see: https://github.com/ClangBuiltLinux/linux/issues/779 Reviewers: MaskRay, jhenderson, alexshap Reviewed By: MaskRay Subscribers: tpimh, sbc100, grimar, jvesely, nhaehnle, kerbowa, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D74433
2020-02-12[llvm-objdump] Add column headers for relocation printingLiad Mordekoviz1-2/+8
This allows us better readability and compatibility with what GNU objdump prints. Fixes https://bugs.llvm.org/show_bug.cgi?id=43941 Reviewed by: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D72992
2020-02-11[NFC] Refactor the tuple of symbol information with structure for llvm-objdumpdiggerlin1-10/+0
SUMMARY: address the comment of https://reviews.llvm.org/D74240#inline-676127 https://reviews.llvm.org/D74240#inline-675875 Reviewers: daltenty, jason liu, xiangling liao Subscribers: wuzish, nemanjai, hiraditya Differential Revision: https://reviews.llvm.org/D74240
2020-02-10[NFC] Refactor the tuple of symbol information with structure for llvm-objdumpdiggerlin1-18/+26
SUMMARY: refator the std::tuple<uint64_t, StringRef, uint8_t> to structor Reviewers: daltenty Subscribers: wuzish, nemanjai, hiraditya Differential Revision: https://reviews.llvm.org/D74240
2020-02-03[llvm-objdump] Suppress spurious warnings when parsing Mach-O binaries.Michael Trent1-1/+1
Summary: llvm-objdump started warning when asked to disassemble a section that isn't present in the input files, in Yuanfang Chen's change: d16c162c9453db855503134fe29ae4a3c0bec936. The problem is that the logic was restricted only to the generic llvm-objdump parser, not to the Mach-O-specific parser used for Apple toolchain compatibility. The solution is to log section names from the Mach-O parser. The macho-cstring-dump.test has been updated to fail if it encounters this new warning in the future. Reviewers: pete, ab, lhames, jhenderson, grimar, MaskRay, ychen Reviewed By: jhenderson, grimar Subscribers: rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73586
2020-01-31[llvm-objdump] avoid crash disassembling unknown instructionSjoerd Meijer1-0/+8
Disassembly of instructions can fail when llvm-objdump is not given the right set of architecture features, for example when the source is compiled with: clang -march=..+ext1+ext2 and disassembly is attempted with: llvm-objdump -mattr=+ext1 This patch avoids further analysing unknown instructions (as was happening before) when disassembly has failed. Differential Revision: https://reviews.llvm.org/D73531
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-3/+3
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-11[Disassembler] Delete the VStream parameter of MCDisassembler::getInstruction()Fangrui Song1-9/+2
The argument is llvm::null() everywhere except llvm::errs() in llvm-objdump in -DLLVM_ENABLE_ASSERTIONS=On builds. It is used by no target but X86 in -DLLVM_ENABLE_ASSERTIONS=On builds. If we ever have the needs to add verbose log to disassemblers, we can record log with a member function, instead of passing it around as an argument.
2020-01-06[MC] Add parameter `Address` to MCInstPrinter::printInstFangrui Song1-4/+4
printInst prints a branch/call instruction as `b offset` (there are many variants on various targets) instead of `b address`. It is a convention to use address instead of offset in most external symbolizers/disassemblers. This difference makes `llvm-objdump -d` output unsatisfactory. Add `uint64_t Address` to printInst(), so that it can pass the argument to printInstruction(). `raw_ostream &OS` is moved to the last to be consistent with other print* methods. The next step is to pass `Address` to printInstruction() (generated by tablegen from the instruction set description). We can gradually migrate targets to print addresses instead of offsets. In any case, downstream projects which don't know `Address` can pass 0 as the argument. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D72172
2019-12-20llvm-objdump should ignore Mach-O stab symbols for disassembly.Michael Trent1-2/+31
Summary: llvm-objdump will commonly error out when disassembling a Mach-O binary with stab symbols, or when printing a Mach-O symbol table that includesstab symbols. That is because the Mach-O N_OSO symbol has been modified to include the bottom 8-bit value of the Mach-O's cpusubtype value in the section field. In general, one cannot blindly assume a stab symbol's section field is valid unless one has actually consulted the specification for the specific stab. Since objdump mostly just walks the symbol table to get mnemonics for code disassembly it's best for objdump to just ignore stab symbols. llvm-nm will do a more complete and correct job of displaying Mach-O symbol table contents. Reviewers: pete, lhames, ab, thegameg, jhenderson, MaskRay Reviewed By: thegameg, MaskRay Subscribers: MaskRay, rupprecht, seiya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71394
2019-10-23[Mips] Use appropriate private label prefix based on Mips ABIMirko Brkusanin1-1/+3
MipsMCAsmInfo was using '$' prefix for Mips32 and '.L' for Mips64 regardless of -target-abi option. By passing MCTargetOptions to MCAsmInfo we can find out Mips ABI and pick appropriate prefix. Tags: #llvm, #clang, #lldb Differential Revision: https://reviews.llvm.org/D66795
2019-10-21[llvm/Object] - Make ELFObjectFile::getRelocatedSection return ↵George Rimar1-4/+19
Expected<section_iterator> It returns just a section_iterator currently and have a report_fatal_error call inside. This change adds a way to return errors and handle them on caller sides. The patch also changes/improves current users and adds test cases. Differential revision: https://reviews.llvm.org/D69167 llvm-svn: 375408
2019-10-17Reland [llvm-objdump] Use a counter for llvm-objdump -h instead of the ↵Jordan Rupprecht1-12/+41
section index. This relands r374931 (reverted in r375088). It fixes 32-bit builds by using the right format string specifier for uint64_t (PRIu64) instead of `%d`. Original description: When listing the index in `llvm-objdump -h`, use a zero-based counter instead of the actual section index (e.g. shdr->sh_index for ELF). While this is effectively a noop for now (except one unit test for XCOFF), the index values will change in a future patch that filters certain sections out (e.g. symbol tables). See D68669 for more context. Note: the test case in `test/tools/llvm-objdump/X86/section-index.s` already covers the case of incrementing the section index counter when sections are skipped. Reviewers: grimar, jhenderson, espindola Reviewed By: grimar Subscribers: emaste, sbc100, arichardson, aheejin, arphaman, seiya, llvm-commits, MaskRay Tags: #llvm Differential Revision: https://reviews.llvm.org/D68848 llvm-svn: 375178
2019-10-17Revert r374931 "[llvm-objdump] Use a counter for llvm-objdump -h instead of ↵Hans Wennborg1-41/+12
the section index." This broke llvm-objdump in 32-bit builds, see e.g. http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/10925 > Summary: > When listing the index in `llvm-objdump -h`, use a zero-based counter instead of the actual section index (e.g. shdr->sh_index for ELF). > > While this is effectively a noop for now (except one unit test for XCOFF), the index values will change in a future patch that filters certain sections out (e.g. symbol tables). See D68669 for more context. Note: the test case in `test/tools/llvm-objdump/X86/section-index.s` already covers the case of incrementing the section index counter when sections are skipped. > > Reviewers: grimar, jhenderson, espindola > > Reviewed By: grimar > > Subscribers: emaste, sbc100, arichardson, aheejin, arphaman, seiya, llvm-commits, MaskRay > > Tags: #llvm > > Differential Revision: https://reviews.llvm.org/D68848 llvm-svn: 375088
2019-10-15[llvm-objdump] Use a counter for llvm-objdump -h instead of the section index.Jordan Rupprecht1-12/+41
Summary: When listing the index in `llvm-objdump -h`, use a zero-based counter instead of the actual section index (e.g. shdr->sh_index for ELF). While this is effectively a noop for now (except one unit test for XCOFF), the index values will change in a future patch that filters certain sections out (e.g. symbol tables). See D68669 for more context. Note: the test case in `test/tools/llvm-objdump/X86/section-index.s` already covers the case of incrementing the section index counter when sections are skipped. Reviewers: grimar, jhenderson, espindola Reviewed By: grimar Subscribers: emaste, sbc100, arichardson, aheejin, arphaman, seiya, llvm-commits, MaskRay Tags: #llvm Differential Revision: https://reviews.llvm.org/D68848 llvm-svn: 374931
2019-10-14[llvm-objdump] Adjust spacing and field width for --section-headersJordan Rupprecht1-15/+33
Summary: - Expand the "Name" column past 13 characters when any of the section names are longer. Current behavior is a staggard output instead of a nice table if a single name is longer. - Only print the required number of hex chars for addresses (i.e. 8 characters for 32-bit, 16 characters for 64-bit) - Fix trailing spaces Reviewers: grimar, jhenderson, espindola Reviewed By: grimar Subscribers: emaste, sbc100, arichardson, aheejin, seiya, llvm-commits, MaskRay Tags: #llvm Differential Revision: https://reviews.llvm.org/D68730 llvm-svn: 374795
2019-10-03[llvm-objdump] Further rearrange llvm-objdump sections for compatabilityJordan Rupprecht1-17/+22
Summary: rL371826 rearranged some output from llvm-objdump for GNU objdump compatability, but there still seem to be some more. I think this rearrangement is a little closer. Overview of the ordering which matches GNU objdump: * Archive headers * File headers * Section headers * Symbol table * Dwarf debugging * Relocations (if `--disassemble` is not used) * Section contents * Disassembly Reviewers: jhenderson, justice_adams, grimar, ychen, espindola Reviewed By: jhenderson Subscribers: aprantl, emaste, arichardson, jrtc27, atanasyan, seiya, llvm-commits, MaskRay Tags: #llvm Differential Revision: https://reviews.llvm.org/D68066 llvm-svn: 373671
2019-09-13[llvm-objdump] Fix llvm-objdump --all-headers output orderGeorge Rimar1-2/+2
Patch by Justice Adams! Made llvm-objdump --all-headers output match the order of GNU objdump for compatibility reasons. Old order of the headers output: * file header * section header table * symbol table * program header table * dynamic section New order of the headers output (GNU compatible): * file header information * program header table * dynamic section * section header table * symbol table (Relevant BugZilla Bug: https://bugs.llvm.org/show_bug.cgi?id=41830) Differential revision: https://reviews.llvm.org/D67357 llvm-svn: 371826
2019-08-27[llvm-objdump] - Remove one overload of reportError. NFCI.George Rimar1-19/+9
There is a problem with reportError we have. Declaration says we have ArchiveName that follows the FileName: reportError(Error E, StringRef FileName, StringRef ArchiveName,... Though implementation have them reversed. I cleaned it up and removed an excessive reportError(Error E, StringRef File) version. Rebased on top of D66418. Differential revision: https://reviews.llvm.org/D66517 llvm-svn: 370034
2019-08-21[llvm-objdump] - Cleanup the error reporting.George Rimar1-94/+87
The error reporting function are not consistent. Before this change: * They had inconsistent naming (e.g. 'error' vs 'report_error'). * Some of them reported the object name, others - dont. * Some of them accepted the case when there was no error. (i.e. error code or Error had a success value). This patch tries to cleanup it a bit. It also renames report_error -> reportError, report_warning -> reportWarning and removes a full stop from messages. Differential revision: https://reviews.llvm.org/D66418 llvm-svn: 369515
2019-08-20[llvm-objdump] - Remove one of `report_error` functions and improve the ↵George Rimar1-15/+14
error reporting. One of the report_error functions was taking object::Archive::Child as an argument. It feels excessive, this patch removes it and introduce a helper function instead. Also I fixed a "TODO" in this patch what improved the message printed. Differential revision: https://reviews.llvm.org/D66468 llvm-svn: 369382
2019-08-15[llvm-objdump] Add warning messages if disassembly + source for problematic ↵Michael Pozulp1-25/+51
inputs Summary: Addresses https://bugs.llvm.org/show_bug.cgi?id=41905 Reviewers: jhenderson, rupprecht, grimar Reviewed By: jhenderson, grimar Subscribers: RKSimon, MaskRay, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62462 llvm-svn: 368963
2019-08-14Recommit r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar1-21/+36
Expected<>" Changes: no changes. A fix for the clang code will be landed right on top. Original commit message: SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368826
2019-08-14Revert r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar1-36/+21
Expected<>" It broke clang BB: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/16455 llvm-svn: 368813
2019-08-14[llvm/Object] - Convert SectionRef::getName() to return Expected<>George Rimar1-21/+36
SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368812
2019-08-05Revert "[llvm-objdump] Re-commit r367284."Michael Pozulp1-50/+25
This reverts r367776 (git commit d34099926e909390cb0254bebb4b7f5cf15467c7). My changes to llvm-objdump tests caused them to fail on windows: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/27368 llvm-svn: 367816