avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] order of modules to linker


From: Erik Christiansen
Subject: Re: [avr-chat] order of modules to linker
Date: Sun, 7 Jan 2018 12:52:38 +1100
User-agent: Mutt/1.8.0 (2017-02-23)

On 06.01.18 15:21, georg chambert wrote:
> Now I got some back-of-the-head hunch, so I re-arranged so that the .a
> was first in the link-list, and sure enough the vector_11 was now a
> fine address to the ISR, and the load-module work (what I can see so
> far)
> 
> WHAT WAS THAT, is my question (I usuallly want to understand whats
> happening, otherwise things tend to come back in some other shape and
> bite u)

Too true. But your example runs contrary to my experience, which is that
it is necessary to place a library (.a) _after_ all the object files
which need it, because the linker reads each file only once. Thus a .o
file on the command line after a needed .a will fail to have its
externals satisfied by the library which has already whizzed past, and
is gone.

Crux: Only the parts of a library which are required for unsatisfied
externals are pulled in by the linker. So place the libraries last, with
libraries needing other libraries preceding those which don't.

If there are reciprocal or cyclical dependencies, then list them thus:
"-( archives -)", and ld will search them repeatedly until no new
undefined references  are created.

Erik



reply via email to

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