How can I examine contents of a data section of an ELF file on Linux?

Norman Ramsey picture Norman Ramsey · Nov 6, 2009 · Viewed 97.3k times · Source

I've been using objdump to look at assembly code in Linux ELF binaries.

Sometimes there is an indirect jump through a jump table that is stored in the rodata (read-only data) section.

How to get objdump or any other tool to show me the contents of this data section?

I could execute the program and examine the relevant addresses in the debugger, but I don't want to do that because it has to be done interactively.

The ideal answer will identify a tool that will not only show me the contents but will let me control the display format, much as od does.

Answer

hobbs picture hobbs · Nov 6, 2009
objdump -s -j .rodata exefile

gives a side-by-side hex/printable ASCII dump of the contents of the rodata section like:

Contents of section .rodata:
 0000 67452301 efcdab89 67452301 efcdab89  gE#.....gE#.....
 0010 64636261 68676665 64636261 68676665  dcbahgfedcbahgfe

It doesn't look like there's anything in there to control formatting, but it's a start. You could always undump the hex and feed it to od, I suppose :)