; W! y9 V/ W2 V
: l2 C+ k o- C
我们可以手动提取其编译器,来作为命令行工具使用。但是对于 IAR 还是不建议这么用,个人感觉 IAR 在设计时,估计没考虑过让用户使用命令行模式来独立使用编译套件,因为其编译套件和其他好多东西都放在了一个目录中,不像ARM 将编译套件独立存放。但是,IAR 的编译套件是支持命令行使用的 ,在其介绍文档中有这么一句话:The compiler, assembler, and linker can also be run from a command line environment,if you want to use them as external tools in an already established project environment. 官方的介绍文档主要就是《 IAR C/C++ Development Guide Compiling and Linking》。 5 M& z3 q7 F0 R s- _, U% _$ ]% ~# Q! y7 \% S9 H3 W* a
1. IAR 我用的比较少,主要内容来自于官方文档。管方文档更加详细,如有疑问直接去官方文档查看即可!官方文档目录为 IAR安装目录\arm\doc。具体如下: 5 u9 C7 B/ y( p, N% e9 {+ P. h
《 IAR C/C++ Development Guide Compiling and Linking》,文档名为 EWARM_DevelopmentGuide.ENU.pdf
- p7 {" E6 n4 Q% s; V& i( a+ ] c 3 I M! ^ q" Z/ V' v3 Wiasmarm.exe) V9 R$ E/ x8 ?. y" |
这个是 IAR 的汇编语言的编译器。官方文档是这么介绍的:The IAR Assembler for Arm is a powerful relocating macro assembler with a versatile set of directives and expression operators. The assembler features a built-in C language preprocessor and supports conditional assembly. 大意就是: IAR Assembler for Arm是一个功能强大的重定位宏汇编程序,具有多种指令和表达式运算符。 汇编程序具有内置的C语言预处理程序,并支持条件汇编。该工具官方有个独立的说明文档《IAR Assembler Reference Guide》,里面有该工具的详细使用说明。 - d0 S/ X* I9 u$ f/ z7 q, F0 X. P9 M! A$ I4 }/ o$ a i
Suppress Dwarf 3 Call Frame Information instructions
--no_it_verification
Do not verify that the instructions following
an IT instruction has the correct condition set
--no_literal_pool
Use MOV32 for LDR Rd,=expr (requires ARMv7-M)
--no_path_in_file_macros
Strip path from __FILE__ macros
--source_encoding {locale|utf8}
Encoding to use for source files with no BOM
--suppress_vfe_header
Do not generate VFE header info
--system_include_directory <path>
Set system header directory
--thumb Generate code in thumb mode, same as --cpu_mode thumb
--version Output version info and exit4 q$ v ]! y( g, n
$ X* F; G$ v | P6 h' e# g3 f8 L( I
iccarm.exe1 y, O. e2 X6 j5 {' }
这个是 IAR 的 C/C++ 编译器。官方文档是这么介绍的:The IAR C/C++ Compiler for Arm is a state-of-the-art compiler that offers the standard features of the C and C++ languages, plus extensions designed to take advantage of the Arm-specific facilities.大意就是: IAR C / C ++ Compiler for Arm是一个最先进的编译器,提供C和C ++语言的标准功能,以及旨在利用Arm特定功能的扩展。- `8 c" h7 }) p4 h+ M: s/ Y4 }
默认使用的头文件目录.\arm\inc\<vendor>: F( b1 r% t# H$ E& O
Generate functions for use from non-instrumented code
--guard_calls Use a guard call for a function static initialization
--header_context
Adds include file context to diagnostics
-I directory Add #include search directory
--ignore_uninstrumented_pointers
Disable checking of accesses via pointers from uninstrumented
functions
-l[c|C|D|E|a|A|b|B][N][H] file|directory
Output list file
c C source listing
C with assembly code
D with pure assembly code
E with non-sequential assembly code
a Assembler file
A with C source
b Basic assembler file
B with C source
N Do not include diagnostics
H Include header file source lines
--lock_regs registers
Prevent compiler from using specified registers (R4-R11).
--macro_positions_in_diagnostics
Use positions inside macros in diagnostics
--make_all_definitions_weak
Make all variable and function definitions weak
--max_cost_constexpr_call limit
Maximum cost (number of calls/number of loop iterations) when
evaluating a top-level constexpr call
--max_depth_constexpr_call limit
Maximum depth of recursion when evaluating a top-level
constexpr call
--mfc Enable multiple file compilation
--misrac1998[=arg,arg,...]
Enable MISRA-C 1998 diagnostics
all Enable all rules
required Enable all required rules
i Enable rule i
i-j Enable rule i through j
~i Disable rule i
~i-j Disable rule i through j
--misrac2004[=arg,arg,...]
Enable MISRA-C 2004 diagnostics
all Enable all rules
required Enable all required rules
X Enable rule or chapter
X-Y Enable range
~X Disable rule or chapter
~X-Y Disable range
where X and Y is one of:
i All rules in chapter i
i.j Rule i.j
--misrac_verbose
Enable verbose MISRA C messages
--nonportable_path_warnings
Enable warning for non-matching case in paths
--no_alignment_reduction
Disable alignment reduction of simple thumb functions
--no_bom Don't use a Byte Order Mark in Unicode output
--no_call_frame_info
Suppress output of call frame information
--no_clustering Disable static clustering for static and global variables
--no_code_motion
Disable code motion
--no_const_align
Turn off the alignment optimization for constants
--no_cse Disable common sub-expression elimination
--no_exceptions Disable C++ exception support
--no_fragments Do not generate section fragments
--no_inline Disable function inlining
--no_literal_pool
Generate code that does not issue read request to .text
--no_loop_align Disable alignment of labels in loops (Thumb2)
--no_mem_idioms Disable idiom recognition for memcpy/memset/memclr
--no_path_in_file_macros
Strip path from __FILE__ and __BASE_FILE__ macros
--no_rtti Disable C++ runtime type information support
--no_rw_dynamic_init
Don't allow C-object to be initialized at runtime
--no_scheduling Disable instruction scheduling
--no_size_constraints
Remove limits for code expansion
--no_static_destruction
Do not emit code to destroy C++ static variables
--no_system_include
Do not search in the default system header directory
--no_tbaa Disable type based alias analysis
--no_typedefs_in_diagnostics
Do not use typedefs when printing types
--no_unaligned_access
Don't generate unaligned accesses
--no_uniform_attribute_syntax
Use old meaning for IAR type attributes before initial type
--no_unroll Disable loop unrolling
--no_var_align Turn off the alignment optimization for variables
--no_warnings Disable generation of warnings
--no_wrap_diagnostics
Don't wrap long lines in diagnostic messages
-O[n|l|m|h|hs|hz]
Select level of optimization:
n No optimizations
l Low optimizations (default)
m Medium optimizations
h High optimizations
hz High optimizations, tuned for small code size
hs High optimizations, tuned for high speed
(-O without argument) The same setting as -Oh
--only_stdout Use stdout only (no console output on stderr)
--output file|path
-o file|path Specify object file
--pending_instantiations limit
Maximum number of instantiations of a given template in
progress at a time (0 -> no limit)
--predef_macros file|directory
Output predefined macros
--preinclude filename
Include file before normal source
--preprocess=[c][n] file|directory
Preprocessor output
c Include comments
n Preprocess only
s Suppress #line directives
--public_equ symbol[=value]
Define public assembler symbol (EQU)
--relaxed_fp Enable floating point optimizations that may affect the result
--remarks Enable generation of remarks
--require_prototypes
Require prototypes for all called or public functions
--ropi Generate read-only position independent code
--runtime_checking check,check,...
Instrument code to do runtime checks for the selected problems:
bounds Check pointer bounds
bounds_no_checks Track pointer bounds, but emit no checks
div_by_zero Check division by zero
implicit_integer_conversion
Check only implicit integer conversion
integer_conversion Check any integer conversion
signed_overflow Check for signed integer overflow
signed_shift Check for overflow in signed shift
switch Check for unhandled cases in switch
statements
unsigned_overflow Check for unsigned integer overflow
unsigned_shift Check for overflow in unsigned shift
--rwpi Generate read-write position independent code
--rwpi_near Generate read-write position independent code
--section section-name=new section-name
Rename section
--silent Silent operation
--source_encoding {locale|utf8}
Encoding to use for source files with no BOM
--stack_protection
Insert stack smash protection
--strict Strict C/C++ standard language rules
--system_include_dir directory
Set system header directory
--text_out encoding
Encoding to use for text output files
utf8 UTF-8
utf16le Little-endian UTF-16
utf16be Big-endian UTF-16
locale Locale specific encoding
--thumb Generate code in thumb mode, same as --cpu_mode thumb
--uniform_attribute_syntax
Same syntax for IAR type attributes as for const/volatile
--use_c++_inline
Use C++ inline semantics in C mode
--use_paths_as_written
Use paths as written in debug information
(normally absolute paths are used)
--use_unix_directory_separators
Use forward slashes in paths in debug information
--utf8_text_in Non-source text input files with no BOM use UTF-8 encoding
--vectorize Perform autovectorization
--version Output version information and exit
--vla Allow variable length arrays
--warnings_affect_exit_code
Warnings affect exit code
--warnings_are_errors
All warnings are errors
--warn_about_c_style_casts
Warn about uses of C-style casts in EC++/C++ : O. [: U) B7 I/ v( R+ W+ ~. O
& g `4 k! O' V. j& _. B/ o& _' k/ Y' f: Y
IDE中有两个工具可将应用程序源文件转换为中间文件目标文件。 IAR C / C ++编译器和IAR汇编器。 两者都产生行业标准格式ELF中的可重定位目标文件,包括DWARF调试信息的格式。下图显示了编译过程:6 S: @7 ^$ N% S8 m+ B
: ]1 f! ^0 s( V& f6 R, P3 Q: J$ T# r/ p) U0 ~ z
ilinkarm.exe# S* L2 p6 V7 Q
这个是 IAR 的连接器。官方文档是这么介绍的:The IAR ILINK Linker for Arm is a powerful, flexible software tool for use in the development of embedded controller applications. It is equally well suited for linking small, single-file, absolute assembler programs as it is for linking large, relocatable input, multi-module, C/C++, or mixed C/C++ and assembler programs. 大意就是:IAR ILINK Linker for Arm是一款功能强大,灵活的软件工具,可用于嵌入式控制器应用程序的开发。 它同样适用于链接小型,单文件,绝对汇编程序,因为它用于链接大型可重定位输入,多模块,C / C ++或混合C / C ++和汇编程序。 6 I9 v x8 @/ v3 H ilinkarm 使用并生成行业标准的ELF和DWARF作为对象格式文件。在.\arm\config目录下,包含了针对各平台的连接器使用的配置文件。 ?3 ~$ E: K. n# T5 k% i 4 N2 {1 B! c6 F- i% p
This example replaces module3.o in the library with the content in the module3.o file and appends module4.o to mylibrary.a:iarchive --replace mylibrary.a module3.o module4.o0 D8 J& _6 z4 m4 H
- f* ]5 U7 N! u# _. l: s1 Z
# A1 o) x$ a V6 @, ^/ S; {ielftool.exe4 y* T% I, j1 o2 f5 G
ARM ELF文件工具,类似于 ARM 的 fromelf 和 GCC 的 elfedit。对ELF可执行映像执行各种转换(例如,填充,校验和,格式转换等)。安装目录.\arm \ src\elfutils下提供了 ielftool 源代码(Microsoft VisualStudio项目)。 如果对如何生成校验和或格式转换要求有特定要求,则可以相应地修改源代码。" B g+ d) z/ V+ X+ Z2 p6 C
" U/ Q9 r5 c- K使用示例: P, m4 h% g7 ]) V7 r$ z
# I' O4 X/ \3 h
This example fills a memory range with 0xFF and then calculates a checksum on the same range:ielftool my_input.out my_output.out --fill 0xFF;0–0xFF --checksum __checksum:4,crc32;0–0xFF # N8 u( ~$ D2 v4 S* q9 ^
To produce a listing of the general properties of the input file and the ELF segments and ELF sections it contains. This is the default behavior when no command line options are used.生成输入文件的常规属性列表以及它包含的ELF段和ELF节。 当没有使用命令行选项时,这是默认行为。
To also include a textual representation of the contents of each ELF section in the input file. To specify this behavior, use the command line option --all .还包括输入文件中每个ELF部分内容的文本表示。 要指定此行为,请使用命令行选项–all。
To produce a textual representation of selected ELF sections from the input file. To specify this behavior, use the command line option --section 从输入文件生成所选ELF节的文本表示。 要指定此行为,请使用命令行选项–section e, ?4 R+ T( a
--f file Read command line options from file and report dependency
--no_bom Don't use a Byte Order Mark in Unicode output
--remove_file_path
remove path information from file symbol
--remove_section #|name
remove matching section(s)
--rename_section (#|name)=name
rename matching section(s)
--rename_symbol name=name
rename matching symbol
--strip strip debug information
--text_out encoding
Encoding to use for text output files
utf8 UTF-8
utf16le Little-endian UTF-16
utf16be Big-endian UTF-16
locale Locale specific encoding
--utf8_text_in Non-source text input files with no BOM use UTF-8 encoding
--version Output version information and exit0 }0 f$ G* W; g: J
0 Q, b1 s, C" f$ c2 L ' y1 s+ z) ~/ f) L9 R1 H使用示例:) |5 h3 _5 @7 E& {( N
5 @/ Z* U- I! L( B4 X$ y# H
This example renames the section .example in input.o to .example2 and stores the result in output.o:iobjmanip --rename_section .example=.example2 input.o output.o 2 c) l; Q: b# ]! u$ ^9 f4 {