NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » compiler error: relocaction truncated to fit: R_AVR_13_PCREL

January 15, 2011
by mickdoe
mickdoe's Avatar

I'm getting this error when I run make on my project. I think it's got something to do with floating point math libraries. Any idea what's causing it?

Here's the error message:

avr-gcc -g -Os -Wall -mmcu=atmega168 -Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm -o enlarger.o avr_control.o controller.o main.o ../Code/libnerdkits/delay.o ../Code/libnerdkits/lcd.o ../Code/libnerdkits/uart.o
/usr/lib/gcc/avr/4.3.4/../../../avr/lib/avr5/libc.a(inverse.o):../../../libm/fplib/inverse.S:50: relocation truncated to fit: R_AVR_13_PCREL against symbol `__divsf3' defined in .text section in /usr/lib/gcc/avr/4.3.4/avr5/libgcc.a(_div_sf.o)
/usr/lib/gcc/avr/4.3.4/../../../avr/lib/avr5/libc.a(log.o):../../../libm/fplib/log.S:94: relocation truncated to fit: R_AVR_13_PCREL against symbol `__addsf3' defined in .text section in /usr/lib/gcc/avr/4.3.4/avr5/libgcc.a(_addsub_sf.o)
/usr/lib/gcc/avr/4.3.4/../../../avr/lib/avr5/libc.a(log.o):../../../libm/fplib/log.S:98: relocation truncated to fit: R_AVR_13_PCREL against symbol `__addsf3' defined in .text section in /usr/lib/gcc/avr/4.3.4/avr5/libgcc.a(_addsub_sf.o)
/usr/lib/gcc/avr/4.3.4/../../../avr/lib/avr5/libc.a(modf.o):../../../libm/fplib/modf.S:87: relocation truncated to fit: R_AVR_13_PCREL against symbol `__subsf3' defined in .text section in /usr/lib/gcc/avr/4.3.4/avr5/libgcc.a(_addsub_sf.o)
make: *** [enlarger.o] Error 1
make: Target `all' not remade because of errors.

And here's my Makefile:

GCCFLAGS=-g -Os -Wall -mmcu=atmega168
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P /dev/ttyUSB0
LINKOBJECTS=../Code/libnerdkits/delay.o ../Code/libnerdkits/lcd.o ../Code/libnerdkits/uart.o

all:    enlarger-upload

enlarger.hex: enlarger.o
    avr-objcopy -j .text -O ihex enlarger.o enlarger.hex

enlarger.o: avr_control.o controller.o main.o
    make -C ../Code/libnerdkits
    avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o enlarger.o avr_control.o controller.o main.o ${LINKOBJECTS}

avr_control.o: avr_control.c
    avr-gcc ${GCCFLAGS} -o avr_control.o -c avr_control.c
controller.o: controller.c
    avr-gcc ${GCCFLAGS} -o controller.o -c controller.c
main.o: main.c
    avr-gcc ${GCCFLAGS} -o main.o -c main.c

enlarger.ass: enlarger.hex
    avr-objdump -S -d enlarger.o > enlarger.ass

enlarger-upload: enlarger.hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:enlarger.hex:a

I'm using emacs on Ubuntu Linux as my development environment. Any suggestions appreciated.

January 19, 2011
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi mickdoe,

See this thread. Apparently, changing the order of some of the library linking (putting the "-lm" somewhere else in the Makefile) should let you get a successful compile. Let me know if that works!

Mike

January 19, 2011
by mickdoe
mickdoe's Avatar

Thanks Mike. I tried moving -lm around to several places and eventually got it to work like this:

avr-gcc -lm ${GCCFLAGS} ${LINKFLAGS} -o enlarger.o avr_control.o controller.o main.o -lm ${LINKOBJECTS}

Post a Reply

Please log in to post a reply.

Did you know that multiple microcontrollers can communicate with each other? Learn more...