I create a DLL using a custom build system (outside of Visual Studio), and I cannot get uninitialized data to display in the .bss section; the compiler inserts it into .data . This inflates the final binary size as it is filled with gigantic arrays of zeros.
For example (small arrays of 1 KB in the example, but the actual buffers are much larger):
int uninitialized[1024]; int initialized[1024] = { 123 };
The compiler builds as follows:
PUBLIC _initialized _DATA SEGMENT COMM _uninitialized:DWORD:0400H _initialized DD 07bH ORG $+4092 _DATA ENDS
The end ends in the object file as follows:
SECTION HEADER #3 .data name 0 physical address 0 virtual address 1000 size of raw data 147 file pointer to raw data (00000147 to 00001146) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers C0400040 flags Initialized Data 8 byte align Read Write
(the .bss section is missing.)
Current compilation flags:
cl -nologo -c -FAsc -Faobjs\ -W4 -WX -X -J -EHs-c- -GR- -Gy -GS- -O1 -Os -Foobjs\file.o file.cpp
I looked through the list of options http://msdn.microsoft.com/en-us/library/fwkeyyhe(v=vs.71).aspx , but I did not notice anything obvious.
I am using the compiler from Visual Studio 2008 Service Pack 1 (Microsoft (R) 32-bit optimizer for the C / C ++ compiler version 15.00.30729.01 for 80x86).
Daniel Verkamp
source share