Big problem with Small programs
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Tue Jan 23 09:33:54 PST 2007
Sean Kelly wrote:
> Walter Bright wrote:
>> Try using enums instead of const variables, they don't take up any
>> space in the object file.
>
> That shaved off maybe 30k. I think the remaining 40k are mostly static
> struct initializers, all of which are unused in the final app. As
> optlink is an optimizing linker, shouldn't it discard whatever is unused
> by the application? Or does that only apply to certain classes of
> information?
I'm not sure about Windows, but I just tried it on Linux. It seems
struct init data is stored in .rodata instead of some separate
section[1]. That means if *any* read-only data from a module is
referenced, all of its struct initializers are kept, presuming optlink
works similarly to 'ld --gc-sections'.
[1]: Like .gnu.linkonce.*, where TypeInfo init data is stored (as well
as functions).
More information about the Digitalmars-d
mailing list