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: R_AVR_13_PCREL against `no symbol' #307

Open
MrSurly opened this issue Mar 25, 2023 · 0 comments
Open

relocation truncated to fit: R_AVR_13_PCREL against `no symbol' #307

MrSurly opened this issue Mar 25, 2023 · 0 comments

Comments

@MrSurly
Copy link

MrSurly commented Mar 25, 2023

While writing code for an ATTINY806 chip, I ran across this error:

(base) epoulsen@strawberry:~/workspaces/dragonfly-can-expander/firmware$ PLATFORMIO_BUILD_FLAGS="-DMCP2515_NO_CONTEXT -DMCP2515_CLOCK_XTAL_FREQ_MHZ=16 -DMCP2515_CLOCK_BAUDRATE_KBPS=1000" pio run 
Processing attinyx06 (platform: atmelmegaavr; board: ATtiny806)
-----------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/ATtiny806.html
PLATFORM: Atmel megaAVR (1.7.0) > ATtiny806
HARDWARE: ATTINY806 16MHz, 512B RAM, 8KB Flash
PACKAGES: 
 - tool-avrdude @ 1.70100.0 (7.1.0) 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/attinyx06/src/can_config.o
Compiling .pio/build/attinyx06/src/command_process.o
Compiling .pio/build/attinyx06/src/common.o
Compiling .pio/build/attinyx06/src/hal_attinyx06.o
Compiling .pio/build/attinyx06/src/main.o
Compiling .pio/build/attinyx06/src/mcp2515.o
Compiling .pio/build/attinyx06/src/mcp2515_hal.o
Linking .pio/build/attinyx06/firmware.elf
/tmp/ccJnIG2N.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0x698): relocation truncated to fit: R_AVR_13_PCREL against `no symbol'
collect2: error: ld returned 1 exit status
*** [.pio/build/attinyx06/firmware.elf] Error 1
====================================================== [FAILED] Took 0.41 seconds ======================================================

This happened after deleting a single like from a function; putting that line back makes it go away; It's clear there doing this simply moves code around in a way that causes the linking to fail.

Doing -O3 instead of -Os "fixes" the issue, but the cost of 50% larger code.

There's a long answer here that has a lot of information that unfortunately is not working
for me. I tried removing -mshort-calls (looks like it was never there in the first place), and adding -mrelax to no avail. Note that that answer states it could happen on devices with >8K of flash; my device has 8K.

I googled it a bit, and I tried all the usual stuff of wrt -mrelax, removing `-m

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

1 participant