llvm / llvm/llvm-project

[llvm-objdump] --disassemble-symbols doesn't account for ELF symbol size

Open
#166,412 3 comments 0 reactions 0 assignees View on GitHub
enhancement tools:llvm-objdump
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Elf Symbols often have a specific size. This size (when nonzero) is not taken into account by `--disassemble-symbols=`

This makes it hard to disassemble a single function, if that function has e.g. local symbols. This can happen when disassembling a relocatable object. The disassembly will stop at the first local symbol, rather than disassembling the encoded size of the function.

Of course, if the size is zero, we have to treat the size as unknown, and stopping on the next symbol mostly makes sense - though I don't know whether we should take into account the symbol binding, and maybe skip local symbols.

This comment implies this is intended behaviour, but I think it would be better if it wasn't the behaviour

https://github.com/llvm/llvm-project/blob/0cdebdaf59d20f34158d97d193381e95a0ba90b0/llvm/tools/llvm-objdump/llvm-objdump.cpp#L2135-L2136

Contributor guide

Open the contributing guide

Research direction

Start in llvm/tools/llvm-objdump/llvm-objdump.cpp at lines 2135-2136 and inspect how --disassemble-symbols determines its stopping point. Reproduce the behavior with a relocatable object containing local symbols, then verify that a nonzero ELF symbol size is honored while the zero-size case follows an agreed stopping rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.