This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: .data and .bss section


On Mar 27, 2006, at 11:39 PM, mohanlal jangir wrote:
Why does gcc put initialized data in .data section and uninitialized data in bss section? Does it provide any optimization? Also, normally gcc initializes global data to zero then what kinds of data go to .bass section? An example would be appreciated.

This question is off-topic for this list. You want a book on UNIX or google around, or just try it out and observe the results. The answers are roughly, optimization, yes, global data that is zero. int i; in C++ is an example. As to why this is advantageous, try int i[100000000]; in C++ and compare to int i[100000] = { 1 };. If you don't see an advantage, add another 0.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]