Search code examples
linux-kernelbinaryfilesdisassembly

Memory addresses in the system.map and vmlinux.o (after building Linux kernel), Do they correspond to each other?


Do memory addresses in system.map and vmlinux.o correspond to each other? For example, Here is a part of the system.map file

c03011ec T handle_fiq_as_nmi
c0301270 T do_IPI
c0301274 T do_DataAbort
c0301328 T do_PrefetchAbort

And here is a part of the disassembled file for vmlinux.o.

000001ec <handle_fiq_as_nmi>:
 1ec:   e92d4038    push    {r3, r4, r5, lr}
 1f0:   e3004000    movw    r4, #0
 1f4:   ee1d3f90    mrc 15, 0, r3, cr13, cr0, {4}
 1f8:   e3404000    movt    r4, #0
 1fc:   e7935004    ldr r5, [r3, r4]

Why there are two different addresses for handle_fiq_as_nmi?


Solution

  • vmlinux.o is a relocatable file, not executable file.

    Use file vmlinux.o to see its type, or more detailed readelf -h vmlinux.o

    Relocatable files need to be linked together to produce a final executable ( like a.out, for your case it's vmlinux ).

    The address in a relocatable file is not the final address, they will be relocated during linking. See linking, ELF format. The addresses in System.map are the final one.