mrichmond68 wrote on Thursday, December 11, 2014:
I am working from the V8.1.2 GCC/ARM_CM3 port. I have successfully built myself a demo in Eclipse(Kepler), my arm gcc is 4_8_2014q3, my hardware is an STM32F103RE processor based board. I’m also using gnuarmeclipse plugins.
When first building, I received the following link error. I’ve fixed it, but I suspect something else is wrong and I’m just masking my real problem with my “fix”. Just putting this out there to see what folks think.
Here is the link error (-flto is being used in the compile/link process):
‘C:\Users\mrichmon\AppData\Local\Temp\ccq0f0ed.ltrans0.ltrans.o’
vTaskSwitchContext' referenced in section
.text.PendSV_Handler.4125’ of C:\Users\mrichmon\AppData\Local\Temp\ccq0f0ed.ltrans0.ltrans.o: defined in discarded section.text' of ./FreeRTOS_Source/source/tasks.o (symbol from plugin)
pxCurrentTCB’ referenced in section.text.PendSV_Handler.4125' of C:\Users\mrichmon\AppData\Local\Temp\ccq0f0ed.ltrans0.ltrans.o: defined in discarded section
.text’ of ./FreeRTOS_Source/source/tasks.o (symbol from plugin)
pxCurrentTCB' referenced in section
.text.SVC_Handler.4140’ of C:\Users\mrichmon\AppData\Local\Temp\ccq0f0ed.ltrans0.ltrans.o: defined in discarded section `.text’ of ./FreeRTOS_Source/source/tasks.o (symbol from plugin)
collect2.exe: error: ld returned 1 exit status
I tracked down the two resources being unceremoniously “discarded” during the the linking process:
vTaskSwitchContext()
pxCurrentTCBG
I fixed the problem by adding the attribute “used” to both resources (yes, I modified source code —icky right?).
Defined in FreeRTOSConfig.h with a big juicy note:
#define KEEP_ME __attribute__((used))
Modified in tasks.c
void KEEP_ME vTaskSwitchContext( void )
{ . . . }
PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB KEEP_ME = NULL;
So maybe -flto is the problem – but maybe I’ll want to use it for my app. Are my only two options to avoid -flto or use the “used” attribute? Does either choice represent a good practice?
Thanks!!
mjr