gpt4 book ai didi

c - Bare-Metal C : Why are some IDEs startup files doing things crt0. s 无论如何都会处理?

转载 作者:太空宇宙 更新时间:2023-11-04 04:39:28 27 4
gpt4 key购买 nike

我正在使用 Em::Blocks IDE 为 ARM Cortex-M3 微 Controller STM32F4 编写裸机 C 软件.

Here's the content of the startup_stm32f429x.S file which is included with the IDE.

  • 在第 169 到 192 行,您会看到 .data 部分填充了初始值。
  • 在第 199 行,它分支到 _start 符号,该符号在我的 GCC toolchain 的 crt0.s 文件中定义。
  • 第 211 到 223 行提供了它自己的代码,用于清除 .bss 部分。 (这里,_start 被再次定义,但很弱。因此,此代码仅在 _start 符号未在其他任何地方定义的情况下才有效。)

我的问题是:

  • 为什么启动文件提供初始化.data和清除.bss的代码?我以为那是 crt0.s 的工作?!
  • 正如我提到的,清除 .bss 的代码似乎只在 crt0.s 丢失的情况下才有效。
    • 听起来 crt0.s 有时可能会丢失。为什么 crt0.s 会丢失?为什么你不能依赖它可用?什么情况下会丢失?
    • 与此相反,为什么 .data 部分的初始化始终处于事件状态,而与 crt0.s 是否可用无关?

更新

我刚刚读到,设置异常 vector is another thing crt0.s is responsible for .再说一遍:为什么这在我的 startup file 中?在第 41 到 151 行完成?

最佳答案

正是因为您不想在裸机微 Controller 上使用 gcc 的 crt0,如果您不需要它的功能的话。如果您不使用 crt0,那么您将不得不自己做。

关于c - Bare-Metal C : Why are some IDEs startup files doing things crt0. s 无论如何都会处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27879129/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com