Why is .bss so big?

David Daney ddaney@avtrex.com
Sun Jan 29 20:38:00 GMT 2006


Anthony Green wrote:
> I've just had a quick look at some .jar.so files and I don't understand
> something.
> 
> For instance, if I look at gnu-crypto-2.0.1.jar.so, built with gcj 4.1
> in FC rawhide, size tells me that .bss is 55136 bytes.
> 
> However, objdump only tells me about 312 symbols in .bss, virtually all
> of which are only 4 bytes large.  There are only two symbols larger, and
> they're both 8 bytes.
> 
> So why is .bss so large?
> 

All uninitialized static variables of fundamental type are in .bss.  I 
think all static references (initialized or not) are there also.  Only 
non-private statics will have exported symbols in the final .so, so if 
there were a lot of private statics, they would not be shown by objdump.

I would try compiling the jar file with -S -funit-at-a-time and look at 
the assembly language to see if there are things in .bss that are not 
static variables.  For some simple classes I have been looking at, only 
static variables end up in .bss.

You could also try examining the .so with readelf -e and see if there 
are sections other than .bss of type NOBITS that would be reported as 
.bss by size.


David Daney




More information about the Java mailing list