[Windows_internals] memory layout (virtual address space of a C process) under Linux OS

Source: Internet
Author: User

I found a good example to demostrate the memory layout and its stack info of a user-mode process, only that this example is for Linux. But it is still worth taking a look at it.

 

C source file is quite simple:

Void func (int x, int y) <br/>{< br/> int A; <br/> int B [3]; <br/>/* No other auto variable */<br/>... <br/>}< br/> void main () <br/>{< br/>... <br/> func (); <br/>... <br/>}

 

Memory layout is as below. I will talk about the stack in the next session.

 

The dimo-below shows the memory layout
A typical
C's process. The process load segments (corresponding"
Text
"And"
Data

"
At the process's base address. The main stack is located
Just
Below and grows downwards. Any additional threads that are created will
Have
Their own stacks, located below the main stack. Each of the stack Frames
Is
Separated by a guard page to detect stack overflows among stacks frame.
The
Heap is located above the process and grows upwards.

In the middle of the process's address
Space, there
Is a region is reserved for shared objects. When a new process is
Created,
The Process Manager first maps the two segments from the executable
Memory.
It then decodes the program's elf header. If the program Header
Indicates that
The executable was linked against a shared library, the Process Manager
Will
Extract the name of the dynamic interpreter from the program header.
Dynamic
Interpreter points to a shared library that contains the runtime linker
Code.
The Process Manager will load this shared library in memory and will
Then pass
Control to the runtime linker code in this library.


Ref:

Http://www.cs.uleth.ca /~ Holzmann/C/system/memorylayouttasks

Http://www.tenouk.com/Bufferoverflowc/Bufferoverflow1c.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.