找回密码
 注册
关于网站域名变更的通知
查看: 2103|回复: 2
打印 上一主题 下一主题

详细了解一下ARM的主流编译器(armcc、iar、gcc for arm)(中)

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2020-9-2 15:33 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
本帖最后由 uperrua 于 2020-9-2 15:46 编辑
- p# x4 r1 F% ^( i$ T4 N' o
! p% I- f. p2 O2 T/ qIAR3 V# B8 r" _. s2 m) l$ f
  相比于 ARM 对于编译器的灵活安装,IAR 的编译器则只跟随其 IDE 发布,编译器不独立提供。IAR 安装后,目录就是下面这个样子了:6 g6 w- i  n4 s! ^2 ~
4 j& O$ x3 Q% Q( C
; w4 H, A! i1 }8 a! g+ ~& l

/ l7 a% L# o5 ]1 Y( E: ^这里我们重点关注一下arm目录下的相关内容。其中内容有很多,这里主要介绍一下编译器相关的那些,首先看下图% F) W  x6 m+ b
" ]* C9 d7 t% z

- J2 H$ }! _1 Y+ Y7 P" \; n* d2 N7 U0 L* ^# ^8 ?
  我们可以手动提取其编译器,来作为命令行工具使用。但是对于 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》。
  Y; z. ~7 p$ p2 N: |! e. D2 u) _
1. IAR 我用的比较少,主要内容来自于官方文档。管方文档更加详细,如有疑问直接去官方文档查看即可!官方文档目录为 IAR安装目录\arm\doc。具体如下:
! y3 q1 {5 |' B" E) s: _
  • 《 IAR C/C++ Development Guide Compiling and Linking》,文档名为 EWARM_DevelopmentGuide.ENU.pdf
  • 《IAR Assembler Reference Guide》,文档名为 EWARM_AssemblerReference.ENU.pdf
  • 《C-STAT® Static Analysis Guide》,文档名为 EW_MisraC1998Reference.ENU.pdf; g9 K" |% n4 A, g, O7 `
2. 还可以直接从 IAR 的 IDE 的菜单进入:菜单 -> help
0 v8 w$ T8 j! r: s. C" G9 |- \/ \# M  F% D* J# U

  ?2 d/ x; ]/ m2 g, Z0 @" h" I: M  f: `2 c5 Q# Z  i% D' W

/ B1 G* q0 d6 P2 F! w" Riasmarm.exe
; Z, G8 _9 w: z1 e. S" P, U% L  这个是 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》,里面有该工具的详细使用说明。! i# I7 e* u; Y; k6 {8 s- C7 {
) N* U4 [0 p* o5 K* D( R
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>iasmarm
  •     IAR Assembler V8.32.3.193/W32 for ARM
  •     Copyright 1999-2019 IAR Systems AB.
  • Usage:        iasmarm {<options>} <sourcefile> {<options>}
  • Sourcefile:   source file with default extension: .msa, , .asm, or .s
  • Environment:  IASMARM
  • Options (specified order is of no importance):
  • -B            Print debug info for assembler macros
  • -c{DEAOM}     Listing options
  •                  D: Disable listing,             E: Disable macro expansion
  •                  A: List only assembled part     O: List several lines of code
  •                  M: List Macro definition
  • -DSYMB        Equivalent to: #define SYMB 1
  • -DSYMB=xx     Equivalent to: #define SYMB xx
  • -e            Use big-endian byte order
  • -Enumber      Allow <number> errors
  • -f file       Extend command line with <file> <.xcl>
  • -g            No system include
  • -G            Open standard input as source
  • -i            List #included files
  • -Ipath        Add #include search path
  • -j            Enable alternative register names, operators and mnemonics
  • -l file       Generate a list on: <file> <.lst>
  • -Lpath        Generate a list on: <path> \ <source> <.lst>
  • -Mab          Change asm.macro argument quote chars,
  •                   where a is start-of-quote and b is end-of-quote char.
  •                   default is a == < and b == >.
  • -N            No header in listing
  • -o file       Put object  on: <file> <.o>
  • -Opath        Put object on: <path> \ <source> <.o>
  • -pnn          Page listing with 'nn' lines/page (10-150)
  • -r            Enable debugger output in object
  • -S            Silent operation of assembler
  • -s{+|-}       Set case sensitivity for user symbols
  •                  -s and -s+ enables sensitivity, -s- disables it.
  • -tn           Set tab spacing between 2 and 9 (default 8)
  • -USYMB        Equivalent to: #undef SYMB
  • -ws           To make warnings generate exit code 1
  • -wstring      Disable warnings
  •                  string: <+|-,><+|-range><,+|-range>...
  •                  range: low_warning_nr<-high_warning_nr>
  •                  example: -w turns all warnings off
  •                           -w-,+10-12,+20 turns all but 10,11,12 and 20 off
  • -x{DI2}       Generate cross-reference list
  •                  D: Show all #defines, I: Show Internal table
  •                  2: Dual line space listing
  • --aarch64     Generate code for AArch64, same as --cpu_mode A64
  • --abi {lp64|ilp32}
  •               Specify ABI for AArch64: ilp32 or lp64.
  • --arm         Generate code in arm mode, same as --cpu_mode arm
  • --cmse
  •               Target secure mode in CMSE (ARMv8-M security extensions)
  • --cpu core    Specify target core
  •                  Valid options are core names such as Cortex-M3
  •                  and architecture names such as 7M
  •                  Default is Cortex-M3
  • --cpu_mode {arm|a|thumb|t}
  •               Select default mode for CODE directive, ARM is default
  • --endian {little|l|big|b}
  •               Specify target byte order
  • --fpu {VFPv1|VFPv2|VFPv3{_D16}{_FP16}|VFP9-S|none}
  •               Specify target FPU coprocessor support
  •                  Default is none, which selects the software
  •                  floating-point library.
  • --legacy {legacyOption}
  •               Generate object files compatible with
  •               older toolchains. Valid options are:
  •               RVCT3.0
  • --no_dwarf3_cfi
  •               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 exit
    8 c) N$ h$ V' ?5 Y' G

- R8 w& }" ~$ }' J1 w, `2 R7 v/ K9 b9 T) h& k: ^
iccarm.exe+ x1 B9 ]+ W) P3 Q) D6 h9 K
  这个是 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特定功能的扩展。
