Hi all,
This is my first post, so I hope it is clear and concise but also in the correct section.
I am doing some development on a MPC5534, using Freescales Codewarrior compiler.
I am trying to implement a stack paint algorithm, so that I can determine my stack usage at runtime.
My problem lies in the fact that I cannot access the linker generated symbols that are present in the ".lcf".
The compiler/linker error:
C:/Freescale/CW MCU v10.4/MCU/PA_Tools/Command_Line_Tools/mwldeppc|Linker|Error
>Small data relocation (109) in function 'vStackInit'
>in referencing file 'stack_c.obj'
>requires that symbol '_stack_addr'
>in symbol definition file 'linker generated symbol'
The function below is a simplification of my implementation so that you can get the "idea" of what I am doing.
There is no need to correct the algorithm (Yes, I know it is corrupting any existing values on the stack), but any help
as to the syntax required to access the symbol "_stack_addr" would be greatly appreciated.
#define STACK_VALUE 0x55AA55AAul
void vStackInit( void );
extern uint32_t _stack_addr;
void vStackInit( void )
{
unsigned int u32IntIndex = 0u;
unsigned int *pu32Index = (unsigned int *)(_stack_addr);
for(u32IntIndex = 0ul; u32IntIndex < 0x8000ul; u32IntIndex++ ) {
pu32Index[u32IntIndex] = STACK_VALUE;
}
}
Any help would be greatly appreciated.
Thanks
Hi Scott.
Haven't used the MPC5534 or tool set but the Kinetis device with CW10.x can access the linker script variable with following declaration in a "C" file"
const uchar __FLASHX_START_ADDR[];
Later in "C" file it is used with following way:
(uint_32) __FLASHX_START_ADDR
Hope this helps.
Regards,
David
Thanks for the feedback, its really helpful. I will try compile and link with that and see if it pulls the correct value.
Regarding your declaration, are you missing "extern"?
Hi,
for my understanding you could use the following.
in main.c file:
extern unsigned long _stack_addr[];
int main(void) {
volatile int i = 0;
unsigned long* StackStartAddr;
StackStartAddr = _stack_addr;
in lcf file:
_stack_addr = ADDR(stack)+SIZEOF(stack);
I can build it without problem on my side.
However I don't have board to test it.
Pascal