Nios V, Max10, C++: region `reset' overflowed by 4 bytes
Everything was working fine, compiles ok, runs ok, then I added more code and suddenly:
[ 98%] Linking CXX executable app_free.elf /quartus/V23.1-STD/riscfree/toolchain/riscv32-unknown-elf/bin/../lib/gcc/riscv32-unknown-elf/12.1.0/../../../../riscv32-unknown-elf/bin/ld: app_free.elf section `.entry' will not fit in region `reset' /quartus/V23.1-STD/riscfree/toolchain/riscv32-unknown-elf/bin/../lib/gcc/riscv32-unknown-elf/12.1.0/../../../../riscv32-unknown-elf/bin/ld: region `reset' overflowed by 4 bytes collect2: error: ld returned 1 exit status make[3]: *** [CMakeFiles/app_free.elf.dir/build.make:115: app_free.elf] Error 1 make[2]: *** [CMakeFiles/Makefile2:104: CMakeFiles/app_free.elf.dir/all] Error 2 make[1]: *** [Makefile:91: all] Error 2
This is not the first time we have seen this error, but it magically comes and goes.
What goes into the .entry section?
Why is it overflowing by 4 bytes?
Why cant I just increase the reset region in bsp-editor?
Thanks for your time,
-Andy
I think I found an answer. My Nios Reset was pointing to on-chip memory, with base 0xc000000.
.text was in external ddr3 at base 0x0, and __start was at 0x804.
Generating the linker map I see:
.entry 0x000000000c000000 0x24 *(.entry) .entry 0x000000000c000000 0x24 freertos_bsp/libfreertos_bsp.a(crt0.S.obj) 0x000000000c000000 __resetWhich tells me the only thing in the .entry section is __reset, and this is __reset in crt0.S:
.section .entry, "xa" .align 5 .globl __reset .type __reset, @function __reset: /* * Jump to the _start entry point in the .text section if reset code * is allowed or if optimizing for RTL simulation. */ /* Jump to the _start entry point in the .text section. */ tail _start .size __reset, . - __resetI'm wondering if the "tail _start" instruction had to be encoded with extra bits because I'm jumping from 0xc000000 to 0x804?
When I switched my Nios reset to also point to external ddr3, then my C++ compiled ok.
Now my .entry is at 0x0, and _start is still 0x804.
Does that seem like a reasonable explanation?