c - Linux: How to find the physical address of an executable's .text, .data, etc -


i'm working on project , not making progress like.

my goal add code to, , recompile, linux kernel display physical address of kernel places various sections of executable, such .text , .data sections, heap , stack.

i understand how memory works, such virtual vs. physical memory, , uses pages , lookup tables translate between two, can't find where in actual code this.

fwiw, i'm working kernel version 2.6.32.67.

currently, i'm poking around in exec.c , using printk() print out data. example, output of mm_struct contained in struct linux_bprm *bprm struct (more specifically, in mm_struct of vm_area_struct.)

execing: ./test.out    bprm     vm_start:       0x7ffe7ed9b000     vm_end:         0x7ffe7edb1000     vm size:        0x16000  bprm->vma->vm_mm:     total_vm:       0x3c     locked_vm:      0x0     shared_vm:      0x24     exec_vm:        0x21     stack_vm:       0x16     reserved_vm:    0x0     start_code:     0x400000     end_code:       0x400744        code size:   0x744     start_data:     0x600748     end_data:       0x600938        data size:   0x1f0     start_brk:      0xc66000     brk:            0xc66000        brk size:    0x0     start_stack:    0x7ffe7edaeac0     arg_start:      0x7ffe7edb04c1     arg_end:        0x7ffe7edb04c9     env_start:      0x7ffe7edb04c9     env_end:        0x7ffe7edb0ff0 

from here, having trouble moving forward. have guidance? thanks.


Comments