aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.h
AgeCommit message (Collapse)AuthorFilesLines
4 days[llvm-objdump] Add inlined function display support (#142246)gulfemsavrun1-3/+4
This patch adds the support for displaying inlined functions into llvm-objdump. 1) It extends the source variable display support for inlined functions both for ascii and unicode formats. 2) It also introduces a new format called limits-only that only prints a line for the start and end of an inlined function without line-drawing characters.
2025-02-28[llvm-objdump] Rework .gnu.version_d dumpingFangrui Song1-0/+1
and fix crash when vd_aux is invalid (#86611). vd_version, vd_flags, vd_ndx, and vd_cnt in Elf{32,64}_Verdef are 16-bit. Change VerDef to use uint16_t instead. vda_name specifies a NUL-terminated string. Update getVersionDefinitions to remove some `.c_str()`. Pull Request: https://github.com/llvm/llvm-project/pull/128434
2024-12-23[llvm-objdump] Remove some unneeded headers. (#120541)Cabbaken1-2/+0
Co-authored-by: qiuruoyu <qiuruoyu@xiaomi.com>
2024-10-28[llvm-objdump] Handle -M for --machoFangrui Song1-0/+1
--macho -d uses the `parseInputMachO` code path, which does not handle -M. Add -M handling for --macho as well. Close #61019 Pull Request: https://github.com/llvm/llvm-project/pull/113795
2023-08-14[llvm-objdump] Add WarningHandler as a member variable. NFCFangrui Song1-1/+5
This can be used to avoid `auto WarningHandler = ...`. Similar to llvm-readobj.
2023-07-27[llvm-objdump] -d: don't display mapping symbols as labelsFangrui Song1-1/+2
Similar to D96617 for llvm-symbolizer. This patch matches the GNU objdump -d behavior to suppress printing labels for mapping symbols. Mapping symbol names don't convey much information. When --show-all-symbols (not in GNU) is specified, we still print mapping symbols. Note: the `for (size_t SI = 0, SE = Symbols.size(); SI != SE;)` loops needs to iterate all mapping symbols, even if they are not displayed. We use the new field `IsMappingSymbol` to recognize mapping symbols. This field also enables simplification after D139131. ELF/ARM/disassemble-all-mapping-symbols.s is enhanced to add `.space 2`. If `End = std::min(End, Symbols[SI].Addr);` is not correctly set, we would print a `.word`. Reviewed By: jhenderson, jobnoorman, peter.smith Differential Revision: https://reviews.llvm.org/D156190
2023-07-26[llvm-objdump] Remove bool MachOOnlyFirst from printPrivateHeaders after ↵Fangrui Song1-1/+1
D155045. NFC Mach-O can just use the global variable `FirstPrivateHeader`. If we ever manage to remove global variables, we can add a Config variable to Dumper. Either case, the parameter is not needed. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D156291
2023-07-14[llvm-objdump] Move printDynamicRelocations into ELFDump.cpp. NFCFangrui Song1-1/+1
2023-07-14[llvm-objdump] Create ObjectFile specific dumpersFangrui Song1-0/+15
We pay the one-off boilerplate overhead to create `*Dumper` classes that derive from objdump::Dumper a la llvm-readobj. This has two primary advantages. First, a lot object file format specific code can be moved from llvm-objdump.cpp to *Dump.cpp files. Refactor `printPrivateHeaders` as an example. Second, with the introduction of ELFDumper<ELFT>, we can simplify a few dispatch functions in ELFDump.cpp. In addition, the ObjectFile specific dumpers contains a ObjectFile specific reference so that we can remove a lot of `cast<*ObjectFile>(Obj)`. Reviewed By: mtrofin Differential Revision: https://reviews.llvm.org/D155045
2023-07-11[llvm-objdump] Change errors to warnings for symbol section name dumpingFangrui Song1-8/+20
Port D69671 (llvm-readobj) to llvm-objdump. Add a class llvm::objdump::Dumper and move some free functions into Dumper so that they can call reportUniqueWarning. Warnings seems preferable in these cases as the issue is localized and we can continue dumping other information. Differential Revision: https://reviews.llvm.org/D154754
2023-07-10[nfc] Factoring out utility that can be used for other object-level toolsDayann D'almeida1-55/+3
Related rfc can be found at https://discourse.llvm.org/t/rfc-llvm-cm-cost-model-evaluation-for-object-files-machine-code/71502. We want to reuse the instruction iterator for this tool. Reviewed By: mtrofin, kazu, jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D152869
2023-07-06[AIX][XCOFF] print out the traceback infozhijian1-0/+7
Summary: Adding a new option -traceback-table to print out the traceback info of xcoff ojbect file. Reviewers: James Henderson, Fangrui Song, Stephen Peckham, Xing Xue Differential Revision: https://reviews.llvm.org/D89049
2022-10-14[llvm-objdump/mac] Add new function starts print modeKeith Smiley1-0/+6
This updates the `--function-starts` argument to now accept 3 different modes, `addrs` for just printing the addresses of the function starts (previous behavior), `names` for just printing the names of the function starts, and `both` to print them both side by side. In general if you're debugging function starts issues it's useful to see the symbol name alongside the address. This also mirrors Apple's `dyldinfo -function_starts` command which prints both. Differential Revision: https://reviews.llvm.org/D119050
2022-07-14[llvm-objdump] Create fake sections for a ELF core fileNamhyung Kim1-1/+1
The linux perf tools use /proc/kcore for disassembly kernel functions. Actually it copies the relevant parts to a temp file and then pass it to objdump. But it doesn't have section headers so llvm-objdump cannot handle it. Let's create fake section headers for the program headers. It'd have a single section for each segment to cover the entire range. And for this purpose we can consider only executable code segments. With this change, I can see the following command shows proper outputs. perf annotate --stdio --objdump=/path/to/llvm-objdump Differential Revision: https://reviews.llvm.org/D128705
2022-07-07[llvm-objdump] Change some nonnull pointers to references. NFCFangrui Song1-4/+4
2022-01-07[llvm] Remove unused forward declarations (NFC)Kazu Hirata1-4/+0
2021-11-04[llvm-objdump] Fix the Assertion failure when providing invalid --debug-vars ↵gbreynoo1-5/+1
or --dwarf values As seen in https://bugs.llvm.org/show_bug.cgi?id=52213 llvm-objdump asserts if either the --debug-vars or the --dwarf options are provided with invalid values. As suggested, this fix adds use of a default value to these options and errors when given bad input. Differential Revision: https://reviews.llvm.org/D112183
2021-08-17[llvm-objdump] -T: print symbol versionsFangrui Song1-0/+2
Similar to D94907 (llvm-nm -D). The output will match GNU objdump 2.37. Older versions don't use ` (version)` for undefined symbols. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D108097
2021-07-28[llvm] Replace LLVM_ATTRIBUTE_NORETURN with C++11 [[noreturn]]Fangrui Song1-4/+4
[[noreturn]] can be used since Oct 2016 when the minimum compiler requirement was bumped to GCC 4.8/MSVC 2015. Note: the definition of LLVM_ATTRIBUTE_NORETURN is kept for now.
2021-04-23llvm-objdump: refactor SourcePrinter into separate file. NFC.Tim Northover1-0/+10
Preparatory patch for MachO feature.
2021-04-20[llvm-objdump] Remove "No" prefixes on variablesNico Weber1-2/+2
...to remove double negation in the code. Requested in D100583. No behavior change. Differential Revision: https://reviews.llvm.org/D100849
2021-04-14[llvm-objdump] Switch command-line parsing from llvm::cl to OptTableNico Weber1-22/+21
This is similar to D83530, but for llvm-objdump. The motivation is the desire to add an `llvm-otool` symlink to llvm-objdump that behaves like macOS's `otool`, using the same technique the at llvm-objcopy uses to behave like `strip` (etc). This change for the most part preserves behavior. In some cases, it increases compatibility with GNU objdump a bit. For example, the long options now require two dashes, and the long options taking arguments for the most part now require a `=` in front of the value. Exceptions are flags where tests passed the value separately, for these the separate form is kept as an alias to the = form. The one-letter short form args are now joined or separate and long longer accept a =, which also matches GNU objdump. cl::opt<>s in libraries now have to be explicitly plumbed through. This patch does that for --x86-asm-syntax=, but there's hope that we can remove that again. Differential Revision: https://reviews.llvm.org/D100433
2021-03-24[llvm-objdump] Implement --prefix-strip optionVinicius Tinti1-0/+1
The option `--prefix-strip` is only used when `--prefix` is not empty. It removes N initial directories from absolute paths before adding the prefix. This matches GNU's objdump behavior. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D96679
2021-02-05[llvm-objdump] Fix missing first line of license in header fileJames Henderson1-0/+1
2021-01-07[llvm-objdump] Pass Twine by const reference instead of by value. NFCI.Simon Pilgrim1-2/+3
2020-10-16[llvm-objdump] Implement --prefix optionVinicius Tinti1-0/+1
The prefix given to --prefix will be added to GNU absolute paths when used with --source option (source interleaved with the disassembly). This matches GNU's objdump behavior. GNU and C++17 rules for absolute paths are different. Differential Revision: https://reviews.llvm.org/D85024 Fixes PR46368. Differential Revision: https://reviews.llvm.org/D85024
2020-05-30[llvm-objdump] Move llvm:: to llvm::objdump:: and qualifying definitions ↵Fangrui Song1-3/+1
with objdump:: Or adding `static`. Qualifying definitions with `objdump::` comforms to the coding standards https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions
2020-04-23[llvm-objdump][ELF][NFC] Create ELFDump.hHubert Tong1-9/+0
Summary: Continuing from D77285, the external interfaces implemented by `ELFDump.cpp` are now declared in `ELFDump.h` and moved into the `llvm::objdump` namespace. Externs defined in `ELFDump.cpp` that are unreferenced externally are also made static. Reviewers: jhenderson, MaskRay, DiggerLin, jasonliu, daltenty Reviewed By: jhenderson, MaskRay Subscribers: RKSimon, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78695
2020-04-22[llvm-objdump][XCOFF] Print more symbol info in relocationjasonliu1-0/+4
Summary: Print more symbol info in relocation printing when --symbol-description is specified. Differential Revision: https://reviews.llvm.org/D78499
2020-04-14[llvm-objdump][Wasm][NFC] Create WasmDump.hHubert Tong1-4/+0
Summary: Continuing from D77285, the external interfaces implemented by `WasmDump.cpp` are now declared in `WasmDump.h` and moved into the `llvm::objdump` namespace. Reviewers: jhenderson, MaskRay, DiggerLin, jasonliu, daltenty Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D77990
2020-04-09[llvm-objdump][NFC] MachODump.cpp interface cleanupHubert Tong1-19/+4
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-06[llvm-objdump][NFC] Declare command-line externs in headers with namespaceHubert Tong1-1/+22
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-4/+0
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] Teach `llvm-objdump` dump dynamic symbols.vgxbj1-1/+5
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-9/+0
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/+4
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
2019-10-17Reland [llvm-objdump] Use a counter for llvm-objdump -h instead of the ↵Jordan Rupprecht1-1/+13
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-13/+1
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-1/+13
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-08-27[llvm-objdump] - Remove one overload of reportError. NFCI.George Rimar1-4/+3
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-9/+6
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-3/+3
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-1/+1
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-05Revert "[llvm-objdump] Re-commit r367284."Michael Pozulp1-1/+1
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
2019-08-04[llvm-objdump] Re-commit r367284.Michael Pozulp1-1/+1
Add warning messages if disassembly + source for problematic inputs Summary: Addresses https://bugs.llvm.org/show_bug.cgi?id=41905 Reviewers: jhenderson, rupprecht, grimar Reviewed By: jhenderson, grimar Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62462 llvm-svn: 367776
2019-07-30Revert "[llvm-objdump] Add warning messages if disassembly + source for ↵Michael Pozulp1-1/+1
problematic inputs" This reverts r367284 (git commit b1cbe51bdf44098c74f5c74b7bcd8c041a7c6772). My changes to LLVMSymbolizer caused a test to fail: http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/29488 llvm-svn: 367286
2019-07-30[llvm-objdump] Add warning messages if disassembly + source for problematic ↵Michael Pozulp1-1/+1
inputs Summary: Addresses https://bugs.llvm.org/show_bug.cgi?id=41905 Reviewers: jhenderson, rupprecht, grimar Reviewed By: jhenderson, grimar Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62462 llvm-svn: 367284
2019-04-15[llvm-objdump] Delete unused forward declarationsFangrui Song1-2/+0
llvm-svn: 358416
2019-04-15[llvm-objdump] Reorganize cl::opt variables and move Mach-O specifics to ↵Fangrui Song1-38/+0
MachODump.cpp llvm-svn: 358415
2019-04-09[llvm-objdump] Migrate some functions from std::error_code to ErrorFangrui Song1-1/+0
llvm-svn: 357965