bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ld & archives dependency problem...


From: Andrea Pippa
Subject: ld & archives dependency problem...
Date: Sun, 07 Jul 2002 22:43:00 +0200

Hi ! I've downloaded latest sources, and investigated a bit more about
the dependency problems. The problem, to my vision, is that:

- load_symbols() [in ldlang.c] is called on all the input files, objects
.o or archives .a .
  This call adds all the symbols for objects, and adds the objects from
archives that are needed for linking. The problem is that objects from
archives are added only if some of their symbols are needed by the
linking at the time the func is called, but they are not added if any
object/archive needs them later. Example:

libda.a contains base.o, which defined base::base() and base::~base()
libdb.a contains child.o, which defined child::child() [that calls
base::base()] and child::~child() [that calls base::~base()]
main.o defines main() [that calls child::child()]

This command linkd things correctly : (...well, just an example, would
need more stdc++ libs and so, but just to explain)

ld -o test main.o libdb.a libda.a

This goes wrong:

ld -o test main.o libda.a libdb.a

...complains that in function child::child() there is undefined symbol
base::base(), and in child::~child() there is undefined symbol
base::~base(). Infact, I've put the libdb archive after the libda
archive, so by the time libda is processed, there is still no need for
any symbol in base.o; but, then, when also libdb is processed, child.o
is added (because of the main.o requiding it), but child.o now lacks
base::base() and base::~base() symbols, that were in libda, but have not
been included because they weren't needed.

Worse:

ld -o test libda.a libdb.a main.o

...even worse: now both libda.a and libdb.a are ignored, and main lacks
child::child() and child::~child() (that were in libdb.a).

The solution to me seems quite simple: just process first all objects,
and then process archives in a loop that only exits when no more objects
are added.
Is that the problem ? is it a problem or a misunderstand (by me) feature
of ld ? thanks !
    Pyper.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]