This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: .data and .bss section
- From: Mike Stump <mrs at apple dot com>
- To: mohanlal jangir <mohanlaljangir at hotmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 28 Mar 2006 10:30:16 -0800
- Subject: Re: .data and .bss section
- References: <BAY18-DAV6FFE0DB063BEBB6A7ED90D2D30@phx.gbl>
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.