Latest News
Wednesday, 7 January 2015

Memory Managment

Understanding of modern memory management is very important specifically for the Intel Architecture, 32 Bit (IA32)

Understanding of how memory is managed because most security holes come from 'overwriting' or 'overflowing' one portion of memory into another. 

Also, Understanding memory management concepts will help you better comprehend the assembly programming language, you will use to manipulate them.


When a program is executed, it is laid out in an organized manner—various elements of the program are mapped into memory.First, the operating system
creates an address space in which the program will run. This address space includes the actual program instructions as well as any required data.
Next, information is loaded from the program’s executable file to the newly created address space. 

There are three types of segments: 
.text 
.bss
.data

.text:
The .text segment is mapped as read-only whereas .data and .bss are writable. 

.data and .bss:
The .data and .bss segments are reserved for global variables. The .data segment contains static initialized data,
and the .bss segment contains uninitialized data. The final segment, .text holds the program instructions.Finally, the stack and the heap are initialized. 

Stack:
The stack is a data structure,more specifically a "Last In First Out (LIFO)" data structure, which means that the most recent data placed
onto the stack is the next item to be removed from the stack. A LIFO data structure is ideal for storing transitory information, or information that 
does not need to be stored for a lengthy period of time. The stack stores local variables, information relating to
function calls, and other information used to clean up the stack after a function or procedure is called.
Another important feature of the stack is that it grows down the address space: as more data is added to the stack, it is added at increasingly lower
address values.

Heap: 
The heap is another data structure used to hold program information, more specifically, dynamic variables. The heap is a "First In First Out (FIFO)" data 
structure. Data is placed and removed from the heap as it builds. The heap grows up the address space: As data is added to the heap, it is added at an 
increasingly higher address value.


memory space diagram:

↑ Lower addresses (0x08000000)
Shared libraries
.text
.bss
Heap (grows ↓)
Stack (grows ↑)
env pointer
Argc
↓ Higher addresses (0xbfffffff)

We recognised you to Go to http://linux-mm.org/ for more detailed information on memory management on Linux.

  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Don't spam :)

Item Reviewed: Memory Managment Rating: 5 Reviewed By: Unknown