IAR 问题:Label 'Reset_Handler' is defined pubweak in a section implicitly declared root

本文介绍使用IAR 7.10.1编译STM32项目时遇到的Warning[25]问题及其解决办法。此警告源于过时的汇编构造,通过在SECTION声明中添加NOROOT可以消除警告。
AI助手已提取文章相关产品:
IAR编译STM32的M3,早期的版本,需要使用core_cm3文件,6版后就不使用它了。

在使用6版的编译成功的项目,现在使用7.1编译,就会出警告,
它来自:
   startup_stm32f10x_hd.s
文件,内容如:
    Warning[25]: Label 'Reset_Handler' is defined pubweak in a section implicitly declared root
等,产生的map文件中:
           .intvec            ro code  0x08000000    0x130  startup_stm32f10x_hd.o [1]

                                            - 0x08000130    0x130


解决方法:

Problem

After upgrading to EWARM 7.10.1 the Warning[25] is issued during assembly of a file that assembled without warning on earlier version of EWARM.

Background

The assembler (iasmarm) is (from EWARM 7.10.1) issuing Warning[25] for a deprecated assembler construction.

The deprecated assembler source construction looks like this:

      PUBWEAK NMI_Handler
      SECTION .text:CODE:REORDER(1)
  NMI_Handler
Solution

To avoid the warning, add ":NOROOT" to the "SECTION" statement:

      PUBWEAK NMI_Handler
      SECTION .text:CODE:REORDER:NOROOT(1)
  NMI_Handler

您可能感兴趣的与本文相关内容

--- ### 🔍 错误分析: 你遇到的警告: ``` Warning[Pe223]: function "__iar_data_init3" declared implicitly ``` 表示你在 `flash_loader_ram.c` 文件中使用了 `__iar_data_init3()` 函数,但**没有提前声明**它。 IAR 编译器在 C89/C90 模式下允许隐式声明函数(即不提前声明就调用),但会给出警告。这种做法是不推荐的,因为可能导致运行时错误(比如参数类型不匹配、函数不存在等)。 --- ### ✅ 解决方案: 你需要在调用 `__iar_data_init3()` 之前,先声明这个函数。可以使用 `extern` 来告诉编译器这个函数的原型。 --- ### ✅ 修改方式: 在你的 `flash_loader_ram.c` 文件顶部添加如下声明: ```c extern void __iar_data_init3(void); ``` 例如,你的文件结构可能如下: ```c #include "flash_loader_ram.h" extern void __iar_data_init3(void); // 添加这行声明 void some_function(void) { __iar_data_init3(); // 现在编译器知道这个函数的原型了 // 其他初始化代码... } ``` --- ### 🔍 补充说明: - `__iar_data_init3` 是 IAR 编译器内部函数,用于初始化 `.data` 和 `.bss` 段。 - 它通常由启动文件(如 `cstart.s` 或 `cmain`)自动调用,但在某些裸机项目、Flash Loader 或 Bootloader 中需要手动调用。 - 如果你是在 Flash Loader 项目中工作(如 STM32 的 Flash Loader Demonstrator),手动调用它是必要的。 --- ### ✅ 建议做法: 如果你在 `main()` 函数或某个入口函数中使用它,建议这样写: ```c #include "stm32h7xx_hal.h" extern void __iar_data_init3(void); int main(void) { __iar_data_init3(); // 初始化 .data 和 .bss 段 HAL_Init(); SystemClock_Config(); // 其他初始化... } ``` --- ### ❗注意: - 不要将 `__iar_data_init3()` 与 `SystemInit()` 或 `HAL_Init()` 混淆。它们负责的是 MCU 和 HAL 层的初始化,不是 C 运行时环境的初始化。 - 如果你不调用 `__iar_data_init3()`,全局变量(`.data`)不会被正确初始化,`.bss` 段也不会被清零,程序行为将不可预测。 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值