undefined reference to __STACK_TOP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

undefined reference to __STACK_TOP

Jump to solution
3,245 Views
robertpoor
Senior Contributor I

I'm porting an older project to SDK_2.2, and I'm getting:

undefined reference to __STACK_TOP

In the original project -- which compiles correctly -- I see references to __STACK_TOP but as far as I can tell, there's no definition for it.  This leads me to think it's a special symbol, perhaps defined by the linker?

What's the right remedy to make __STACK_TOP known to my project?  Or has the mechanism changed in SDK 2.x?

Tags (2)
0 Kudos
Reply
1 Solution
2,654 Views
robertpoor
Senior Contributor I

Okay - figured it out: __STACK_TOP defined in the .ld file.

In the old project, the .ld file defines both __StackTop and __STACK_TOP:

.stack :
{
. = ALIGN(8);
__StackLimit = .;
. += STACK_SIZE;
__StackTop = .;
__STACK_TOP = .;
PROVIDE(__stack = __StackTop);
} > m_data

The newer project only defines __StackTop:

/* Initializes stack on the end of block */
__StackTop = ORIGIN(m_data) + LENGTH(m_data);
__StackLimit = __StackTop - STACK_SIZE;
PROVIDE(__stack = __StackTop);

I could alias __StackTop to __STACK_TOP as in the old project, or change references in my code to _StackTop.  The latter appears to be stylistically more correct.  And it now compiles without error.

View solution in original post

0 Kudos
Reply
2 Replies
2,655 Views
robertpoor
Senior Contributor I

Okay - figured it out: __STACK_TOP defined in the .ld file.

In the old project, the .ld file defines both __StackTop and __STACK_TOP:

.stack :
{
. = ALIGN(8);
__StackLimit = .;
. += STACK_SIZE;
__StackTop = .;
__STACK_TOP = .;
PROVIDE(__stack = __StackTop);
} > m_data

The newer project only defines __StackTop:

/* Initializes stack on the end of block */
__StackTop = ORIGIN(m_data) + LENGTH(m_data);
__StackLimit = __StackTop - STACK_SIZE;
PROVIDE(__stack = __StackTop);

I could alias __StackTop to __STACK_TOP as in the old project, or change references in my code to _StackTop.  The latter appears to be stylistically more correct.  And it now compiles without error.

0 Kudos
Reply
2,654 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Rotert,

Thanks for your sharing .

BR

Alice

0 Kudos
Reply