|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
必备8 p# ?0 Q) `* ^6 e( U7 j0 T% e! y
在讲解各编译器之前,必须先了解一下以下文件。这些文件在编译器目录下或者编译生成目标平台的可执行程序时经常见到。此外,还需要注意区分 Windows 平台 和 Linux 平台的文件。 ]/ `: G; |" s
* z5 t$ `. w9 W2 d0 S) F- .o 文件: 指的是 object 文件,俗称目标文件。在 Linux 下扩展名缩写为 .o,在 windows 下通常为 .obj 文件。
- .a 文件: 指的是 archive 文件,俗称静态库文件。在 Linux 下扩展名缩写为 .a,在 windows 下通常为 .lib 文件。
- .so 文件: 指的是 shared object 文件,用于动态连接的。在 Linux 下扩展名缩写为 .so,在 windows 下通常为 .dll 文件。
6 n+ h* n" Y8 y, w s
9 Z [% O6 |4 E8 H0 K; F.o 文件是链接文件,.a 是静态库文件,需要 .o 文件生成,作为一个库为外部程序提供函数接口。详细的可以看一下博文 ARM 之一 镜像文件(Image)/可执行文件/ELF文件/对象文件 详解。
$ Z6 Y- S4 \8 @; @0 n3 l% I
- W& f; V9 P- S 在交叉编译工具链目录中,有大量的 .o 和 .a 文件。这些文件在我们编译目标平台时会被用到!为什么在Windows下面的编译工具链中会有这么多的 .o 和 .a 文件呢?这是因为编译工具链是在 Linux 系统 中编译生成的! 。看下图:5 W4 v9 q; Q, K+ ?5 g% J& N
9 y: D- T" g* t, s
+ \ ? `9 a ?2 W7 I6 c7 P
$ r, f# p2 t" c& N" d. s如果有亲自编译过交叉编译工具链,那么就一定会见到 build、host 和 target 这几个参数:
$ X7 |; Q2 o* S8 q( L( c
- j5 |% D/ @$ k( M- –build=编译该软件(就是指的交叉编译工具链本身)所使用的平台
- –host=该软件(就是指的交叉编译工具链本身)将运行的平台
- –target=该软件(就是指的交叉编译工具链本身)所要处理的目标平台。即交叉编译工具链编译出来的程序运行的平台0 q" v# O! n% Q5 u
" p4 ?7 [ u, c
比较
; z8 W B+ l, n) @# d- q) _, X目前,针对于 ARM 平台的主流编译器主要有以下三者:
0 X; k1 U; G. r" X9 m- q6 E8 G+ _
! m7 E+ l2 v* U4 x& d' o比较 ARMCC IAR GCC for ARM* I. r2 ]. n- F8 G5 s: v
命令行工具 随IDE发布,也独立提供 仅随其IDE发布,不独立提供 独立提供
- I) q5 V- ~+ P开发商 ARM IAR ARM、Linaro、mentor3 `$ h! z! Z# N; N8 v9 Y4 [6 y# X
支持的平台 Windows、Linux Windows Windows、Linux、Mac(部分)
3 {; D% {# S' L3 Q0 n* f* n配套 IDE Keil MDK、ARM Development Studio 5、ADS IAR EMBEDDED WORKBENCH FOR ARM 除以上两者外的其他支持ARM的IDE,例如:eclipse、Visual Studio. K% N. L, ~& s+ e
6 t) z7 I; n& b, ~7 [
ARM ARM 官网上除了提供了配套 IDE(参考博文《ARM 之 各集成开发环境(IDE)说明(Keil、RVDS、ADS、DS-5、MDK)》) 以外,每次都会提供编译器的独立下载。用户可以单独安装编译器,编译器采用命令行形式使用。
8 `+ V' f0 X) _+ f$ h4 o 也就是说,ARM 的 IDE 和编译器是相互独立的,使用者可以为同一个IDE配置不同版本的编译器!目前,ARM 官方提供两个版本的编译器,如下图所示:
! V: ?) H9 V9 [ L) d# ?
$ W3 n$ ^# k! z* s
0 L. b9 d( A) n4 q
! N h' F* c0 H3 D) o! c 其中,Arm Compiler 6 是 Arm Compiler 5 的替代者!相比于 Arm Compiler 5 的 Edison Design Group 使用的编译器前端,Arm Compiler 6 将编译器前端换为了基于 LLVM 的 Clang!. E0 I+ |4 i; o$ {1 L: \
' i2 n" ^* e: V' e; J
8 a* y' q$ s H' g* d3 z
! ~: N( n# |. l9 }' r, H* `2 g在 ARM 官网的介绍中,有如下一段话
) A: H, D7 y4 c& a. p& r+ H) oGeneral update releases on the last branch, version 5.06, ended in H2 2017 with 5.06u6. After this, further support and maintenance will be available through Arm Compiler Long Term Maintenance releases with maintenance continuing until at least summer 2020. Arm Compiler 5.06 for Certification and Arm Compiler 5.06 Long Term Maintenance releases will each be supported by an Arm Compiler Qualification Kit.
% e: }( Q; m" W9 v6 R6 `2 l/ K大意就是,Arm Compiler 5 以后就要退出舞台了!在 ARM 内核的支持上,Arm Compiler 6 也要比 Arm Compiler 5 完善的多!
, ^8 N6 Z5 ?4 R& H, v$ E& u# R1 }目前,ARM 官方的 IDE都会包含这两个版本的编译器。例如,在 Keil MDK 的安装目录下面会有如下两个目录,分别对应了 Arm Compiler 5 和 Arm Compiler 67 T. t& {% s. u4 d: m
5 ?* A2 U8 J" v, ~0 ~( g
" A7 h' K( O: @% o- k; m! T
. u$ n7 a6 Y" p
上面说了,以上编译器 ARM 也提供独立下载安装,具体见上文的官网地址即可!我本身安装了多个版本的 ARM编译器,如下:
+ B) u$ s' u x) v9 Q$ `7 T" K. E9 T' ?
# u% H# ~) Y2 c- ?- {) N0 ^
9 z8 m1 H% w1 o
- Edison Design Group 是一家公司,靠卖产品给卖编译器的公司生存,它卖的是前端,包括C++、Java和Fortran前端,全世界几乎所有商用编译器,都会用这家公司的前端。最重要的,这家公司只有5个人。
% O; v: e+ |' k$ X% i/ v6 v( @% o; w' ^这五个人依次是:Mike Miller, Daveed Vandevoorde, Steve Adamczyk, John Spicer, Mike Herricl。Daveed Vandevoorde 写过两本书《C++ Templates》和《C++ Solutions》,Mike Miller是C++专家,实现部分C++的功能。Mike Herrick在Bell实验室呆了19年。Steve Adamczyk和John Spicer是EDG的创建者。 - 在最早期,ARM 的编译器也是随 IDE 发布的,如 ADS 时代!; ~8 J! Q) v7 X. ~3 |
0 I% K# `- i F* Darmcc.exe
! V1 J3 p6 N3 P* ~; S0 Q The ARM and Thumb® compiler. This compiles your C and C++ code.It supports inline and embedded assemblers, and also includes the Advanced SIMD vectorizingcompiler. ARM和Thumb®编译器。 这将编译您的 C 和 C++代码。它支持内联和嵌入式汇编程序,还包括高级SIMD矢量化编译器。
/ f- M4 V) b) p8 m( O" D( x j6 D 编译器支持将以下不同标准的C和C ++源代码编译为 ARM 和 Thumb® 代码:# B9 v5 m* V4 u/ V( _! y9 P* \0 o
" X' L: o7 f& Z3 ]) b) D7 Y. G3 W- ISO Standard C:1990 source.
- ISO Standard C:1999 source.
- ISO Standard C++:2003 source.
- ISO Standard C++:2011 source.
9 m2 l% c( q2 K0 }% y: m: p
- D. u* R* C" H' E8 {armcc 符合 Base Standard Application Binary InteRFace for the ARM Architectur(ARM体系结构的基本标准应用程序二进制接口,BSABI)。 特别是编译器:
/ `/ I$ @/ Q% C5 z7 ?, M/ w( |- |. S( B- r0 F
- 生成 ELF 格式的对象文件。 参考博文《ARM 之 镜像文件(Image)/可执行文件/ELF文件/对象文件 详解》。
- 生成基于 Debug With Arbitrary Record Format Debugging Standard Version 3 (DWARF 3) 的调试信息 并且包含对于 DWARF 2 debug tables的支持。
- 使用 Edison Design Group (EDG) 编译器前端!
$ N1 j- }# O4 g
" J/ w5 T0 Z7 [( g/ z- D:\ARM\ARM_Compiler_5.06u4>armcc
- Product: ARM Compiler 5.06
- Component: ARM Compiler 5.06 update 4 (build 422)
- Tool: armcc [4d3604]
- Usage: armcc [options] file1 file2 ... filen
- Main options:
- --arm Generate ARM code 创建 ARM 代码
- --thumb Generate Thumb code 创建 Thumb 代码
- --c90 Switch to C mode (default for .c files) 切换到C模式 (默认是 .c 文件)
- --cpp Switch to C++ mode (default for .cpp files) 切换到C++模式 (默认 .cpp 文件)
- -O0 Minimum optimization 最小优化级别
- -O1 Restricted optimization for debugging 受限的调试级别优化
- -O2 High optimization 高优化
- -O3 Maximum optimization 最大优化
- -Ospace Optimize for codesize 对代码大小进行优化
- -Otime Optimize for maximum performance 优化最大优化级别的运行时间
- --cpu <cpu> Select CPU to generate code for 选择CPU
- --cpu list Output a list of all the selectable CPUs 输出所有被选中的CPU列表
- -o <file> Name the final output file of the compilation 最终输出文件的名字
- -c Compile only, do not link 只进行编译,不链接
- --asm Output assembly code as well as object code 输出汇编以及obj文件
- -S Output assembly code instead of object code 只输出汇编文件
- --interleave Interleave source with disassembly (use with --asm or -S) 交叉反汇编 (use with --asm or -S)
- -E Preprocess the C source code only 仅仅预处理C代码
- -D<symbol> Define <symbol> on entry to the compiler 定义 <symbol> 符号并且传入编译过程
- -g Generate tables for high-level debugging 为高级别调试创建表
- -I<directory> Include <directory> on the #include search path 在编译的时候包含 <directory> 作为头文件搜索目录
Q$ c/ ~9 E/ q2 y$ m6 y/ N+ O# q
- V6 {! @( t6 ^7 e" T- k( }9 z9 L8 E8 F; _9 T1 A
其默认的头文件搜索路径如下图所示:: u5 R) l/ P, Y4 L1 w' W
5 q- Q* W. T3 _! w3 O
8 \: f, X$ N$ ^6 a3 Y& A
+ a, M& y. u9 _ g( o7 P- u- I, _8 A- E
armasm.exe5 g3 I6 r' Y4 K) W d8 y9 b7 v0 x
The ARM and Thumb assembler. This assembles ARM and Thumb assembly language sources. ARM 和 Thumb 汇编器。这将汇编 ARM 和 Thumb 汇编语言源文件。9 Y/ F9 G$ N6 l- @1 H
" J. e' Y4 M! A5 U5 k% ?
- D:\ARM\ARM_Compiler_5.06u4>armasm
- Product: ARM Compiler 5.06
- Component: ARM Compiler 5.06 update 4 (build 422)
- Tool: armasm [4d35cf]
- For Educational purposes only
- Software supplied by: ARM Limited
- Usage: armasm [options] sourcefile
- Options:
- --list listingfile Write a listing file (see manual for options) 生成列表文件
- -o outputfile Name the final output file 命名最终输出文件名
- --depend dependfile Save 'make' source file dependencies 保留 'make' 源文件依赖
- --errors errorsfile Put stderr diagnostics to errorsfile 把标准错误判断放入errorsfile
- -I dir[,dir] Add dirs to source file search path 添加源文件的搜索目录
- --pd
- --predefine directive Pre-execute a SET{L,A,S} directive 预执行 SET{L,A,S} 指令
- --maxcache <n> Maximum cache size (default 8MB) 最大闪存空间 (default 8MB)
- --no_esc Ignore C-style (\c) escape sequences 忽略C风格(\ c)转义序列
- --no_warn Turn off Warning messages 关闭警告信息
- -g Output debugging tables 输出调试表
- --apcs /<quals> Make pre-definitions to match the
- chosen procedure-call standard 进行预定义以匹配选择的程序调用标准
- --checkreglist Warn about out of order LDM/STM register lists 警告LDM/STM寄存器列表出现故障
- --help Print this information 打印帮助信息
- --li Little-endian ARM 小端模式的 ARM
- --bi Big-endian ARM 大端模式的 ARM
- -M Write source file dependency lists to stdout 将源文件依赖关系列表写入stdout
- --MD Write source file dependency lists to inputfile.d 将源文件依赖关系列表写入inputfile.d
- --keep Keep local labels in symbol table of object file 将本地标签保存在目标文件的符号表中
- --regnames none Do not predefine register names 不预定义寄存器名称
- --split_ldm Fault long LDM/STM
- --unsafe Downgrade certain errors to warnings 将某些错误降级为警告
- --via <file> Read further arguments from <file> 从<file>中读取更多参数
- --cpu <target-cpu> Set the target ARM core type 设置目标ARM核心类型
- --cpu list Output a list of all the selectable CPUs 输出所有可选CPU的列表
- --fpu <target-arch> Set target FP architecture version 设置目标FP架构版本
- --fpu list Output a list of all selectable FP architectures 输出所有可选FP架构的列表
- --thumb Assemble Thumb instructions 汇编 Thumb 指令
- --arm Assemble ARM instructions 汇编 ARM 指令
3 T% T: z4 C! }4 A' A* u ! p! W/ N6 s* _6 e5 X
; W; T( e$ j! B
armlink.exe
" f6 j/ W; C( a0 ?( ~+ N* t The linker. This combines the contents of one or more object files with selected parts of one ormore object libraries to produce an executable program.A 64-bit version of armlink is also provided that can access the greater amount of memoryavailable on 64-bit machines. It supports all the features that are supported by the 32-bit versionof armlink in this release. 连接器。这将一个或多个目标文件的内容与一个或多个对象库的选定部分组合在一起,以生成可执行程序。还提供了64位版本的armlink,可以访问64位计算机上可用的更大内存量。它支持此版本中32位版本的armlink支持的所有功能。) R# K8 V: }5 @/ ?& I
If you are using ARM Compiler as a standalone product, then the 32-bit version is used bydefault. 如果您使用ARM编译器作为独立产品,则默认使用32位版本。
9 Z1 Y6 ]& Y) v) ^7 u6 G For ARM Compiler in DS-5, the linker version depends on the host platform. 32-bit tools havethe 32-bit linker and 64-bit tools have the 64-bit linker. You do not get both versions.For the Microcontroller Developer Kit (MDK), only the 32-bit linker is provided. 对于DS-5中的ARM编译器,链接器版本取决于主机平台。 32位工具具有32位链接器,64位工具具有64位链接器。 您没有获得这两个版本。对于微控制器开发工具包(MDK),仅提供32位链接器。
2 u& u5 k* K0 s
+ C+ h i$ c" a7 J8 _* {- D:\ARM\ARM_Compiler_5.06u4>armlink
- Product: ARM Compiler 5.06
- Component: ARM Compiler 5.06 update 4 (build 422)
- Tool: armlink [4d35d2]
- For Educational purposes only
- Software supplied by: ARM Limited
- Usage: armlink option-list input-file-list
- where
- option-list is a list of case-insensitive options. 不区分大小写的选项列表。
- input-file-list is a list of input object and library files. 输入对象或者库文件列表。
- General options (abbreviations shown capitalised):
- --help Print this summary. 显示帮助信息。
- --output file Specify the name of the output file. 指定输出文件名。
- --via file Read further arguments from file.
- Options for specifying memory map information:
- --partial Generate a partially linked object. 创建一个被分散链接的对象文件。
- --scatter file Create the memory map as described in file. 按文件(分散加载文件)中的描述创建内存映射。
- --ro-base n Set exec addr of region containing RO sections. 设置执行地址空间域,包含RO段(只读数据段)。
- --rw-base n Set exec addr of region containing RW/ZI sections. 设置执行地址空间域,包含RW/ZI段。
- Options for controlling image contents:
- --bestdebug Add debug information giving best debug view to image. 添加调试信息,为镜像提供最佳调试视图。
- --datacompressor off
- Do not compress RW data sections. 不要压缩RW数据段。
- --no_debug Do not add debug information to image. 不添加调试信息。
- --entry Specify entry sections and entry point. 指定输入段与输入点。
- --libpath Specify path to find system libraries from. 指定系统库文件路径。
- --userlibpath Specify path to find user libraries from. 指定用户库文件路径。
- --no_locals Do not add local symbols to image symbol table. 不要添加局部标号到image的标号列表。
- --no_remove Do not remove unused sections from image. 不要移除image的未使用段。
- Options for controlling image related information:
- --callgraph Create a static callgraph of functions. 创建一个函数静态调用图。
- --feedback file Generate feedback that can be used by the compiler in file.
- --info topic List misc. information about image.
- Available topics: (separate multiple topics with comma)
- common List common sections eliminated from the image.
- debug List eliminated input debug sections.
- sizes List code and data sizes for objects in image.
- totals List total sizes of all objects in image.
- veneers List veneers that have been generated.
- unused List sections eliminated from the image.
- --map Display memory map of image. 显示image内存映射。
- --symbols List symbols in image. 列出image符号。
- --xref List all cross-references between input sections. 列出输入的段之间所有的交叉引用.最终输出会放在.map文件里面。& p8 `, y8 P$ [5 r* n# [9 Q
H0 R; y- ?# g. l# p, N' c6 C. e
8 e K& j" m/ q) S
armar.exe
5 b( K* {: A* a- {The librarian. This enables sets of ELF object files to be collected together and maintained inarchives or libraries. You can pass such a library or archive to the linker in place of several ELFfiles. You can also use the archive for distribution to a third party for further applicationdevelopment. 库文件管理工具。 这使得 ELF 对象文件集可以一起收集并维护在原始文件或库中。 您可以将此类库或存档传递给链接器以代替多个ELF文件。 您还可以使用存档分发给第三方以进行进一步的应用程序开发。
% H8 s8 V W" m b: Y
& t+ N6 E6 S) i- D:\ARM\ARM_Compiler_5.06u4>armar
- Product: ARM Compiler 5.06
- Component: ARM Compiler 5.06 update 4 (build 422)
- Tool: armar [4d35c8]
- Archive creation and maintenance tool
- Command format:
- armar options archive [ file_list ]
- Wildcards '?' and '*' may be used in file_list
- Options:-
- -r Insert files in <file_list>, replace existing members of the same name. 在 <file_list> 中插入文件, 替换掉已经存在的同名成员。
- -d Delete the members in <file_list>. 从 <file_list> 中删除成员。
- -x Extract members in <file_list> placing in files of the same name. 从 <file_list> 中提取同名的成员。
- -m Move files in <file_list>. 在 <file_list> 中移动文件。
- -p Print files to stdout. 打印文件到标准输出设备。
- -a pos Insert/move files after file named <pos>. 插入/删除 <pos> 后面的文件。
- -b pos Insert/move files before file named <pos>. 插入/删除 <pos> 前面的文件。
- -u Update older files only, used with -r. 只更新旧的文件, 与 -r 一起使用。
- -n Do not add a symbol table to an object archive. 不要向 object 文件中添加符号表。
- -s Force regeneration of archive symbol table. 强制重新生成文档符号表。
- -t Print table of contents of archive. 打印文档的内容表。
- --zs Show the symbol table. 显示符号表。
- --zt Summarize the archive contents (sizes + entries). 汇总文档内容 (大小和输入)。
- -c Suppress warning when a new archive is created. 当一个新文档被创建的时候不显示警告。
- -C Do not overwrite existing files when extracting. 提取的时候不要覆盖一个已经存在的文件。
- -T Truncate file names to system maximum length. 截取系统最大长度文件名。
- -v Give verbose output. 提供详细输出。
- --create Force creation of a new archive. 强制创建一个新文档。
- --via file Take additional arguments from via file. 从 via 文件中获取额外参数。
- --sizes List the size of each member and the library total. 列出所有成员大小与库的总大小。
- --entries List sections containing ENTRY points. 列出包括入口点的部分。
- --vsn Print the current Armar Version. 打印最新的armar版本。
- --help Print this message. 打印帮助信息。
- Examples:-
- armar -r mylib.a obj1 obj2 obj3...
- armar -x mylib.a ?sort*
- armar -d mylib.a hash.o
- armar -tv ansilib.a
+ U( b, e5 c' V- Y1 w$ a) t3 h7 S
" Q8 a3 d8 B5 G4 a( i" O; l/ i/ [6 Q9 o/ m9 h8 x
fromelf.exe
& e6 x8 b8 z1 l" R* M M" ]1 Y5 |The image conversion utility. This can also generate textual information about the input image,such as its disassembly and its code and data size.镜像转换实用程序。 这还可以生成有关输入图像的文本信息,例如其反汇编及其代码和数据大小。
5 {" D2 h" w5 O6 {6 ~0 u) F3 }9 E. \' M
- D:\ARM\ARM_Compiler_5.06u4>fromelf
- Product: ARM Compiler 5.06
- Component: ARM Compiler 5.06 update 4 (build 422)
- Tool: fromelf [4d35cb]
- ARM image conversion utility. ARM 镜像转换工具
- fromelf [options] input_file
- Options:
- --help display this help screen 显示帮助信息
- --vsn display version information 显示版本信息
- --output file the output file. (defaults to stdout for -text format) 输出文件名. (默认输出 -text 格式)
- --nodebug do not put debug areas in the output image 不要输出调试信息到映像文件中
- --nolinkview do not put sections in the output image 不要输出段信息到映像文件中
- Binary Output Formats:
- --bin Plain Binary 普通二进制
- --m32 Motorola 32 bit Hex 摩托罗拉32位Hex码
- --i32 Intel 32 bit Hex 英特尔32位Hex码
- --vhx Byte Oriented Hex format 定向字节的 Hex 格式
- --base addr Optionally set base address for m32,i32 为 m32,i32设置基地址(可选的)
- Output Formats Requiring Debug Information 输出格式要求的调试信息
- --fieldoffsets Assembly Language Description of Structures/Classes. Structures/Classes的汇编描述
- --expandarrays Arrays inside and outside structures are expanded. 展开内部和外部结构的数组
- Other Output Formats:
- --elf ELF ELF格式
- --text Text Information 文本信息
- Flags for Text Information 文本信息的标志
- -v verbose 详细信息
- -a print data addresses (For images built with debug) 打印数据的地址信息 (得到的.axf映像文件)
- -c disassemble code 汇编码
- -d print contents of data section 打印数据的段内容
- -e print exception tables 打印异常表
- -g print debug tables 打印调试表
- -r print relocation information 打印重定位信息
- -s print symbol table 打印符号表
- -t print string table 打印字符表
- -y print dynamic segment contents 打印动态段内容
- -z print code and data size information 打印代码与数据的大小信息
2 k( @! {0 @- y Z y% c% } 6 w& ?) C8 g! l% i& u( D, t' f( l, i
2 R4 T6 u6 ^: e' h. ^ |
|