-flto in GCC 7.2.1 cause ISR is removed from result binary (change from GCC 6.3.1)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Hi,
I just upgraded GCC (win32 host) toolchain from ver 6.3.1 to 7.2.1 and found that my recompiled project with -flto is not working. I found this is because new GCC thrown away my ISRs code and leave them directed to the default interrupt handler that cause MCU lokckup.
So here are my gcc compile options:
arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -DSTM32L476xx -I../..
arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -DSTM32L476xx -I../..
I tried to assign my ISR to .isr_vector section that is defined in my generic linker script
void __attribute__ ((section(
.isr_vector :
{
. = ALIGN(8);
KEEP(
. = ALIGN(8);
} >FLASH
and I also tried to add KEEP(*(
.text.
...
Even if I call the ISR function directly from main() it's discarded too. Is there any other way how to tell GCC 7 to keep it? Again, in GCC 6 it worked fine without any attributes.
The last though directed me to ISR names definitions. It's the part of STM Cube library, the file: startup_
.section .isr_vector,
.type g_pfnVectors, %object
.size g_pfnVectors, .-g_pfnVectors
g_pfnVectors:
.word _estack
.word Reset_Handler
...
.word USART2_IRQHandler
...
.weak USART2_IRQHandler
.thumb_set USART2_
Is it OK? No problem with weak or so? When I rename my ISR to some other name that is NOT listed in this startup file it is NOT discarded so I guess there might be some link but I don't understand GAS asm...
Changed in gcc-arm-embedded: | |
milestone: | none → 7-2018-q2-update |
no longer affects: | gcc-arm-embedded/7.0 |
Changed in gcc-arm-embedded: | |
status: | New → Fix Released |
Changed in gcc-arm-embedded: | |
milestone: | none → 7-2017-q4-major |
Changed in gcc-arm-embedded: | |
status: | New → Confirmed |
Thanks for the report. Is the isr section kept if you drop the -flto?