Whenever I build an Win32 EXE in release mode with C++ Builder (Version XE4, but previous versions do this also), it always creates an export directory and exports an Initialize/Finalize entry for every unit in my project. This leads to thousands of unnecessary exports. There is a similar issue with Win64 builds, but the exports generated are not as many.
A quick check with the dumpbin tool gives the following (abbreviated) output:
Section contains the following exports for PROJECTX.exe
00000000 characteristics
0 time date stamp Thu Jan 01 00:00:00 1970
0.00 version
1 ordinal base
1205 number of functions
1205 number of names
ordinal hint RVA name
1046 0 003ECF44 @$xp$13Gdipapi@INT16
1077 1 003ED64C @$xp$13Gdipapi@PARGB
1053 2 003ED0D4 @$xp$13Gdipapi@Unit_
1047 3 003ECF5C @$xp$14Gdipapi@UINT16
1049 4 003ECF88 @$xp$14Gdipapi@UINT32
...
261 E0 000BD758 @@Find@Finalize
260 E1 000BD748 @@Find@Initialize
153 E2 0007EE70 @@Flags@Finalize
152 E3 0007EE60 @@Flags@Initialize
...
My concern is apart from adding to the PE file size and loading time, these export entries provide metadata which could aid reverse engineering my binary and as such I would like to strip them out.
A hacky solution is to manually delete the PE images export directory after it is built, however there must be a solution for this from within the c++ builder IDE/compiler.
Why is C++ Builder doing this and how can I disable generating these export directory entries?
Update: Building an empty VCL Forms application in Win32 Release mode generates the following exports by default...
Section contains the following exports for Project1.exe
00000000 characteristics
0 time date stamp Thu Jan 01 00:00:00 1970
0.00 version
1 ordinal base
5 number of functions
5 number of names
ordinal hint RVA name
3 0 000036C8 @@Unit1@Finalize
2 1 000036B8 @@Unit1@Initialize
5 2 00006974 _Form1
1 3 00001F59 __GetExceptDLLinfo
4 4 000060AC ___CPPdebugHook