On Fri, Jun 06, 2025 at 05:34:27PM +0200, Alexandre Chartre wrote:
Hi,
This RFC provides two changes to objtool.
- Disassemble code with libopcodes instead of running objdump
objtool executes the objdump command to disassemble code. In particular,
if objtool fails to validate a function then it will use objdump to
disassemble the entire file which is not very helpful when processing
a large file (like vmlinux.o).
Using libopcodes provides more control about the disassembly scope and
output, and it is possible to disassemble a single instruction or
a single function. Now when objtool fails to validate a function it
will disassemble that single function instead of disassembling the
entire file.
Ah, nice to get rid of that awful objdump hack.
- Add the --trace <function> option to trace function validation
Figuring out why a function validation has failed can be difficult because
objtool checks all code flows (including alternatives) and maintains
instructions states (in particular call frame information).
The trace option allows to follow the function validation done by objtool
instruction per instruction, see what objtool is doing and get function
validation information. An output example is shown below.
This is pretty freaking awesome!
I assume we could eventually build on this work to have an "objtool
disas" subcommand, which would basically be an improved "objdump -d"
which annotates alternatives and other runtime patching.