Re: executable segments -data,text.stack
From: Arto Viitanen (av_at_cs.uta.fi)
Date: 12/27/04
- Next message: Christian: "Get host name from IP address"
- Previous message: sachin_mzn_at_yahoo.com: "executable segments -data,text.stack"
- In reply to: sachin_mzn_at_yahoo.com: "executable segments -data,text.stack"
- Next in thread: sachin_mzn_at_yahoo.com: "Re: executable segments -data,text.stack"
- Reply: sachin_mzn_at_yahoo.com: "Re: executable segments -data,text.stack"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 27 Dec 2004 13:44:36 +0200
>>>>> "sachin" == sachin mzn <sachin_mzn@yahoo.com> writes:
sachin> Hi, I am little confused about the different segments in an
sachin> executable.
sachin> I know that there are primarily 3 segment, text, data and stack.
sachin> I know all local varibales goes into stack.
sachin> But I am confused that what goes into text and data segment.
sachin> Many say machine instruction goes into text. Can some one clarify me
sachin> what is it?
sachin> do global functions go into text segment? If it is true then what
sachin> about local variables declared in global function, will they go into
sachin> text ot stack segment?
sachin> Regards, Sachin
Modern von Neumann computers use memory for both running program and data it
uses. Virtual memory is a way to make a) use more programs than fit together
on to the computer's memory and b) use programs that use more memory than
what computer's memory is. There are two main ways to implement virtual
memory: segmented memory and paged memory. In segmented memory, program is
divided to different segments, that can be load to memory when needed. In
paged memory, the memory is divided to small portions called page, that can
be loaded one at the time (and in different parts of the memory). Actually,
modern Unix systems use paged segmented memory.
Program file is an image of the program to be run on the memory. It is
divided to different segments. Text segment contains the program code to be
run. If program uses dynamic libraries, when the program is loaded to be run,
libraries it refers are also loaded. The data program will be using is
divided into two segments: data and stack. Data contains global variables
(and their default variables), constants etc. Also dynamically allocated
memory (links etc.) is on the data segment. Stack is a segment that is
actually only in running program (that is on program file there is no stack)
and it will contain local variables that are not allocated to registers,
function parameters that are not allocated to registers etc.
Reason for three segments is, that first in the memory space is text, since
it size is known. Then there is data, which is growing upwards. Stack is on
the other size of the memory space (2^word size) and it is growing downwards.
Normally text segment is marked readonly, since there is no need to change
running program. Because of this, text segment might be shared between
several instances of the running program (they are called processes).
-- Arto V. Viitanen av@cs.uta.fi University of Tampere, Department of Computer Sciences Tampere, Finland http://www.cs.uta.fi/~av/
- Next message: Christian: "Get host name from IP address"
- Previous message: sachin_mzn_at_yahoo.com: "executable segments -data,text.stack"
- In reply to: sachin_mzn_at_yahoo.com: "executable segments -data,text.stack"
- Next in thread: sachin_mzn_at_yahoo.com: "Re: executable segments -data,text.stack"
- Reply: sachin_mzn_at_yahoo.com: "Re: executable segments -data,text.stack"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|