Nils Goroll writes:
> > It's just a bit of arcana that designers and code reviewers sometimes
> > need to know about, like the difference between .data and .bss.  :-/
> 
> I'd like to make sure that I understand this issue.
> 
> Do you think that 
> http://stackoverflow.com/questions/610682/-bss-section-in-elf-file
> contains a good explanation?

Yes, it's buried in there.  .data contains initialized static storage
duration objects while .bss contains uninitialized ones.  .data is
present in the object file, while .bss is not.  If you've got a huge
static array somewhere, then this:

        static int bar[100000] = { 0 };

creates a huge resulting binary, while this:

        static int bar[100000];

does not, and yet they're functionally equivalent.  More subtly,
you'll find that objects in .data are usually not located near those
in .bss, so when debugging memory corruption, it can help to keep
track of which ones are which.

-- 
James Carlson, Solaris Networking              <james.d.carlson at sun.com>
Sun Microsystems / 35 Network Drive        71.232W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.496N   Fax +1 781 442 1677

Reply via email to