I added the assembler source of .section .init5 in Arduino IDE and confirmed that it was added by disassembler. My problem is a solution.
I am happy.
I want to check the linker script. The following is the linker execution log. The linker script specification cannot be found.
Linking everything together...
"D:\C_EXT_WIN10\arduino-1.8.13-windows\arduino-1.8.13\hardware\tools\avr/bin/avr-gcc"
-w
-Os
-g
-flto
-fuse-linker-plugin
-Wl,--gc-sections
-mmcu=atmega32u4
-o "D:\C_EXT_~1\User\yoshi\AppData\Local\Temp\arduino_build_473170/constructorCall.ino.elf"
"D:\C_EXT_~1\User\yoshi\AppData\Local\Temp\arduino_build_473170\sketch\constructorCall.ino.cpp.o"
"D:\C_EXT_~1\User\yoshi\AppData\Local\Temp\arduino_build_473170/core\core.a"
"-LD:\C_EXT_~1\User\yoshi\AppData\Local\Temp\arduino_build_473170"
-lm
Default linker scripts are in:
.../arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/lib/ldscripts
It looks like 32u4 builds use avr5.xn: /* Script for -n: mix text and data on same page */
"avr5" specifies the "sub-architcture" within AVR. More than 8k of program memory, less than 128k, etc. A Nano Every (w atmega4809) would use xmega3.xn, and a Mega (atmeg2560) would use avr6.xn
You can see what it's doing by adding a "-Wl,--verbose" to the link command.
Thank you for everything.
My first goal can be achieved with the following modifications.
Call ini () with init5 and then
Execute serial.bign
Delete init () in main ().
It may be better to call initVariant () in main () at the end of init ().
I think it is better to enable interrupts in init () after hardware initialization.
My second question is why the init() call comes after the execution of the constructor. I think init() is the HW initialization process. Executing the constructor is software initialization. I think that it should be done as soon as possible after initializing the variables with initial values of the hardware, initializing the bss, and setting the stack. I think it's correct to do it before the variables are initialized by the constructor.
I hope this fix will be realized in the Arduino release version.