I have a
Windows tool that dumps data on global variables from PDBs and it reports on the size, name, and section of all globals. I look over the results occasionally and fix glitches. Doing it as a post-link process like this is advantageous because it detects cases that static analysis will miss. For instance, it found a large const array that was not in the read-only section because it was being initialized at run-time, so fixing that saved a lot of code as well as moving data to read-only. It also found a
VC++ compiler quirk that can easily force const data into the read-write section (which we worked around in the most important cases).
Another case this tool detects is duplicate variables. This happens when a static/const variable of non-integral type* is declared in a header file and the compiler generates multiple instances, potentially one per translation unit.
I think the low hanging fruit for these two inefficiencies are dealt with, but if somebody wanted to put in a build verification step to make sure things stay clean that would be great.
I've attached the reports for chrome.dll and chrome_child.dll from the latest 64-bit canary. The first section shows duplicated variables, with the second column being how many bytes are wasted. I just noticed that chrome_child.dll has two copies of ft_adobe_glyph_list which is wasting ~56 kB. This is because this array is defined in a header file. I guess I didn't fix it because it's in freetype so a bit more work.
Bruce
* Integral types declared as const in a header file generally don't cause storage to be allocated but if they have a constructor they sometimes do because software is hard