I need to disassemble /proc/kcore
file in Linux and I need to obtain virtual addresses of some special instructions to put kprobes
later on it. According to this document /proc/kcore
is an image of physical memory, but in this question someone answered that it is kernel's virtual memory (exactly what I am looking for).
When I use objdump
tool to disassemble it, it starts with address something like f7c0b000
, but udis86 starts with 0x0 (and totally different instruction). When I try to grep
some specific instruction, let's say mov 0xf7c1d60c,%edx
, I got:
objdump
f7c0b022 mov 0xf7c1d60c,%edx
udis86
290ec02a mov 0xf7c1d60c,%edx
It looks like the offset between udis86
and objdump
is always 0xbffff000
. Why so strange offset? How can I obtain virtual address of specific instruction? Somewhere I've read, that kernel is statically mapped at virtual address 0xc0000000 + 0x100000. If /proc/kcore
is really physical image, is it correct only to add 0x100000 to addresses returned by objdump
and I will get virtual address?