FranXh
FranXh

Reputation: 4771

Linux memory map regions to store procedures

I have a question asking me to explain in what regions of a linux memory map a procedure is stored. The question instructs me to use objdump -h to find this information.

Now, I am a little bit confused what "regions in memory" means.

I know that for a given procedure we have certain register that we work with (say %eax, %edx...) and also for each variable we have a memory location it is stored in (say 8(%ebp)). In addition I know that we have the %esp and %ebp registers to "take care" of the stack.

I also run objdump -h on my file but from what I get I cannot tell anything specific.

So should I just mention the registers being used and the memory addresses where the variables of this procedure are being stored?

Upvotes: 1

Views: 241

Answers (2)

Gunner
Gunner

Reputation: 5884

You could easily do a internet search for linux memory map, after all it is your homework and you would learn how to problem solve and do research.

Each program has certain segments, here are a few: bss - uninitialized data data - initialized data (strings, arrays etc...) text - code "procedures"

Sections are relevant to the start address of the program, with positive or negative offsets.

Here is a good page: http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory

Upvotes: 0

Jason
Jason

Reputation: 32520

I believe your question is asking where the linker has designated your actual code to reside in memory when it's loaded by the operating system. This area of code would be represented by the program counter register, or %EIP on x86.

Typically on Linux, program code as well as read-only variables are stored in the lower regions of mapped memory for the process, with the stack in the upper regions (i.e., the stack grows down).

Upvotes: 3

Related Questions