Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relocation Truncated to fit..... #23

Open
Ejac46 opened this issue Jan 22, 2020 · 2 comments
Open

Relocation Truncated to fit..... #23

Ejac46 opened this issue Jan 22, 2020 · 2 comments

Comments

@Ejac46
Copy link

Ejac46 commented Jan 22, 2020

No description provided.

@Ejac46 Ejac46 changed the title First, many thanks for this work, it is very useful. Relocation Truncated to fit..... Jan 22, 2020
@Ejac46
Copy link
Author

Ejac46 commented Jan 22, 2020

Many thanks for this Library, great Job, it is very useful.

I used these four functions succesfully in an Arduino UNO:

  • aes128_dec_single and aes128_enc_single
  • aes128_dec_multiple and aes128_enc_multiple

The problems comes when I try to use it in a Arduino MEGA2560, It seems is not ready for it, as this message appears when compiling and uploading

Arduino:1.8.10 (Windows 10), Tarjeta:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:......../appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avr6/crtatmega2560.o:(.init9+0x0): relocation truncated to fit: R_AVR_13_PCREL against symbol `main' defined in .text.startup section in C:...\AppData\Local\Temp\ccWx9BPA.ltrans0.ltrans.o

collect2.exe: error: ld returned 1 exit status

Error compiling for Arduino Mega or Mega 2560.

I have been taking a look to different websites looking for a solution. This kind of error looks related to this:
The AVR devices support two kinds of jump/call instructions: JMP vs. RJMP, and CALL vs. RCALL. The R variants make calls relative to the current location and are more efficient both in usage of program memory and execution time. This comes at a cost though: RJMP and RCALL can only be used for addresses in the range of +/-4kb from their location in program memory. This is never a problem on devices with no more than 8kb of program memory because the whole 8kb range can be addressed from any location via RCALL or RJMP.

I haven´t made any modification on my arduino cc 1.8.10 version and I have recently installed it. I would be surprised it is a mistake on the compiler. Not sure anyway, I will take a deeper look to this, but any help would be much appreciated.

I have seen that the library.json file states: "platforms": "atmelavr", I am not sure this is saying it is not compatible with my Arduino mega3560

Many thanks in advance!

@woytam
Copy link

woytam commented Apr 1, 2020

I have run into the same problem. For me, solution was to change order of files for linker (unfortunately, this cannot be done in Arduino, you can use makefile configuration).
Command for linker was changed from (some parameters are omitted with ...)

avr-gcc -g  ...  -o program.elf main.o spi.o net.o  ...  aes_sbox-asm.o aes_invsbox-asm.o aes_dec-asm_faster.o aes_keyschedule-asm.o 

to

avr-gcc -g  ...  -o program.elf main.o aes_sbox-asm.o aes_invsbox-asm.o aes_dec-asm_faster.o aes_keyschedule-asm.o spi.o net.o  ...   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants