I've got a binary installed on my system, and would like to look at the disassembly of a given function. Preferrably using objdump
, but other solutions would be acceptable as well.
From this questions I've learned that I might be able to disassemble part of the code if I only know the boundary addresses. From this answer I've learned how to turn my split debug symbols back into a single file.
But even operating on that single file, and even disassembling all the code (i.e. without start or stop address, but plain -d
parameter to objdump
), I still don't see that symbol anywhere. Which makes sense insofar as the function in question is static, so it isn't exported. Nevertheless, valgrind
will report the function name, so it has to be stored somewhere.
Looking at the details of the debug sections, I find that name mentioned in the .debug_str
section, but I don't know a tool which can turn this into an address range.
Disassembling an ELF-formatted fileUse the --disassemble option to display a disassembled version of the image to stdout . If you use this option with the --output destination option, you can reassemble the output file with armasm. You can use this option to disassemble either an ELF image or an ELF object file.
Objdump command in Linux is used to provide thorough information on object files. This command is mainly used by the programmers who work on compilers, but still its a very handy tool for normal programmers also when it comes to debugging.
The objdump command is generally used to inspect the object files and binary files. It prints the different sections in object files, their virtual memory address, logical memory address, debug information, symbol table, and other pieces of information. Here we'll see how we can use this tool to disassemble the files.
I would suggest using gdb as the simplest approach. You can even do it as a one-liner, like:
gdb -batch -ex 'file /bin/ls' -ex 'disassemble main'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With