Skip to content

[llvm-objdump][BPF] --symbolize-operands: infer local labels for BPF #100550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions llvm/test/tools/llvm-objdump/BPF/disassemble-symbolize-operands.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# REQUIRES: bpf-registered-target

## Verify generation of 'Lxx' labels for local jump targets, when
## --symbolize-operands option is specified.

# RUN: llvm-mc -triple=bpfel %s -filetype=obj -o %t
# RUN: llvm-objdump -d --symbolize-operands --no-show-raw-insn --no-leading-addr %t | \
# RUN: FileCheck %s
.text
main:
if r1 > 42 goto +2
r1 -= 10
goto -3
r0 = 0
exit

# CHECK: <main>:
# CHECK-NEXT: <L1>:
# CHECK-NEXT: if r1 > 0x2a goto +0x2 <L0>
# CHECK-NEXT: r1 -= 0xa
# CHECK-NEXT: goto -0x3 <main>
# CHECK-NEXT: <L0>:
# CHECK-NEXT: r0 = 0x0
# CHECK-NEXT: exit
6 changes: 4 additions & 2 deletions llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,11 @@ collectLocalBranchTargets(ArrayRef<uint8_t> Bytes, MCInstrAnalysis *MIA,
const MCSubtargetInfo *STI, uint64_t SectionAddr,
uint64_t Start, uint64_t End,
std::unordered_map<uint64_t, std::string> &Labels) {
// So far only supports PowerPC and X86.
// Supported by certain targets.
const bool isPPC = STI->getTargetTriple().isPPC();
if (!isPPC && !STI->getTargetTriple().isX86())
const bool isX86 = STI->getTargetTriple().isX86();
const bool isBPF = STI->getTargetTriple().isBPF();
if (!isPPC && !isX86 && !isBPF)
return;

if (MIA)
Expand Down
Loading