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

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

[avr-gcc-list] Link question


From: Kári Davíðsson
Subject: [avr-gcc-list] Link question
Date: Thu, 22 Mar 2012 23:26:36 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

Hello,

I have a library with couple of object files.
Library is created with avr-ar, e.g.

$ avr-ar rcs libmylib.a f1.o f2.o f3.o

All of the files use .init8 or .fini8 sections.

Looking at the library through with avr-objdump reveals that all
functions and sections are in the library, e.g.

$ avr-objdump -s libmylib.a
.....
 0940 30313737 3737373b 3b303b35 3b28352c  0177777;;0;5;(5,
 0950 342900                               4).
Contents of section .init8:
 0000 209a289a 14bc83e0 85bd83ec 86bd8091   .(.............
 0010 00008064 80937c00 84e08093 7b0088ea  ...d..|.....{...
 0020 80937a00                             ..z.
Contents of section .fini8:
 0000 10927a00                             ..z.

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.
$ avr-g++ -g -Os -DF_CPU=16000000UL -mmcu=atmega328p myapp.o -L. -lmylib -o myapp

The application of course does not work and I can verify that the .init8 section is stripped out by looking at the pin toggling patterns,
which are not executed.

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.
All .init8 functions are called during initialization and .fini8 are
executed normally when main() returns, e.g.
$ avr-g++ -g -Os -DF_CPU=16000000UL -mmcu=atmega328p f?.o myapp.o -o myapp

It there anything that I can do to force the linker to include the sections it is leaving out of the executable?

This is all on Ubuntu 11.10 with following avr tools:
$ avr-gcc --version
avr-gcc (GCC) 4.5.3

$ avr-objcopy --version
GNU objcopy (GNU Binutils) 2.20.1.20100303

and avr-libc 1:1.7.1-2

All pointers appreciated, since I have been a googling for solution but found NULL.

brg
kd




reply via email to

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