avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Link question


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Link question
Date: Fri, 23 Mar 2012 09:07:13 +0100 (MET)

(Please suscribe to the list to not miss replies.)

Kári Davíðsson <address@hidden> wrote:

> I can compile my application and link in this library without errors,
> but then .init8 and .fini8 sections are stripped out of the final
> executable, e.g.

No, they are not "stripped", they simply never made it there, because
the linker had no reason to include those object modules in the first
place.

> If I on the other hand link the application by specifying all of the
> library object files on the command line, every thing works just fine.

Sure, object files specified on the command line are always linked.

Object modules within a library are only pulled in to satisfy global
references which are undefined at the point where the library is being
processed (that's why the position of a library on the command line is
important).

Presumably, your init/fini object modules don't define any symbol that
is being needed by the linker, so they are not considered.

What you could do is putting one global symbol into each of your
modules (perhaps you've already got some?), and then explicitly tell
the linker that just this symbol is global undefined, using the -u
option.  This will make the linker pull in that entire object module
from the library.

avr-g++ -g -Os -DF_CPU=16000000UL -mmcu=atmega328p myapp.o \
-Wl,-u,symbol1 -Wl,-u,symbol2 \
-L. -lmylib -o myapp

(The -Wl option is used to prefix a linker-only option on the compiler
command line.)
-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



reply via email to

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