[Top][All Lists]

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

[avr-libc-dev] [bug #14855] Link Error "relocation truncated to fit: R_A

From: anonymous
Subject: [avr-libc-dev] [bug #14855] Link Error "relocation truncated to fit: R_AVR_13_PCREL"
Date: Fri, 4 Nov 2005 02:46:00 +0000

Follow-up Comment #4, bug #14855 (project avr-libc):

The reason consists that the 'avr-g++' inserts libraries 'gcc'
and 'm' in addition before to user ones.  With 'avr-gcc' all works:
it inserts default libraries (gcc, c and gcc again) after
user ones.

Resulted below the program illustrates a mistake:

  avr-g++ -mmcu=atmega168 -o foo3.elf foo3.cpp -lm
     ==> many errors: relocation truncated to fit
  It is possible to look library sequence with '-v' switch:
     avr-ld ... /tmp/ccHZLoOn.o -lgcc -lm -lgcc -lc -lgcc

  Here functions from Avr-libc/libm use not the the own base
  arithmetic functions, and take them from library which has been
  picked up earlier.

  With 'C' compiler all works:
  avr-gcc -mmcu=atmega168 -o foo3.elf foo3.cpp -lm
    ==> OK
  Looking by '-v':
     avr-ld ... /tmp/ccCdQL2u.o -lm -lgcc -lc -lgcc

  'C' compiler with incorrect library sequence:
  avr-gcc -v -mmcu=atmega168 -o foo3.elf foo3.cpp -lgcc -lm
     ==> result is like (1), the same errors.

It is possible to use the 'avr-g++', having forbidden implicit
connection of libraries:
  avr-g++ -nodefaultlibs -mmcu=atmega168 -o foo3.elf foo3.cpp -lm -lgcc
     ==> OK

Example program:
  #include <math.h>

  volatile double val;

  int main ()
      double x, y;
      int i;

      x = (val * 1.2 + 1.3) / 1.4;
      if (x < 1.5 && x > -1.6 && x != 0.17)
          x -= 1.8;
      x = -x;

      x = acos(x);
      x = asin(x);
      x = atan(x);
      x = atan2(x, 0.19);
      x = ceil(x);
      x = cos(x);
      x = cosh(x);
      x = exp(x);
      x = fabs(x);
      x = floor(x);
      x = fmod(x, 0.20);
      x = frexp(x, &i);
      x = ldexp(x, 3);
      x = log(x);
      x = log10(x);
      x = modf(x, &y);
      x = pow(x, 0.21);
      x = sin(x);
      x = sinh(x);
      x = sqrt(x);
      x = tan(x);
      x = tanh(x);

      return (int)x;

(I have use avr-g** 4.0.2, binutils 2.16.1 and Avr-libc 1.2.5).

And about of Avr-libc.
Usage of short instructions (rcall/rjmp) is safe due to summary size
of Avr-libc/limb functions is less then 4K bytes.  It is no sence
(for common linking, where '-lm' is after all user's), the section is
'.text.fplib' or simply '.text'.



Reply to this item at:


  Message sent via/by Savannah

reply via email to

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