[Platform specific] About data segment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'd like to know where go global variables, constants and litteral strings, 
and what happens to them when the process is spawned

1) Are the litteral strings put in the same place than constant objects such 
as

const double PI = 3.14;

static const struct { int a; int b; } mytab [] = {
  {23, 52}, {23, 526}, {342, 1}};

?

2) Are those objects put in the same place than r/w global variables such as 

struct {
  char field1[43];
  char field2[52];
  int field4;
} myinfos;

static char * my_str = NULL;

int main () {
  static char mega_buffer[100000];
  /* ... */
}

?

3) What happens to the global constant objects when the process begins? When 
are they initialized?
5) What happens to the global variables, since they can be initialized too?
6) If i aim good performance for the system to load my programs, should i 
avoid too much global variables (such as my "static mega_buffer")? what 
about having a bunch of big litteral strings?


I work on Linux
Thank you !


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux