[PATCH] D131589: [llvm-objdump] Handle multiple syms at same addr in disassembly.

Simon Tatham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 10 09:28:04 PDT 2022


simon_tatham created this revision.
simon_tatham added reviewers: scott.linder, jhenderson, aardappel, rochauha, sbc100, dschuff, rafauler.
Herald added a subscriber: rupprecht.
Herald added a reviewer: MaskRay.
Herald added a project: All.
simon_tatham requested review of this revision.
Herald added subscribers: llvm-commits, StephenFan, aheejin.
Herald added a project: LLVM.

The main disassembly loop in llvm-objdump works by iterating through
the symbols in a code section, and for each one, dumping the range of
the section from that symbol to the next. If there's another symbol
defined at the same location, then that range will have length 0, and
llvm-objdump will skip over the symbol entirely.

As a result, llvm-objdump will only show the last of the symbols
defined at that address. Not only that, but the other symbols won't
even be checked against the `--disassemble-symbol` list. So if you
have two symbols `foo` and `bar` defined in the same place, then one
of `--disassemble-symbol=foo` and `--disassemble-symbol=bar` will
generate an error message and no disassembly.

I think a better approach in that situation is to prioritise display
of the symbol the user actually asked for. Also, if the user
specifically asks for disassembly of //both// of two symbols defined
at the same address, the best response I can think of is to
disassemble the code once, preceded by both symbol names.

This involves teaching llvm-objdump to be able to display more than
one symbol name at the head of a disassembled section, which also
makes it possible to implement a `--show-all-symbols` option to
display //every// symbol defined in the code, not just the most
preferred one at each address.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131589

Files:
  llvm/test/tools/llvm-objdump/multiple-symbols.test
  llvm/tools/llvm-objdump/ObjdumpOpts.td
  llvm/tools/llvm-objdump/llvm-objdump.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131589.451520.patch
Type: text/x-patch
Size: 19566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220810/b5e3558f/attachment.bin>


More information about the llvm-commits mailing list