STM8L programming problem: segment.text size overflow

Publisher:SparklingBeautyLatest update time:2020-04-14 Source: eefocusKeywords:STM8L Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#error clnk Debugsolar_charger.lkf:1 segment .text size overflow, indicating that the code segment overflows. At this time, because the STM8L firmware library is used, some unnecessary functions are compiled. You can try to comment out some unnecessary functions. If there are no functions that can be commented, you can try to select code optimization and compress the code in the project setting.

 

The most common problem is that when using a library, the code is prompted to exceed the memory range.


The amount of code is not large, but the compiler clearly indicates that the code exceeds the memory range. Why is this happening?


The main reason is that in order to handle errors properly, assert codes are added in the library file. At the same time, in order to provide all functional functions, there are many unused functions in the middle. However, in STM8L, although these useless functions are not connected to the execution code in the end, they are in the generated .o files. Since CxSTM8 judges the total size of .o before connection, rather than the size of the executable code after connection, although our code is very small, due to the excessive amount of unused code and error handling code in the library, the total size of the .o files before connection exceeds the range, causing the compiler to not connect. (Of course, it is also possible that the connection was made, but the executable file generated after the connection exceeded the requirement in size, so no executable file was generated. However, after commenting out some useless functions, the connection was successful, so it was judged that the connection was not made.)

 

In this case, not using library functions will inevitably reduce development efficiency. Using library functions will cause the generated code to exceed the memory size. At this time, the compromise is to still use library functions, but:

Comment out unused functions in the library;

Comment out some unnecessary assert statements in library functions;

Make some simple library functions into macro definitions and call them directly;

Avoid unnecessary code and reduce redundant code. (Be careful with assert codes)

Keywords:STM8L Reference address:STM8L programming problem: segment.text size overflow

Previous article:[STM8S Getting Started 1]: STM8SF103 compilation environment installation
Next article:STVD+COSMIC can't open file crtsi0.sm8 when compiling the project

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号