[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Weak symbols & executable bloat
From: |
Craig Lawson |
Subject: |
Weak symbols & executable bloat |
Date: |
Tue, 9 Nov 2004 11:00:23 -0800 |
Hi
Folks,
I have an
interesting problem where my executables are bloating significantly due to weak
symbol resolution. Here's the scenario:
- I include STL's
<string> in all of my object files, and use the std::string == operator
in most of them. This defines the weak symbol "operator == std::basic_string,
std::basic_string" (obviously, I'm paraphrasing the typical C++
mess).
- I put my common
code into a library. However, it's not all common. A small subset (A.o
and B.o) are used for small.program, and nearly all of them (A.o, B.o, C.o,
... Z.o) are used for large.program. Further, there are lots of references
between modules C-Z.
I link the code and
discover that small.program is enormous. The cross-reference shows that
"operator == std::basic_string, std::basic_string" is arbitrarily satisfied by
H.o. Further, H.o has some references to J.o and K.o, so these are pulled in,
too. And so the snowball turns into an avalanche. Yet neither H, J, nor K
are required by small.program.
Resolution of weak
symbols is apparently random -- or at least not in my control. My
first thought is to break up my library into two libraries: one with only those
modules needed by small.program and another with the rest. But this promises to
be a maintenance pain because in reality there are more than two modules, and I
have many more weak symbols than operator ==.
Is there some linker
option which will control how weak symbols are resolved? Something along the
lines of: resolve weak symbols after all strong symbols have been resolved, and
try hard to resolve them from the pool of modules required by the strong
symbols?
Best
Regards,
Craig.
- Weak symbols & executable bloat,
Craig Lawson <=