加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

IAR的编译过程

发布时间:2020-12-15 06:21:07 所属栏目:百科 来源:网络整理
导读:stm32 函数库 FWlib2.0.3 FWlib3.5 ? 见 ? ? ??http://download.csdn.net/detail/xuehui869/4205152 IAR for Arm的文档 ? 见http://download.csdn.net/detail/xuehui869/4106746 STM32的相关datasheet ? 见http://download.csdn.net/detail/xuehui869/420498

stm32 函数库 FWlib2.0.3 FWlib3.5

? 见 ? ? ??http://download.csdn.net/detail/xuehui869/4205152

IAR for Arm的文档 ?见http://download.csdn.net/detail/xuehui869/4106746

STM32的相关datasheet ?见http://download.csdn.net/detail/xuehui869/4204982

1.?? 使用IAR compiler + assembler,对工程的每个".c/.cpp/.asm",分别生成一个.o文件,为可重定位ELF,叫做symobol。(内含的目标代码实际为机器码)

2.?? 使用IAR linker对上步产生的 "relocatable objectfiles(eg:可重定位ELF)? .o"+“.icf”链接

3.?? 最终产生可执行ELF或者bin等。(IAR的调试系统C-SPY会根据ELF文件产生进行JLIINK在线调试,因为该文件中包含了每个obj在内存中的绝对地址。而且对于函数而言,虽然其内部的局部变量在运行时的地址不是固定的,但由于程序经过固定程式的编译已经是确定性事件,所以C-SPY根据该文件的信息是可以预测的)

?

--说明:根据上面的过程,利用.o可以生成“可以安装、动态管理的软件“

有两种设想(对于一个已经链接好了的最小单位镜像而言):

(1). 编译之后至链接之前:在镜像文件的头部设置标号,后面的bin引用地址的时候根据这个标号(基地址)偏移。这样,在linker链接的时候,就可以很方便的分配绝对地址了。

(2).在程序加载时,在镜像的头部设置一个变量,该变量可以动态改变[A1]?。同样,其后的地址也以此偏移,这样就可以动态改变一个模块程序的存储器地址,实现动态加载、程序安装、管理了。

ELF文件格式参见《链接器与加载器》“Unix ELF格式”章节,或者wiki.

?

?

MAP文件

?

第一部分:

***PLACEMENT SUMMARY? 位置总括

?

"A1":? place at 0x08000000 { ro section .intvec};----启动文件

"P1":? place in [from 0x08000000 to 0x0807ffff] { ro};-------代码与常量(.text、.rodata)

"P3":? place in [from 0x20000010 to 0x2000ffff] {

?????????rw,block CSTACK,block HEAP };-----RAM区。规划.data 、.bss、栈、堆

Section??????????? Kind??????? Address???? Size?Object

“A1”:

.intvec?????????????????? ? ro code

?

“P1”??????????????????????????????????

.text????????????????????? ? ro code

.rodata????????????????? ? const

?

"P3",part 1 of 3:

HEAP?????????????????? ? uninit

CSTACK????????? uninit

.iar.dynexit??????????? ? uninit

?

"P3",part 2 of 3:??

.data??????????????????????????? ? inited

?

"P3",part 3 of 3:

.bss?????????????????????? ? zero

?

?

?

第二部分:

***INIT TABLE----------------------------------启动过程中,变量的初始化

?

? ????????Address???? Size

?????????-------???? ----

Zero (__iar_zero_init3)------------------------------------.bss段

??? 1destination range,total size 0x71c6:

?????????0x2000362c? 0x71c6

?

Copy/packbits (__iar_packbits_init3)--------------------------------.data段

??? 1source range,total size 0x387 (84% of destination):

?????????0x0801bcad?? 0x387

??? 1destination range,total size 0x42e:

?????????0x200031fc?? 0x42e

?

?

第三部分:

*** MODULE SUMMARY????????? 模块概览

???Module???????????????????? rocode? ??????ro data?????????rw data

??? 各个目标文件

??? (每个.c生成一个)???????? 只读代码?????常量??? ???????????变量

?

各个文件:

?

command line: [2]

?

动态库

dl7M_tl_if.a: [3]

?

rt7M_tl.a: [4]

?

shb_l.a: [5]

?

第四部分:

*** ENTRY LIST:???????? 入口目录

?

Entry???????? Address ?????Size ????Type????????????????? ???????????????Object

实体名?????? 地址?????? ??大小??? 种类(Code or Data)?Gb or Lc???????? 目标文件

(函数/变量)

?

?

?

?

?

结果:

[1] = D:fenlei12work状态机软件p200_v2P200ProcProject_PBOCDebugObj

[2] = command line

[3] = dl7M_tl_if.a

[4] = rt7M_tl.a

[5] = shb_l.a

?

? 100796 bytes of readonly? code memory

?? 13944 bytes of readonly? data memory

?? 42976 bytes of readwrite data memory

?

Errors: none

Warnings: none

?

?

?

附录:

一、从目标文件到下载

二、目标文件的segment分配

三、程序的启动

1 When an application is started,thesystem startup code first performs hardware

initialization,such as initialization ofthe stack pointer to point at the end of the

predefined stack area:

2 Then,memories that should bezero-initialized are cleared,in other words,filled with

zeros:

3 For initialized data,data declared,forexample,like int i = 6; the initializers are

copied from ROM to RAM:

Figure 6: Initializing variables

4 Finally,the main function is called:

四、

?

类似于linux程序的编译过程以及SVN windows软件,IAR软件由工作区(windows外壳)和分散的模块组成(比如编译器 IarBuild、链接器ILink)组成。实质上,不用IAR提供的集成开发环境,使用那些命令行工具开发也是可行的。

?

?

IAR编译后,产生这几个目录.

?

(1)、

Exe--------------execute 可执行文件包

???????????

???????????????????? /.bin:纯镜像文件

???????????????????? /.sim:flash loader 在烧flash时会用到*.sim文件

???????????????????? /.out:C-SPY JLINK在线调试用到的ELF/DWARF文件

以下摘自help:

Build considerations
When you build an application that will be downloaded to flash,specialconsideration is needed. Two output files must be generated. The first is theusual ELF/DWARF file (out) that provides the debugger with debug and symbolinformation. The second file is a simple-code file (filename extension sim)that will be opened and read by the flash loader when it downloads theapplication to flash memory.

The simple-code file must have the same path and name as the ELF/DWARF fileexcept for the filename extension. This file is automatically generated by thelinker.

(2).

List

每个.c产生一个.lst及.s

/.lst? list文件

/.s?? 汇编文件

(3)

Obj

????????

????????????? /.o? 编译后生成的ELF可重定位目标文件

????????????? /.pbiThis is an internal working file generated by the Source Browser.


?[A1]最好是CPU硬件支持,有个基地址寄存器。这个就简单多了

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读