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: Incremental linking - how to do that?


Niv Tweig <rm16029@email.sps.mot.com> writes:

> 1) Suppose you have P1.cc,P2.cc,...,Pn.cc (C++ programs) and you want to
> incrementally link them,
>     how do you do that?
>     I mean, as I understand from the poorly written docs about that
> subject, first you will write probably
>     ld -Ur -o P.exe P1.o P2.o .. Pn.o
>     (the -Ur option is for incremental linking on C++)

-r and -Ur do not do incremental linking.  They link relocateable
objects together to produce a relocateable object.

I guess the documentation for the -i option is misleading.  It should
not use the word ``incremental.''

>     Now suppose that only P1.o changed and you want to update that in
> the exe file,
>     without linking again all the object files, what should you write:
> 
>     ld -Ur -o P.exe P1.o
>         or
>     ld -Ur -o P.exe P1.o P2.o .. Pn.o (Does the linker check the
> timestamps of the files and knows to "update" only P1.o in P.exe?)

Neither.  The first case will essentially copy P1.o while building
global constructor tables.  The second will create a new P.exe from
the input files.

> 2) The documentation for -Ur says :
>     "For anything other than C++ programs, this option is equivalent to
> `-r': it generates relocatable output--i.e., an output file that can in
> turn serve as input to ld. When linking C++ programs, `-Ur' does resolve
> references to constructors, unlike `-r'. It does not work to use `-Ur'
> on files that were themselves linked with `-Ur'; once the constructor
> table has been built, it cannot be added to. Use `-Ur' only for the last
> partial link, and `-r' for the others. "
>     Does that mean that what I suggested in question 1 cannot be done at
> all?
>     i.e. does it mean that P.exe, after being created with the -Ur
> option,
>     cannot be used again with the -Ur option to update itself.
>     If the answer is yes, Then how can incremental links be done in C++.

The answer is yes.

The GNU linker does not support incremental linking.

> 3) What is the exact reason for the separation between C and C++ (the
> options -r and -Ur), what is it with constructors that makes them
> different?

Global objects normally need table of constructors and destructors to
be created.  These tables are used at program startup and termination
to create and destroy the global objects.  The -Ur option directs the
linker to build these tables.  This is useful for certain embedded
operating systems which execute relocateable objects rather than fully
linked executables, such as VxWorks.

Ian


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