The File /proc/PID/maps shows a memory map of the process with PID.(on linux/unix(r)) systems
lets write a program which enters loop and doesn't terminate.
we'll see its memory layout
chaos@sheikhchillip:/mnt/e/builds/assembly$ uname -r
4.4.0-18362-Microsoft
chaos@sheikhchillip:/mnt/e/builds/assembly$ nasm -v
NASM version 2.14
chaos@sheikhchillip:/mnt/e/builds/assembly$ ld -v
GNU ld (GNU Binutils for Debian) 2.31.1
chaos@sheikhchillip:/mnt/e/builds/assembly$
enough about current system used to build.
*/********************************************************/*
section .data
correct: dq -1
section .text
global _start
_start:
jmp _start
*/********************************************************/*
;chaos@sheikhchillip:/mnt/e/builds/assembly$ nasm -felf64 mappings_loop.asm -o mappings.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ls
;endianness.asm hello2.o hello.o mappings.o risc_cisc.asm strlen2 strlen.asm
;hello hello3 loader_start32.asm print_call.asm smpgdt.asm strlen2.asm strlen.o
;hello2 hello3.o mappings_loop.asm print_rax.asm strlen strlen2.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ld -o mappings mappings.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ls
;endianness.asm hello2.o hello.o mappings_loop.asm print_rax.asm strlen strlen2.o
;hello hello3 loader_start32.asm mappings.o risc_cisc.asm strlen2 strlen.asm
;hello2 hello3.o mappings print_call.asm smpgdt.asm strlen2.asm strlen.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ./mappings & [& is neccessary because otherwise shell might enter program loop]
;[1] 348
;chaos@sheikhchillip:/mnt/e/builds/assembly$ cat /proc/348/maps
MemRegAddrRng Prms
;00400000-00401000 r--p 00000000 00:00 138053 /mnt/e/builds/assembly/mappings
;00401000-00402000 r-xp 00001000 00:00 138053 /mnt/e/builds/assembly/mappings
;00402000-00403000 rw-p 00002000 00:00 138053 /mnt/e/builds/assembly/mappings
;7ffff42b6000-7ffff4ab6000 rw-p 00000000 00:00 0 [stack]
;7ffff4e6d000-7ffff4e6e000 r-xp 00000000 00:00 0 [vdso]
So, Hence We can see the memorymap, which is useful in many cases.
lets write a program which enters loop and doesn't terminate.
we'll see its memory layout
chaos@sheikhchillip:/mnt/e/builds/assembly$ uname -r
4.4.0-18362-Microsoft
chaos@sheikhchillip:/mnt/e/builds/assembly$ nasm -v
NASM version 2.14
chaos@sheikhchillip:/mnt/e/builds/assembly$ ld -v
GNU ld (GNU Binutils for Debian) 2.31.1
chaos@sheikhchillip:/mnt/e/builds/assembly$
enough about current system used to build.
*/********************************************************/*
section .data
correct: dq -1
section .text
global _start
_start:
jmp _start
*/********************************************************/*
;chaos@sheikhchillip:/mnt/e/builds/assembly$ nasm -felf64 mappings_loop.asm -o mappings.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ls
;endianness.asm hello2.o hello.o mappings.o risc_cisc.asm strlen2 strlen.asm
;hello hello3 loader_start32.asm print_call.asm smpgdt.asm strlen2.asm strlen.o
;hello2 hello3.o mappings_loop.asm print_rax.asm strlen strlen2.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ld -o mappings mappings.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ls
;endianness.asm hello2.o hello.o mappings_loop.asm print_rax.asm strlen strlen2.o
;hello hello3 loader_start32.asm mappings.o risc_cisc.asm strlen2 strlen.asm
;hello2 hello3.o mappings print_call.asm smpgdt.asm strlen2.asm strlen.o
;chaos@sheikhchillip:/mnt/e/builds/assembly$ ./mappings & [& is neccessary because otherwise shell might enter program loop]
;[1] 348
;chaos@sheikhchillip:/mnt/e/builds/assembly$ cat /proc/348/maps
MemRegAddrRng Prms
;00400000-00401000 r--p 00000000 00:00 138053 /mnt/e/builds/assembly/mappings
;00401000-00402000 r-xp 00001000 00:00 138053 /mnt/e/builds/assembly/mappings
;00402000-00403000 rw-p 00002000 00:00 138053 /mnt/e/builds/assembly/mappings
;7ffff42b6000-7ffff4ab6000 rw-p 00000000 00:00 0 [stack]
;7ffff4e6d000-7ffff4e6e000 r-xp 00000000 00:00 0 [vdso]
So, Hence We can see the memorymap, which is useful in many cases.
0 comments :
Post a Comment