I am porting a gcc project to armclang.
My .sct file contains:
#define __STACK_SIZE 0x00001000 #define __HEAP_SIZE 0x00003800 #if __HEAP_SIZE > 0 ARM_LIB_HEAP __HEAP_BASE EMPTY __HEAP_SIZE { ; Reserve empty region for heap } #endif ARM_LIB_STACK __STACK_TOP EMPTY -__STACK_SIZE { ; Reserve empty region for stack } }
File exceptions.c contains code:
ExecFuncPtr vector_table[] __attribute__((section("vectors"))) = { /* Configure Initial Stack Pointer using linker-generated symbol */ #ifdef TWO_REGION #pragma import(__use_two_region_memory) (ExecFuncPtr)&Image$$ARM_LIB_STACK$$ZI$$Limit, #else /* (default) One Region model */ (ExecFuncPtr)&Image$$ARM_LIB_STACKHEAP$$ZI$$Limit, #endif (ExecFuncPtr)__main, /* Initial PC, set to entry point */ NMIException, HardFaultException, MemManageException, BusFaultException, UsageFaultException, 0, 0, 0, 0, /* Reserved */ SVCHandler, DebugMonitor, 0, /* Reserved */ PendSVC, SysTickHandler, /* Add up to 240 interrupt handlers, starting here... */ InterruptHandler, InterruptHandler, /* Some dummy interrupt handlers */ InterruptHandler /* : */ };
If TWO_REGION is defined I get compiler errors:
exceptions.c:102:13: error: '#pragma import' is an ARM Compiler 5 extension, and is not supported by ARM Compiler 6 [-Warmcc-pragma-import] #pragma import(__use_two_region_memory) ^ exceptions.c:103:19: error: use of undeclared identifier 'Image$$ARM_LIB_STACK$$ZI$$Limit'; did you mean 'Image$$ARM_LIB_STACKHEAP$$ZI$$Limit'? (ExecFuncPtr)&Image$$ARM_LIB_STACK$$ZI$$Limit, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Image$$ARM_LIB_STACKHEAP$$ZI$$Limit exceptions.c:85:21: note: 'Image$$ARM_LIB_STACKHEAP$$ZI$$Limit' declared here extern unsigned int Image$$ARM_LIB_STACKHEAP$$ZI$$Limit; /* for (default) One Region model */ ^ 2 errors generated.
If TWO_REGION is undefined I get linker error:
Error: L6218E: Undefined symbol Image$$ARM_LIB_STACKHEAP$$ZI$$Limit (referred from exceptions.o).
How should I fix these errors?
Hi David,
The default region names are indeed ARM_LIB_STACKHEAP (one region model) or ARM_LIB_STACK, and ARM_LIB_HEAP for the two region model. Your scatter file is implementing the two region model.https://developer.arm.com/documentation/100748/0617/Embedded-Software-Development/Run-time-memory-models
The error:
exceptions.c:102:13: error: '#pragma import' is an ARM Compiler 5 extension, and is not supported by ARM Compiler 6 [-Warmcc-pragma-import] #pragma import(__use_two_region_memory)
says that the necessary __use_two_region_memory symbol is imported in a legacy way. That #pragma should be changed to the below, optionally with the same #ifdef wrapper, and moved out of function (for example to top of source file, where #include etc usually reside, hope that makes sense...)
#ifdef TWO_REGION __asm(".global __use_two_region_memory"); #endif
Regards
Ronan