No linker error when exceeding m_text because of __DATA_ROM

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

No linker error when exceeding m_text because of __DATA_ROM

跳至解决方案
2,387 次查看
tommy1231
Contributor II

Using the default linker file for the S32k144 that the S32DS comes with, the linker fails to generate an error when the allowed size for the m_text is exceeded.  Looking at the linker file it doesn't directly put the data ROM into m_text but rather creates some variables and uses those.  This prevents the linker from generating an error when the assigned sized of m_text is exceeded.

 

In my case my linker for the m_text looks like this

m_text (RX) : ORIGIN = 0x00002404, LENGTH = 0x0000FBFC

I would expect that if anything stored in this section goes beyond 0x12000 the linker would generate an error.

If the .text section exceeds the size it triggers and error.

However these two sections also go into flash but do not trigger an error because they are not directly placed into m_text but rather use variables defined in the linker file (__DATA_ROM & __CODE_ROM)

.data : AT(__DATA_ROM)
.code : AT(__CODE_ROM)

How can I get the linker to properly trigger an error?  

标记 (3)
0 项奖励
回复
1 解答
2,280 次查看
raresvasile
NXP Employee
NXP Employee

Hi Tom,

Can you add the following line at the end of the linker script? (after line 208)

ASSERT(__CUSTOM_END >= (ORIGIN(m_text) + LENGTH(m_text)), "region m_text overflowed with code and rom data")

This should do the trick.

Best regards,

Rares

在原帖中查看解决方案

0 项奖励
回复
4 回复数
2,281 次查看
raresvasile
NXP Employee
NXP Employee

Hi Tom,

Can you add the following line at the end of the linker script? (after line 208)

ASSERT(__CUSTOM_END >= (ORIGIN(m_text) + LENGTH(m_text)), "region m_text overflowed with code and rom data")

This should do the trick.

Best regards,

Rares

0 项奖励
回复
2,280 次查看
tommy1231
Contributor II

Hi Rares,

It almost did the trick.  The ASSERT happens when the condition is false so I had to flip the greater than to a less than

ASSERT(__CUSTOM_END < (ORIGIN(m_text) + LENGTH(m_text)), "region m_text overflowed with code and rom data")

I would suggest that this gets added to the default linker files that S32 DS generates as others might run into this as well.

Thank you,

Tom

0 项奖励
回复
2,280 次查看
jiri_kral
NXP Employee
NXP Employee

Hi, 

I'm not sure about your scenario. By default - when section size is exceeded linker error message is shown: 

pastedImage_1.png

Can you share your project or .map file? 

What's your size output from build console? 

pastedImage_10.png

Jiri

0 项奖励
回复
2,280 次查看
tommy1231
Contributor II

Hi Jiri,

If I shrink the size of m_text enough I do get the error like you said

pastedImage_1.png

However if I make the size big enough for m_text to fit but not big enough for these sections it doesn't give an error

.data : AT(__DATA_ROM)
.code : AT(__CODE_ROM)

 

Notice if you add the text size to the data size it is 0xACC8 which is larger than I allowed the space to be

pastedImage_2.png

From the map file it goes past the allowed space (0x2404 + 0xA000 = 0xC404)

*fill* 0x1fff0ce9 0x3
0x1fff0cec __data_end__ = .
0x0000cca4 __DATA_END = (__DATA_ROM + (__data_end__ - __data_start__))
0x0000cca4 __CODE_ROM = __DATA_END

The generated srecord also shows it going beyond.

S113CCC438BD2B685A1CF2D09847F0E700000240A4

 

0 项奖励
回复