
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. This change also turns out to fix a bug in which `--disassemble-all` on a mixed Arm/Thumb ELF file would fail to switch disassembly states between Arm and Thumb functions, because the mapping symbols were accidentally ignored. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D131589
43 lines
1.4 KiB
ArmAsm
43 lines
1.4 KiB
ArmAsm
// This test demonstrates that the alphabetical-order tie breaking between
|
|
// multiple symbols defined at the same address is based on the raw symbol
|
|
// name, not its demangled version.
|
|
|
|
@ REQUIRES: arm-registered-target
|
|
|
|
@ RUN: llvm-mc -triple armv8a-unknown-linux -filetype=obj %s -o %t.o
|
|
|
|
// All the run lines below should generate some subset of this
|
|
// display, with different parts included:
|
|
|
|
@ COMMON: Disassembly of section .text:
|
|
@
|
|
@ RAW-B: 00000000 <_Z4bbbbv>:
|
|
@ NICE-B: 00000000 <bbbb()>:
|
|
@ NO-B-NOT: bbbb
|
|
@ A: 00000000 <aaaa>:
|
|
@ COMMON: 0: e0800080 add r0, r0, r0, lsl #1
|
|
@ COMMON: 4: e12fff1e bx lr
|
|
|
|
// The default disassembly chooses just the alphabetically later symbol, which
|
|
// is aaaa, because the leading _ on a mangled name sorts before lowercase
|
|
// ASCII.
|
|
|
|
@ RUN: llvm-objdump --triple armv8a -d %t.o | FileCheck --check-prefixes=COMMON,NO-B,A %s
|
|
|
|
// With the --show-all-symbols option, bbbb is also shown, in its raw form.
|
|
|
|
@ RUN: llvm-objdump --triple armv8a --show-all-symbols -d %t.o | FileCheck --check-prefixes=COMMON,RAW-B,A %s
|
|
|
|
// With --demangle as well, bbbb is demangled, but that doesn't change its
|
|
// place in the sorting order.
|
|
|
|
@ RUN: llvm-objdump --triple armv8a --show-all-symbols --demangle -d %t.o | FileCheck --check-prefixes=COMMON,NICE-B,A %s
|
|
|
|
.text
|
|
.globl aaaa
|
|
.globl _Z4bbbv
|
|
aaaa:
|
|
_Z4bbbbv:
|
|
add r0, r0, r0, lsl #1
|
|
bx lr
|