undefined reference to __STACK_TOP

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

undefined reference to __STACK_TOP

跳至解决方案
3,745 次查看
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?

标记 (2)
0 项奖励
回复
1 解答
3,154 次查看
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 项奖励
回复
2 回复数
3,155 次查看
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 项奖励
回复
3,154 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Rotert,

Thanks for your sharing .

BR

Alice

0 项奖励
回复