Hi,
I am using KDS3.2.0 and KSDK 2.0 for K66F development.
I can use PRINTF to output debug message..
When I use sprintf and have the following problem:
sprintf(&LCD_character[d_position], "DDD"); ---Works fine
sprintf(&LCD_character[d_position], "%s_", temp_char); ---Not working, get the following error:
`_sbrk' referenced in section `.text._sbrk_r' of c:/fsl32/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m/fpu\libg_s.a(lib_a-sbrkr.o): defined in discarded section `.text' of ./utilities/fsl_sbrk.o (symbol from plugin)
`errno' referenced in section `.text._sbrk_r' of c:/fsl32/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m/fpu\libg_s.a(lib_a-sbrkr.o): defined in discarded section `.text' of ./middleware/lwip_2.0.0/port/sys_arch.o (symbol from plugin)
collect2.exe: error: ld returned 1 exit status
makefile:103: recipe for target 'iNetVu7710_V50_FW.elf' failed
make: *** [iNetVu7710_V50_FW.elf] Error 1
I tried the way that Erich provided to change "caddr_t _sbrk(int incr)" in fsl_sbrk.c to
void _sbrk(void){}
It didn't fix the problem...
Can anybody to help me to fix this problem?
Thanks,
Christie
Solved! Go to Solution.
Hi Christie,
I have identified the problem: it is related to -flto linker optimization. See Solving Problem with GNU Linker and “referenced in section, defined in discarded section ” Error Mes... for a description and the solution to work around this.
I hope this helps,
Erich
Hello,
could you provide an example with all the necessary types/variables?
I have tried the following
unsigned char LCD_character[32];
int d_position = 0;
char *temp_char;
void test(void) {
sprintf(&LCD_character[d_position], "DDD");
sprintf(&LCD_character[d_position], "%s_", temp_char);
}
and it worked on my end without issues?
Erich
Hi Christie,
I have identified the problem: it is related to -flto linker optimization. See Solving Problem with GNU Linker and “referenced in section, defined in discarded section ” Error Mes... for a description and the solution to work around this.
I hope this helps,
Erich
Hi Erich,
It works. Thank you for your help...
What is "-flto" optimization doing? Can I just turn off this because I tried it works fine without "-flto" ON?
If I check "use float with nano printf", it works as well...
Could you tell me if there is any relationship? Which way should I use?
Thanks,
Christie
Hi Christie,
-flto does optmizations across compilation units (modules), something the compiler is not able to do. Basically it tries to remove/inline things as much as possible from a 'global' application point of view. It is known (at least to me) that sometimes it is too agressive like in this case. It is not related to the printf option, but of course if you use different libraries, it has an other angle of optimizations.
I hope this helps,
Erich
Thanks, Erich.
got it, will look into it over the next day and report back my findings.
Erich