Data, store data
Text, store code
"Santa" <santa1...@yahoo.com>
??????:60e37826.04010...@posting.google.com...
Hi,
There are 3 (main?) segments/sections of the file produced
by a linker.
text - program text (and apparently const char arrays. maybe
other 'const' arrays, since those can not be changed
anyway). I am not 100% sure about the array part, maybe
someone will correct me.
data - initialized global data. see examples below.
bss - uninitialized global data.
Here are some examples
--------------------------------------------------------
int x = 1; /* goes into data */
int y; /* goes into bss */
/* i think this would also end up in text, but maybe data. I
* am not sure */
const int z = 1;
/* this, we've seen go into 'text',
* since can't be changed anyway,
* but can be protected */
const char array[] = {'a','b'....etc}
/* the rest goes into text */
int
main(void)
{
return EXIT_SUCCESS;
}
--------------------------------------------------------
Here is some more info on where name BSS might've come from.
*****
Block Started by Symbol
(BSS) The uninitialised data segment produced by Unix
linkers. The other segments are the "text" segment which
contains the program code and the "data" segment contains
initialised data. Objects in the bss segment have only a
name and a size but no value.
*****
>From the UNIX FAQ,
BSS = "Block Started by Symbol"
Dennis Ritchie says:
Actually the acronym (in the sense we took it up; it may
have other credible etymologies) is "Block Started by
Symbol." It was a pseudo-op in FAP (Fortran Assembly [-er?]
Program), an assembler for the IBM 704-709-7090-7094
machines. It defined its label and set aside space for a
given number of words. There was another pseudo-op, BES,
"Block Ended by Symbol" that did the same except that the
label was defined by the last assigned word + 1. (On these
machines Fortran arrays were stored backwards in storage and
were 1-origin.)
The usage is reasonably appropriate, because just as with
standard Unix loaders, the space assigned didn't have to be
punched literally into the object deck but was represented
by a count somewhere.
****
The acronym BSS refers to the run-time uninitialized data
area and that the acronym has historical origins.
*****
from "Expert C Programming"
The BSS segment gets its name from abbrevbiating "Block
Started by Symbol" -- a pseudo-op from the old IBM 704
assembler, carried over into UNIX, and there ever since.
Some people like to remember it as "Better Save Space".
SInce the BSS segment only holds variables that don't have
any value yet, it doesn't actually need to store the image
of these variables. The size that BSS will require at
runtime is recorded in the object file, but BSS (unlike the
data segment) does not take up any actual space
--------------------------------------------------------
Gabi
Every process consists of basically 4 portions of address space that are
accessible to the process
when it is running
Text - This portion contains the actual m/c instructions to be
executed. On many Operating Systems this is set to read only, so that the
process can't modify its instructions. This allows multiple instances of
the program to share the single copy of the text.
Data - This portion contains the program's data part. It furthere
divided into
1) Initialized Read Only Data - This contains the data elements
that are initialized by the program and they are read only during the
execution of the process.
2) Initialized Read Write Data - This contains the data elements
that are initialized by the program and will be modified in the course of
process execution.
3)Uninitalized Data - This contains the elements are not
initialized by the program and are set 0 before the processes executes.
These can also be modified and referred as BSS(Block Started Symbol). The
adv of such elements are, system doesn't have to allocate space in the
program file for this area, b'coz it is initialized to 0 by OS before the
process begins to execute.
Stack - This portion is used for local variables, stack frames
Heap - This portion contains the dynamically allocated memory
Example ::
int abc = 1; ----> Initialized Read-Write Data
char *str; ----> BSS
const int i = 10; -----> Initialized Read-Only Data
main()
{
int ii,a=1,b=2,c; -----> Local Variables on
Stack
char *ptr;
ptr = malloc(4); ------> Allocated Memory in Heap
c= a+b; ------> Text
}
Regards
Kalpana
>_______________________________________________
>VxWorks Users Group mailing list
>VxWe...@lbl.gov
>http://www-csg.lbl.gov/vxworks/
Yi
They are supposed to be automatically set. Note, however, that you
have to specify how much stack space you want when you spawn
a task, and that you must never exceed that amount. Most
probably, you have a memory leak.
Speaking only for myself,
Joe Durusau