; a9 o' {' x4 e) t0 }  默认使用的头文件目录.\arm\inc\<vendor>
7 j. B, J+ ~, U) h" L4 k* O0 z3 q+ O8 w. }
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>iccarm
  •    IAR ANSI C/C++ Compiler V8.32.3.193/W32 for ARM
  •    Copyright 1999-2019 IAR Systems AB.
  •    PC-locked license - IAR Embedded Workbench for ARM
  • Available command line options:
  • --aapcs {std|vfp}
  •                 Specify calling convention.
  • --aeabi         Generate aeabi compliant code
  • --align_sp_on_irq
  •                 Generate code to align SP on entry to __irq functions
  • --arm           Generate code in arm mode, same as --cpu_mode arm
  • --c++           C++
  • --c89           Use C89 standard
  • --char_is_signed
  •                 'Plain' char is treated as signed char
  • --char_is_unsigned
  •                 'plain' char is treated as unsigned char
  • --cmse          Enable CMSE secure object generation
  • --cpu core      Specify target core
  •                 Valid options are core names such as Cortex-M3
  •                 and architecture names such as 7M
  •                 Cortex-M3 is default
  • --cpu_mode {arm|a|thumb|t}
  •                 Select default mode for functions, arm is default
  • -D symbol[=value]
  •                 Define macro (same as #define symbol [value])
  • --debug
  • -r              Insert debug info in object file
  • --dependencies=[i|m|n][lw] file|directory|+
  •                 List file dependencies
  •                    i     Include filename only (default)
  •                    m     Makefile style (multiple rules)
  •                    n     Makefile style (one rule)
  •                    s     Don't include system file dependencies
  •                    l     Use locale encoding instead of UTF-8
  •                    w     Use little endian UTF-16 instead of UTF-8
  •                    b     Use a Byte Order Mark in UTF-8 output
  •                 (+: output same as -o, only with .d extension)
  • --deprecated_feature_warnings [+|-]feature,[+|-]feature,...
  •                 Enable (+) or disable (-) warnings about deprecated features:
  •                    attribute_syntax         Warn about attribute syntax that
  •                                             will change
  •                    preprocessor_extensions  Warn about use of migration
  •                                             preprocessor extensions
  •                    segment_pragmas          Warn about use of #pragma constseg/
  •                                             dataseg/memory
  • --diagnostics_tables file|directory
  •                 Dump diagnostic message tables to file
  • --diag_error tag,tag,...
  •                 Treat the list of tags as error diagnostics
  • --diag_remark tag,tag,...
  •                 Treat the list of tags as remark diagnostics
  • --diag_suppress tag,tag,...
  •                 Suppress the list of tags as diagnostics
  • --diag_warning tag,tag,...
  •                 Treat the list of tags as warning diagnostics
  • --discard_unused_publics
  •                 Discard unused public functions and variables
  • --dlib_config name|path
  •                 Specify DLib library configuration
  • --do_explicit_zero_opt_in_named_sections
  •                 Allow zero init optimization for variables in named
  •                 sections/segments
  • -e              Enable IAR C/C++ language extensions
  • --enable_hardware_workaround waid[,waid[...]]
  •                 Generate hardware workaround for specified problem
  • --enable_restrict
  •                 Enable the restrict keyword
  • --endian {little|l|big|b}
  •                 Select byte order, little-endian is default
  • --enum_is_int   Force the size of all enumeration types to be at least 4 bytes
  • --error_limit limit
  •                 Stop after this many errors (0 = no limit)
  • -f file         Read command line options from file
  • --f file        Read command line options from file and report dependency
  • --fpu {VFPv2|VFPv3{_D16}{_FP16}|VFPv4{_sp}|VFP9-S|none}
  •                 Specify target FPU coprocessor support
  •                 Default is none, which selects the software
  •                 floating-point library.
  • --generate_entries_without_bounds
  •                 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++8 F: j& O5 k! l

: x2 c; q( N" f% c7 a0 m& `4 e0 D+ w0 `# A# K0 i
IDE中有两个工具可将应用程序源文件转换为中间文件目标文件。 IAR C / C ++编译器和IAR汇编器。 两者都产生行业标准格式ELF中的可重定位目标文件,包括DWARF调试信息的格式。下图显示了编译过程:5 @) G7 e9 k/ f
- I$ r9 o$ V( S7 n; y7 S. z

  P! i# G) c# ], Y
" `9 G2 b, `2 c, ^+ K
; Z5 i3 m' v+ P4 q" i- X5 Tilinkarm.exe5 P5 g+ U( A( r& E; ]) o
  这个是 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 ++和汇编程序。3 Y2 W% L# h) g7 K
  ilinkarm 使用并生成行业标准的ELF和DWARF作为对象格式文件。在.\arm\config目录下,包含了针对各平台的连接器使用的配置文件。
& R5 f3 [: w, [. y6 q( R% v1 v& i) |5 {. J9 j4 ?' y
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>ilinkarm
  •    IAR ELF Linker V8.32.3.193/W32 for ARM
  •    Copyright 2007-2019 IAR Systems AB.
  • Available command line options:
  • --advanced_heap Use an advanced heap manager.
  • --basic_heap    Use a basic heap manager
  • --BE32          Use old type big-endian mode.
  • --BE8           Use byte invariant mode.
  • --bounds_table_size number_of_records[:number_of_buckets]|(number_of_bytes)
  •                 Specify size of bounds checking tables
  • --call_graph file|directory
  •                 Produce an XML call graph file
  • --config file   Read linker configuration from file
  • --config_def symbol=value
  •                 Define a config symbol
  • --config_search directory
  •                 Look for config files in directory
  • --cpp_init_routine symbol
  •                 Specify C++ dynamic init routine name
  • --cpu core      Specify target core
  •                 Valid options are core names such as Cortex-M3
  •                 and architecture names such as 7M
  •                 default is extracted from objects
  • --debug_heap    Use heap with runtime checks
  • --default_to_complex_ranges
  •                 Make "complex ranges" the default in initialize directives
  • --define_symbol symbol=value
  •                 Define absolute symbol
  • --dependencies=[i|m|n][lw] file|directory|+
  •                 List file dependencies
  •                    i     Include filename only (default)
  •                    m     Makefile style (multiple rules)
  •                    n     Makefile style (one rule)
  •                    s     Don't include system file dependencies
  •                    l     Use locale encoding instead of UTF-8
  •                    w     Use little endian UTF-16 instead of UTF-8
  •                    b     Use a Byte Order Mark in UTF-8 output
  •                 (+: output same as -o, only with .d extension)
  • --diagnostics_tables file|directory
  •                 Dump diagnostic message tables to file
  • --diag_error tag,tag,...
  •                 Treat the list of tags as error diagnostics
  • --diag_remark tag,tag,...
  •                 Treat the list of tags as remark diagnostics
  • --diag_suppress tag,tag,...
  •                 Suppress the list of tags as diagnostics
  • --diag_warning tag,tag,...
  •                 Treat the list of tags as warning diagnostics
  • --do_segment_pad
  •                 Pad segments to 4 byte alignment
  • --enable_hardware_workaround waid[,waid[...]]
  •                 Generate hardware workaround for specified problem
  • --enable_stack_usage
  •                 Enable stack usage analysis
  • --entry symbol  Set program entry point
  • --error_limit limit
  •                 Stop after this many errors (0 = no limit)
  • --exception_tables action
  •                 Generate exception tables for modules lacking them
  •                   nocreate    Do not generate entries (default)
  •                   unwind      Generate unwind entries
  •                   cantunwind  Generate nounwind entries
  • --export_builtin_config file|directory
  •                 Export the builtin configuration
  • --extra_init routine
  •                 Call extra init routine if defined
  • -f file         Read command line options from file
  • --f file        Read command line options from file and report dependency
  • --force_exceptions
  •                 Always include exception code
  • --force_output  Produce an output file in spite of errors
  • --fpu {VFPv1|VFPv2|VFPv3{_D16}{_FP16}|VFP9-S|none}
  •                 Specify target FPU coprocessor support
  •                 Default is extracted from objects.
  • --ignore_uninstrumented_pointers
  •                 Disable checking of accesses via pointers in memory with
  •                 no bounds
  • --image_input file[,symbol[,section[,alignment]]]
  •                 Put image file in section
  • --import_cmse_lib_in file
  •                 Read previous version of import library for building non-secure image
  • --import_cmse_lib_out file|directory
  •                 Produce import library for building non-secure image
  • --inline        Try to inline small functions.
  • --keep symbol   Require global symbol
  • --log topic,topic,...
  •                 Do log output for the selected topics
  •                    call_graph        Call graph with stack usage
  •                    crt_routine_selection
  •                                      CRT routine implementation selection
  •                    demangle          Demangle symbols in log output
  •                    fragment_info     Supplementary info for --log sections
  •                    initialization    Initialization decisions
  •                    inlining          Small function inlining
  •                    libraries         Automatic library selection
  •                    merging           Results of --merge_duplicate_sections
  •                    modules           Module selection
  •                    redirects         Redirected symbols
  •                    sections          Section fragment selection
  •                    unused_fragments  Unused section fragments
  •                    veneers           Veneer statistics
  • --log_file file Specify file for log output
  • --mangled_names_in_messages
  •                 Include mangled symbol names in diagnostics
  • --manual_dynamic_initialization
  •                 Don't perform dynamic initialization during startup
  • --map file|directory
  •                 Produce a linker list file
  • --merge_duplicate_sections
  •                 Merge equivalent read-only sections
  • --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
  • --no_bom        Don't use a Byte Order Mark in Unicode output
  • --no_dynamic_rtti_elimination
  •                 Disable dynamic rtti elimination
  • --no_entry      This program has no entry point
  • --no_exceptions Signal an error if exceptions are used
  • --no_fragments  Always link entire sections
  • --no_free_heap  Use a heap manager with no 'free'
  • --no_inline func,func,...
  •                 Do not inline any of the specified functions
  • --no_library_search
  •                 Disable automatic runtime library search
  • --no_literal_pool
  •                 Don't generate literal pool in code memory
  • --no_locals     Do not include local symbols in output symbol table
  • --no_range_reservations
  •                 Do not reserve address ranges for absolute symbols
  • --no_remove     Do not remove unused sections
  • --no_vfe        Disable Virtual Fuction Elimination
  • --no_warnings   Disable generation of warnings
  • --no_wrap_diagnostics
  •                 Don't wrap long lines in diagnostic messages
  • --only_stdout   Use stdout only (no console output on stderr)
  • --output file
  • -o file         Specify output file
  • --pi_veneers    Generate position independent veneers.
  • --place_holder symbol[,size[,section[,alignment]]]
  •                 Reserve a place in ROM for later use
  • --preconfig file
  •                 Read before normal linker configuration file
  • --printf_multibytes
  •                 Enable multibyte support in printf & friends
  • --redirect orig=replacement
  •                 Redirect symbol refs to replacement symbol
  • --remarks       Enable generation of remarks
  • --scanf_multibytes
  •                 Enable multibyte support in scanf & friends
  • --search directory
  • -L directory    Look for object and library files in directory
  • --semihosting[=iar_breakpoint]
  •                 Link with debug interface.
  •                 Specify interface to override default.
  • --silent        Silent operation
  • --stack_usage_control file
  •                 Read stack usage control file
  • --strip         Do not include 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
  • --threaded_lib  Configure runtime library for use with threads
  • --timezone_lib  Enable timezone and daylight savings support
  • --treat_rvct_modules_as_softfp
  •                 link softfp versions of math function for modules
  •                 compiled with RVCT even though they are built with
  •                 vfp calling-convention
  • --use_full_std_template_names
  •                 Don't use short names for standard C++ templates
  • --use_optimized_variants no|auto|small|fast
  •                 Use optimized variants of DLIB library functions
  •                   no     Do not use redirects to use optimized variants
  •                   auto   Use redirects based on attributes in object files
  •                          (default)
  •                   small  Always use a small variant if available
  •                   fast   Always use a fast variant if available
  • --utf8_text_in  Non-source text input files with no BOM use UTF-8 encoding
  • --version       Output version information and exit
  • --vfe=[forced]  Perform Virtual Function Elimination
  •                   forced      Force the use of VFE for all modules
  •                               with VFE information.
  • --warnings_affect_exit_code
  •                 Warnings affect exit code
  • --warnings_are_errors
  •                 All warnings are errors
  • --whole_archive archive
  •                 Link all modules in archive: c" t- z6 P$ K* _! b

3 p( z' y. h& J* v9 l% r
% O  A  H/ s% u, n$ F, WIAR ILINK链接器(ilinkarm.exe)用于构建最终应用程序。通常,链接器需要以下信息作为输入:
; K! u0 r1 \2 E. i0 j& m
0 L% N5 D$ Z9 S
  • 几个目标文件,可能还有某些库
  • 程序开始标签(默认设置)
  • 链接器配置文件,用于描述目标系统内存中代码和数据的放置
      u0 x6 |! p5 |& P, _7 d6 r

8 C9 S6 i$ K6 ~2 L下图显示了链接过程:
- ^( t* y. B+ P5 C& ?" v8 O5 o2 O. _6 T% m; B) ?
& c3 H/ Z" x4 O5 `2 b
6 E! {$ C% G3 X) N8 ?0 i
IAR ILINK链接器生成ELF格式的绝对目标文件,其中包含可执行镜像。 链接后,可以使用生成的绝对可执行映像+ E5 i0 g2 V* q( F( J( z& S5 b

6 y7 \, F4 a8 w
  • 加载到IAR C-SPY调试器或任何其他兼容的外部调试器读取ELF和DWARF。
  • 使用flash / PROM编程器对flash / PROM进行编程。 在此之前可能必须使用ielftool将镜像中的实际字节转换为标准的Motorola 32-bit S-record 格式或Intel Hex-32格式。
    : s/ `/ w& g# H1 Q

0 v) Z# N2 g& A
% U0 Z9 ~/ r( Oiarchive.exe# n" s( v2 F; R7 W7 |! h
档案管理工具,类似于 ARM 的 armar 和 GCC 的 ar。用于创建和操作几个ELF目标文件的库(存档)。库文件包含多个可重定位的ELF对象模块,每个模块都可以由链接器独立使用。 与直接指定给链接器的对象模块相比,只有在需要时才包含库中的每个模块。. X+ ^9 l& K1 \  Z
+ C0 f" u, I- A& y
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>iarchive
  •    IAR Archive Tool V10.4.14.1149
  •    Copyright 2008-2019 IAR Systems AB.
  • Usage:          iarchive [command] archive obj1 ... objN
  •                 iarchive [command] obj1 ... objN -o archive
  •                 iarchive [command] archive
  • Available command line options:
  • --create        Create new archive
  • --delete
  • -d              Delete module(s) from archive
  • --extract
  • -x              Extract module(s) from archive
  • -f file         Read command line options from file
  • --f file        Read command line options from file and report dependency
  • --no_bom        Don't use a Byte Order Mark in Unicode output
  • --output archive
  • -o archive      Name of archive file
  • --replace
  • -r              Replace or add module(s) to archive
  • --symbols       List symbol table of archive
  • --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
  • --toc
  • -t              List archive table of content
  • --utf8_text_in  Non-source text input files with no BOM use UTF-8 encoding
  • --verbose
  • -V              verbose operation
  • --version       Output version information and exit
  • --vtoc          List archive table of content (verbose)
    / z$ S0 ?% H! N. t( n, {# z
" k1 S0 c) @" ^) F8 U5 s" Z: x
# U# q0 b9 X* ]9 ~  b4 `% g+ Q
使用示例:/ d+ C3 D* ~. h0 E1 }- k
$ t  S) w+ d  u9 _* o' X
  • 使用源对象文件module1.o、module.2.o和module3.o 创建了一个名为mylibrary.a的库文件:iarchive mylibrary.a module1.o module2.o module3.o
  • 列出 mylibrary.a中的内容:iarchive --toc mylibrary.a
  • 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.o
    / b, K8 Z& J4 i. h, n/ q5 Z

( L# m/ E2 W7 J: }
9 L1 v7 T4 A0 x- {! E2 A9 V+ O3 U) Aielftool.exe
1 F1 z$ _% t% W1 VARM ELF文件工具,类似于 ARM 的 fromelf 和 GCC 的 elfedit。对ELF可执行映像执行各种转换(例如,填充,校验和,格式转换等)。安装目录.\arm \ src\elfutils下提供了 ielftool 源代码(Microsoft VisualStudio项目)。 如果对如何生成校验和或格式转换要求有特定要求,则可以相应地修改源代码。
* {5 Y: e6 x9 {" r* p2 l; F/ l6 p
+ f& ~* V( V/ m3 t% n
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>iarchive
  •    IAR Archive Tool V10.4.14.1149
  •    Copyright 2008-2019 IAR Systems AB.
  • Usage:          iarchive [command] archive obj1 ... objN
  •                 iarchive [command] obj1 ... objN -o archive
  •                 iarchive [command] archive
  • Available command line options:
  • --create        Create new archive
  • --delete
  • -d              Delete module(s) from archive
  • --extract
  • -x              Extract module(s) from archive
  • -f file         Read command line options from file
  • --f file        Read command line options from file and report dependency
  • --no_bom        Don't use a Byte Order Mark in Unicode output
  • --output archive
  • -o archive      Name of archive file
  • --replace
  • -r              Replace or add module(s) to archive
  • --symbols       List symbol table of archive
  • --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
  • --toc
  • -t              List archive table of content
  • --utf8_text_in  Non-source text input files with no BOM use UTF-8 encoding
  • --verbose
  • -V              verbose operation
  • --version       Output version information and exit
  • --vtoc          List archive table of content (verbose)
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>ielftool
  •    IAR ELF Tool V10.4.14.1149 [BUILT at IAR]
  •    Copyright 2007-2019 IAR Systems AB.
  • Usage:       ielftool input_file output_file
  • Available command line options:
  • --bin           Save as raw binary
  • --checksum sym:size,algo[:[1|2][a|m|z][r][R][o][x][i|p][W|L]][,start]
  •            ;range[;range...]
  •                 Generate checksum
  •                    sym       Checksum symbol
  •                    size      Length of the symbol in bytes
  •                    algo      Algorithm: sum, sum8wide, sum32, crc16, crc32
  •                              crc64iso, crc64ecma or crc=poly
  •                    1|2       Complement: 1 or 2
  •                    a|m|z     Reverse the bit order for:
  •                                input bytes only: a
  •                                input bytes and final checksum: m
  •                                final checksum only: z
  •                    o         Output the Rocksoft model specification
  •                    r         Reverse the byte order within each word
  •                    R         Traverse the range(s) in reverse order
  •                    x         Toggle the endianess of the checksum
  •                    i|p       Use initial value normally: i
  •                              Prefix input data with the start value: p
  •                    W|L       Use a checksum unit length of 2 bytes: W
  •                              Use a checksum unit length of 4 bytes: L
  •                    start     Initial checksum value (defaults to 0)
  •                    range     Do checksum of bytes in range
  • --fill [v;]pattern;range[;range...]
  •                 Specify fill
  •                    v         Virtual fill, do not generate actual filler bytes.
  •                              This can be used for checksums and parities.
  •                    pattern   Sequence of filler bytes
  •                    range     Fill range
  • --front_headers Move program and section headers to the front of the ELF file.
  • --ihex          Save as 32-bit linear Intel Extended hex
  • --offset [-]offset
  •                 Add (subtract if - is used) offset to all address records.
  •                 This only works for the output formats: Motorola S-records,
  •                 Intel Hex, Simple-Code and TI-TXT
  • --parity sym:size,algo:flashbase[:[r][[B|W|L]];range[;range...]
  •                 Generate parity bits
  •                    sym       Parity symbol
  •                    size      Length of the symbol in bytes
  •                    algo      Parity algorithm: odd, even
  •                    flashbase Ignore bytes before this address
  •                    r         Traverse the range(s) in reverse order
  •                    B         Use a parity unit length of 1 byte
  •                    W         Use a parity unit length of 2 bytes
  •                    L         Use a parity unit length of 4 bytes
  •                    range     Perform parity on bytes in this range
  • --self_reloc relocator[,jtc]
  •                 Create self-relocating image with relocator
  •                    jtc       Number of jump table entries
  • --silent        Silent operation
  • --simple        Save as Simple-code
  • --simple-ne     Save as Simple-code without entry record
  • --srec          Save as Motorola S-records
  • --srec-len length
  •                 Restrict the length of S-records
  • --srec-s3only   Restrict the type of S-records to S3 (and S7)
  • --strip         Remove all section headers and non-program sections
  • --titxt         Save as Texas Instruments TI-TXT
  • --verbose       Print all performed operations
  • --version       Output tool version
      Q/ O1 ]# O0 Z7 T6 |8 |1 K
$ `% f" p7 [/ f4 D) U3 Q
: o4 d9 [1 f* P/ w& I# t: i6 i
# E+ O1 ~0 H( \, z
使用示例:
# N' I8 n! C6 H) I+ l
4 P. z7 F& l! W  [  m
  • 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
    8 ]; N% s; F: n

  X. X) `3 `- _
4 a  Y+ D3 _9 J5 G$ xielfdumparm.exe
& d4 _" k) k! j0 l$ c针对 ARM ELF 格式的文件的 Dumper工具。类似于 GCC 的 objdump,用于创建ELF可重定位或可执行映像内容的文本表示。主要用于以下三个方面:
) S5 b5 t1 N3 z3 v+ g
0 j' V# }* |+ s, q3 w
  • 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节的文本表示。 要指定此行为,请使用命令行选项–section2 A; f) w( z' e# D4 }6 E9 a  o9 q

6 p0 ?+ i4 M0 O2 V
) i5 A8 k5 y# B5 ~+ P. Q2 f
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>ielfdumparm
  •    IAR ELF Dumper V8.32.3.193 for ARM
  •    Copyright 2007-2019 IAR Systems AB.
  • Usage:          IElfDump input_file [output_file]
  • Available command line options:
  • -a              All sections, except strtab sections
  • --aarch64       Disassemble in Aarch64 mode if mode cannot be deduced by the image.
  • --all           Dump all sections
  • --arm           Disassemble in Arm mode if mode cannot be deduced by the image.
  • --code          Dump only code sections
  • --disasm_data   Use disassembly format for data sections
  • -f file         Read command line options from file
  • --f file        Read command line options from file and report dependency
  • --no_bom        Don't use a Byte Order Mark in Unicode output
  • --no_header     Do not produce a list header
  • --no_rel_sections
  •                 Do not output associated .rel sections
  • --no_strtab     Do not include strtab sections
  • --no_utf8_in    Non-IAR input files are by default assumed to use UTF-8
  •                 encoding unless this option is used.
  • --output file
  • -o file         Name of text file to create
  • --range A-B     Disassemble only addresses in the specified range
  •                 (from A to B).
  • --raw           Use raw text format
  • --section #|name[,...]
  • -s #|name[,...] Dump only section(s) with given numbers/names
  • --source        Include source in disassembled code in executables
  • --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         Disassemble in thumb mode if mode cannot be deduced by the image.
  • --use_full_std_template_names
  •                 Don't use short names for standard C++ templates
  • --utf8_text_in  Non-source text input files with no BOM use UTF-8 encoding
  • --version       Output version information and exit
    6 Y5 U1 B+ C2 P* b
5 L4 _) O% ]% N8 r
! |5 S( d5 F$ P, ~/ V& [; q
iobjmanip.exe0 D, V( W+ D7 c$ S& }2 K' K
针对 ARM ELF 格式的 Object 文件的操作工具。用于执行ELF目标文件的低级操作。, [& Y7 M: R, Q5 A5 Z! e

) n  s* F$ O- W, R' V9 d- `
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>iobjmanip
  •    IAR Object File Manipulator V10.4.14.1149
  •    Copyright 2009-2019 IAR Systems AB.
  • Usage:          iobjmanip <op1>[,...<opN>] <src> <dest>
  • Available command line options:
  • -f file         Read command line options from file
  • --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 exit8 E& |3 ?- P$ l2 Z! Y% c8 g1 e1 _
; ^6 s8 [8 X9 a' v$ w

; Q# L! M9 S- F8 _- X+ J: d使用示例:6 Z: u5 w  s0 g5 A5 R5 j5 e' V% ^& }
; V5 ^* c: B" L$ }- r1 A; G
  • 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
    + I2 i# |: \4 p: t

: U- c2 x  M. i7 t+ a" v! s' d0 y0 ~
isymexport.exe
$ w" f* t5 m! P7 Z绝对符号导出器。 从ROM映像文件中导出绝对符号,以便在链接附加应用程序时使用它们。
; c8 n. n$ I; ?5 z' S. I0 z2 O. X, O6 c6 v& h5 L, H
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>isymexport
  •    IAR Absolute Symbol Exporter V10.4.14.1149
  •    Copyright 2008-2019 IAR Systems AB.
  • Usage:          ISymExport input_file output_file
  • Available command line options:
  • --edit steering_file
  •                 Show/hide/rename symbols
  • --export_locals[=symbol_prefix]
  •                 Export local variable and function symbols
  • -f file         Read command line options from file
  • --f file        Read command line options from file and report dependency
  • --generate_vfe_header
  •                 Generate vfe header section
  • --no_bom        Don't use a Byte Order Mark in Unicode output
  • --ram_reserve_ranges[=symbol_prefix]
  •                 Generate symbols to reserve all occupied RAM ranges
  • --reserve_ranges[=symbol_prefix]
  •                 Generate symbols to reserve all occupied ranges
  • --show_entry_as[=name]
  •                 Export the entry point of the program as name
  • --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 exit
    - V  L. C: }! H' C8 @% h0 b

; ~7 T4 r- u6 V1 S: T0 z1 b' {2 f- I/ i$ D( Z7 e* O
iexe2obj.exe2 |  H' Y* h. P& o1 X! M  L0 m. T
IAR ELF可重定位对象创建器。从可执行的ELF目标文件创建可重定位的ELF目标文件。
2 j$ j2 X% V% f' }% u& }/ x1 c0 n0 Z! ?; s7 A+ X
  • E:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\bin>iexe2obj
  •    IAR ELF Exe to Object Tool V10.4.14.1149
  •    Copyright 2008-2019 IAR Systems AB.
  • Usage:          IExe2Obj input_file output_file
  • Available command line options:
  • -f file         Read command line options from file
  • --f file        Read command line options from file and report dependency
  • --hide_symbols  Hide all symbols in the image
  • --keep_mode_symbols
  •                 Keep mode symbols in the image
  • --no_bom        Don't use a Byte Order Mark in Unicode output
  • --prefix prefix Set section/symbol name prefix
  • --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 exit
  • --wrap function Create wrapper for function
    6 Z3 b4 j6 K6 @. o& w8 C7 F

2 |5 ~$ q3 s* l- c- _6 H# H& H" j3 y
% N* f3 ^! n1 j! a0 k& r+ Q
0 Y; R& e  a; R  x8 c

该用户从未签到

2#
发表于 2020-9-2 16:07 | 只看该作者
详细了解一下ARM的主流编译器(armcc、iar、gcc for arm)

该用户从未签到

3#
发表于 2020-9-2 19:32 | 只看该作者
学习一下编译器内容
3 _" ?- T/ p0 [* I% J* c: R
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-11-25 01:04 , Processed in 0.218750 second(s), 26 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表