Undefined reference to `_sbrk' when compiling without semihosting.
Hallo, I’m trying to build pretty basic Cpp project using GCC ARM Embedded 4.7 update 3.
The code is ass follow:
#include <stdio.h>
struct test_class {
test_class () {
m = new char[10];
printf("In ctor\n");
}
~test_class () {
delete m;
printf("In dtor\n");
}
char * m;
} g;
int main()
{
printf("In main\n");
return 0;
}
I’m using(after basic modifications) linker script and start-up code from examples shipped with GCC ARM Embedded.
When I'm compiling with semihosting using linker flags as given in readme.txt
“--specs=nano.specs --specs=
Compilation finish without any error.
When I try to build without semihosting, once again using flags form readme.txt:
“--specs=nano.specs -Wl,--start-group -lgcc -lc -lc -lm -lnosys -Wl,--end-group”
I gets Errors:
c:/program files (x86)/gnu tools arm embedded/4.7 2013q3/
sbrkr.c:
c:/program files (x86)/gnu tools arm embedded/4.7 2013q3/
signalr.
c:/program files (x86)/gnu tools arm embedded/4.7 2013q3/
signalr.
collect2.exe: error: ld returned 1 exit status
In both cases I use compilator flags:
-Os -ffunction-sections -fdata-sections -fno-builtin
What is more when I add -flto to compiler options I get lot of new errors:
`NMI_Handler' referenced in section `.isr_vector' of ./src/startup_
`HardFault_Handler' referenced in section `.isr_vector' of ./src/startup_
`MemManage_Handler' referenced in section `.isr_vector' of ./src/startup_
`BusFault_Handler' referenced in section `.isr_vector' of ./src/startup_
`UsageFault_
`SVC_Handler' referenced in section `.isr_vector' of ./src/startup_
`DebugMon_Handler' referenced in section `.isr_vector' of ./src/startup_
`PendSV_Handler' referenced in section `.isr_vector' of ./src/startup_
`SysTick_Handler' referenced in section `.isr_vector' of ./src/startup_
collect2.exe: error: ld returned 1 exit status
I have found how to solved it on Cooox support forum (http://
Thanks for any help.
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Joey Ye
- Solved:
- Last query:
- Last reply: