IAR的编译过程

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:\fenlei12\work\状态机软件\p200_v2\P200Proc\Project_PBOC\Debug\Obj

[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硬件支持,有个基地址寄存器。这个就简单多了

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在VSCode中使用IAR编译器进行译需要进行一些配置。以下是一般的步骤: 1. 安装VSCode:首先确保你已经安装了VSCode编辑器,并且它能够正常运行。 2. 安装C/C++扩展:在VSCode中,点击左侧边栏的扩展按钮(四个方块图标),搜索并安装"ms-vscode.cpptools"扩展,这个扩展提供了对C/C++代码的支持。 3. 配置编译器路径:打开VSCode的设置(快捷键:Ctrl + ,),在搜索框中输入"C++",找到"C++: Intelli Sense engine"选项,将其设置为"Tag Parser"。然后找到"C++: Default"选项,点击"Edit in settings.json",在打开的settings.json文件中添加以下代码: ```json { "C_Cpp.default.intelliSenseMode": "tag-parser", "C_Cpp.default.compilerPath": "iar_compiler_path" } ``` 将`iar_compiler_path`替换为你IAR编译器的安装路径。 4. 创建任务:在VSCode中,点击菜单栏的"Terminal" -> "Configure Default Build Task",选择"Others"。然后在.vscode目录下会生成一个tasks.json文件,在其中添加以下代码: ```json { "version": "2.0.0", "tasks": [ { "label": "Build with IAR", "type": "shell", "command": "iar_compiler_path", "args": [ "your_project_file" ], "group": { "kind": "build", "isDefault": true } } ] } ``` 将`iar_compiler_path`替换为你IAR编译器的安装路径,将`your_project_file`替换为你要编译的项目文件路径。 5. 编译项目:在VSCode中,按下Ctrl + Shift + B,选择"Build with IAR"任务,即可开始编译你的项目。 请注意,以上步骤是一个基本的配置过程,具体步骤可能会因你的具体情况而有所不同。如果遇到问题,建议参考IAR编译器和VSCode的官方文档进行配置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值