Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WINAPI C/C++ -> why did the binary size increase dramatically ? (Switch from VS2013 to VS 2015)

Even though I know I will probably get bashed for asking this question I'll still go ahead and ask it since it literally drives me nuts. I'm hoping maybe one of you has some insight on the matter.

Compiling MS's WIN32 default ('non-empty' setting) project on VS2013 yields a binary size~16kb. Compiling the same project on VS2015 Update3 yields a binary size~105kb (more than 6x as large!).

I double and triple checked the final command line parameters passed to cl.exe and link.exe and they appear identical (project settings). Even changes in the project settings - favor size over speed - don't help (binary still 105kb). What the heck is going here ? I even installed VS2015 on a second computer in order to rule out a 'defective' installation - same results (105kb). Reaching out for help since I'm done at this point.

like image 360
PIp3dr3am Avatar asked Dec 29 '16 20:12

PIp3dr3am


1 Answers

I don't have VS 2013 installed at the moment, but I just did a quick test comparing VS 2010 and VS 2015. In each version, I created a "Win32 Project" (Windows Application, Non-Empty, No ATL, No MFC). The resulting file sizes for the 32-bit Release build are:

VS 2010: 57,344
VS 2015: 104,448

Running dumpbin /headers on both executables shows slight differences in the code size, but the main difference seems to be the resources:

VS 2010 .rsrc size: 0xC200 (about 49K)
VS 2015 .rsrc size: 0x17200 (about 92K)

Upon closer inspection, the icon resources in the VS2015 version have more alternatives (different sizes, different bit depths). So that appears to be the bulk of the size difference in my test case.

EDIT: Comparison of executable size broken down by PE section:

+---------+-----------------+-----------------+-------+
| Section |     VS 2010     |     VS 2015     | Change|
|         | (hex)  | (dec)  | (hex)  | (dec)  | (dec) |
+---------+--------+--------+--------+--------+-------+
| .text   | 0xC00  | 3072   | 0x1000 | 4096   |  1024 |
| .rdata  | 0x800  | 2048   | 0xC00  | 3072   |  1024 |
| .data   | 0x200  | 512    | 0x200  | 512    |     0 |
| .rsrc   | 0xC200 | 49664  | 0x17200| 94720  | 45056 |
| .reloc  | 0x400  | 1024   | 0x200  | 512    |  -512 |
| .gfids  | n/a    | n/a    | 0x200  | 512    |   512 |
+---------+--------+--------+--------+--------+-------+
                                        Total | 47104 |

So, when you exclude .rsrc, the total difference is 2K.

like image 62
cbranch Avatar answered Oct 25 '22 20:10

cbranch