Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- task_struct
- | ---pmd /-pte->page
- | / /
- mm_struct ----> pgd----pmd---pte->page
- / | \ \
- / | \ ---pmd
- / | \
- / | \
- vm_area_struct-->vm_area_struct-->vm_area_struct
- | |
- | |
- struct file struct file
- / | \
- / | \
- / | \
- page-->page-->page
- The kernal maintains additional information on each memory address that is mapped by a process. Each process is assigned a struct mm_struct pointed to by the task_struct.
- struct mm_struct {
- struct vm_area_struct * mmap;
- rb_root_t mm_rb;
- struct vm_area_struct * mmap_cache;
- pgd_t * pgd;
- atomic_t mm_users;
- atomic_t mm_count;
- int map_count;
- struct rw_semaphore mmap_sem;
- spinlock_t page_table_lock;
- struct list_head mmlist;
- unsigned long start_code, end_code, start_data, end_data;
- unsigned long start_brk, brk, start_stack;
- unsigned long arg_start, arg_end, env_start, env_end;
- unsigned long rss, total_vm, locked_vm;
- unsigned long def_flags;
- unsigned long cpu_vm_mask;
- unsigned long swap_address;
- unsigned dumpable:1;
- mm_context_t context;
- };
- The vm_area_structs refer to a block of memory in the address space that is been used.
- Text Code and initialised data from the executable itself. Starts at 0x08040000
- Heap Uninitialised data and the heap starting after text
- Stack The stack. Grows down from __PAGE_OFFSET (default 0xC00000000)
- struct vm_area_struct {
- struct mm_struct * vm_mm;
- unsigned long vm_start;
- unsigned long vm_end;
- /* linked list of VM areas per task, sorted by address */
- struct vm_area_struct *vm_next;
- pgprot_t vm_page_prot;
- unsigned long vm_flags;
- rb_node_t vm_rb;
- struct vm_area_struct *vm_next_share;
- struct vm_area_struct **vm_pprev_share;
- struct vm_operations_struct * vm_ops;
- /* Information about our backing store: */
- unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZE
- units, *not* PAGE_CACHE_SIZE */
- struct file * vm_file; /* File we map to (can be NULL). */
- unsigned long vm_raend; /* XXX: put full readahead info here. */
- void * vm_private_data; /* was vm_pte (shared mem) */
- };
- 110 * vm_flags in vm_area_struct, see mm_types.h.
- 111 */
- 112 #define VM_NONE 0x00000000
- 113
- 114 #define VM_READ 0x00000001 /* currently active flags */
- 115 #define VM_WRITE 0x00000002
- 116 #define VM_EXEC 0x00000004
- 117 #define VM_SHARED 0x00000008
- snippet address space
- 08048000-0804e000 r-xp 00000000 03:01 64652 /sbin/init text
- 0804e000-0804f000 rw-p 00006000 03:01 64652 /sbin/init data
- 0804f000-08053000 rwxp 00000000 00:00 0 zero-mapped BSS
- 40000000-40015000 r-xp 00000000 03:01 96278 /lib/ld-2.3.2.so text
- 40015000-40016000 rw-p 00014000 03:01 96278 /lib/ld-2.3.2.so data
- 40016000-40017000 rw-p 00000000 00:00 0 BSS for ld.so
- 42000000-4212e000 r-xp 00000000 03:01 80290 /lib/tls/libc-2.3.2.so text
- 4212e000-42131000 rw-p 0012e000 03:01 80290 /lib/tls/libc-2.3.2.so data
- 42131000-42133000 rw-p 00000000 00:00 0 BSS for libc
- bffff000-c0000000 rwxp 00000000 00:00 0 Stack segment
- ffffe000-fffff000 ---p 00000000 00:00 0 vsyscall page
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement