Quote:
Originally Posted by MrUser
Hi,
is there any command to see symbol table info.
will it show where its allocating memory for varibales golbals & locals and code.(i mean the segments).
|
Try using nm or odump for that.
Quote:
Originally Posted by MrUser
i read there is a section called read only data segment and this is where initialized data such as strings stores.
|
If you use gdb to get the address of the string literal you will find that it is in the address range of the text segment which is readonly.
Quote:
Originally Posted by MrUser
i have wriiten the following program and its giving segmentation for strings but not others.
any idea whats the proper reason.
Code:
char *p="test";
int g=10;
int main()
{
g=20;// no segmentation
printf("%d",g);
getchar();
*p='T';// generates segmentation
printf("%s",p);
return 0;
}
thanks in advnace
|
A string literal cannot be modified since it is stored in the text segment which is shared and readonly.