简体   繁体   English

KEIL的__main中有哪些操作

[英]what operations in the __main of KEIL

Before running main() function in users' application, it will IMPORT __main and execute __main, so I wonder that what does this function do?在用户的应用程序中运行main() function之前,它会导入__main并执行__main,所以我想知道这个function是做什么的?

__main __主要的

copy rw variables from flash to ram?将 rw 变量从 flash 复制到 ram? initialize bss section?初始化 bss 部分? initialzie stack/heap section?初始化堆栈/堆部分? anything else?还要别的吗?

Does it initialize according to the scater file which defines the execute region?它是否根据定义执行区域的分散文件进行初始化?

Copied from https://developer.arm.com/documentation/100748/0618/Embedded-Software-Development/Application-startup复制自https://developer.arm.com/documentation/100748/0618/Embedded-Software-Development/Application-startup

Application startup应用启动

In most embedded systems, an initialization sequence executes to set up the system before the main task is executed.在大多数嵌入式系统中,执行初始化序列以在执行主任务之前设置系统。

The following figure shows the default initialization sequence.下图显示了默认的初始化顺序。

Figure 1. Default initialization sequence图 1. 默认初始化顺序在此处输入图像描述

Default initialization sequence __main is responsible for setting up the memory and __rt_entry is responsible for setting up the run-time environment.默认初始化顺序__main负责设置memory,__rt_entry负责设置运行时环境。

__main performs code and data copying, decompression, and zero initialization of the ZI data. __main 执行 ZI 数据的代码和数据复制、解压缩和零初始化。 It then branches to __rt_entry to set up the stack and heap, initialize the library functions and static data, and call any top level C++ constructors.然后它分支到 __rt_entry 以设置堆栈和堆,初始化库函数和 static 数据,并调用任何顶级 C++ 构造函数。 __rt_entry then branches to main(), the entry to your application. __rt_entry 然后分支到 main(),即您的应用程序的入口。 When the main application has finished executing, __rt_entry shuts down the library, then hands control back to the debugger.当主应用程序完成执行时,__rt_entry 关闭库,然后将控制权交还给调试器。

The function label main() has a special significance. function label main() 具有特殊意义。 The presence of a main() function forces the linker to link in the initialization code in __main and __rt_entry. main() function 的存在强制 linker 链接到 __main 和 __rt_entry 中的初始化代码中。 Without a function labeled main(), the initialization sequence is not linked in, and as a result, some standard C library functionality is not supported.如果没有标记为 main() 的 function,则不会链接初始化序列,因此,不支持某些标准的 C 库功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM