This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [BUG] ld behavior varies for C++ static initializer dependingon .a or .o input


Alexandre Oliva wrote:
On Apr 12, 2003, Hal Black <hablack at vt dot edu> wrote:


Why should it be different for a .a file with the same .o files in
it?  Should .a files not be used for C++?


Because .o files are copied to the output, whereas .a files are used
as libraries, i.e., only members that offer symbols that are being
looked for are copied to the output.  Can you imagine the bloat if any
time you linked with a static library, all of the code in it was
copied to your executables?

What I'm saying is not to use all the symbols, but to include all static initializers as "symbols that are being looked for". Even if they aren't explicitly referenced by annother piece of code, they are implicitly referenced by virtue of being static initializers.



------------------ From the C++ draft spec 2 December 1996:

 Section 3.7.1:
 2 If an object of static storage duration has initialization or a
 destructor with side effects, it shall not be eliminated even if it
 appears to be unused, except that a class object or its copy may be
 eliminated as specified in 12.8.
------------------

I would say that not looking for static initializers constitutes eliminating them...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]