je****@gmail.com wrote:
hi all,
can any one give me some explanation of "wat is .bss segment in object
file" and what it will contain and difference between data segment
and .bss segment....
Neither "bss segments" nor "data segments" have anything to do with C. They
are both terms relating to the mechanics of compiling and loading programs in
specific environments.
Typically, a "data segment" is the part of the object module that contains
initialized static data (in C, initialized static variables, string constants,
and other stuff like that), while the "bss segment" ("Block Started by
Symbol") defines the space for unitialized static data.
For example
int main(void)
{
static char abc[12], /* located in BSS segment */
def[] = "1"; /* located in DATA segment */
static int seven; /* located in BSS segment */
static float pi = 3.14159; /* located in DATA segment */
int two = 3; /* not in BSS nor DATA */
strcpy(abc /* as above */,
"Test" /* located in DATA segment */
);
return 0;
}
HTH
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------