Linker command-line options

本文档详细介绍了链接器的两个关键选项:--first 和 --entry。--first 选项用于指定输入节在执行区域中的首次出现位置,例如放置包含向量表的节。--entry 选项则用来定义映像的唯一初始入口点,可以是数值地址、符号或对象内的偏移量。需要注意的是,如果入口地址位于 Thumb 状态,其最低位必须为 1。当使用 --ltcg 时,只能使用 --entry 符号。这两个选项在创建和加载程序时都起到重要作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Option: --first

--first = section_id      

This option places the selected input section first in its execution region. This can, for example,

place the section containing the vector table first in the image.

Syntax

section_id is one of the following:

1)    Symbol

Selects the section that defines symbolYou must not specify a symbol that has

more than one definition, because only one section can be placed first. For example: --first=reset

2)    object(section)

Selects section from object. There must be no space between object and the

following open parenthesis. For example: --first=init.o(init)

3)    object

Selects the single input section in object. If you use this short form and there is

more than one input section, the linker generates an error message. For example:

--first=init.o

 

Note: The --first option cannot be used with --scatter. Instead, use the +FIRST attribute in a

scatter-loading file.

 


 

 

Options: --entry 

--entry=location

 This option specifies the unique initial entry point of the image.

 

Syntax

location is one of the following:

1) entry_address   

A numerical value, for example: --entry=0x0

2)    symbol

Specifies an image entry point as the address of symbol, for example:--entry=reset_handler

3)     offset+object(section)

Specifies an image entry point as an offset inside a section within a particular object, for example:

--entry=8+startup.o(startupseg)

There must be no spaces within the argument to --entry. The input section and object names are matched without case-sensitivity. You can use the following simplified notation:

    object(section), if offset is zero.

    object, if there is only one input section. armlink generates an error message if there is more than one code input section in object.

 

Note

1)    If the entry address of your image is in Thumb state, then the least significant bit of the address must be set to 1. The linker does this automatically if you specify a symbol. For example, if the entry code starts at address 0x8000 in Thumb state you must use --entry=0x8001.

2)    If you use --ltcg, then only --entry symbol can be used.

 

 

Usage

 The image can contain multiple entry points, but the initial entry point specified with this option is stored in the executable file header for use by the loader. There can be only one occurrence of this option on the command line. A debugger typically uses this entry address to initialize the Program Counter (PC) when an image is loaded. The initial entry point must meet the following conditions:

 

    the image entry point must lie within an execution region

    the execution region must be non-overlay, and must be a root execution region (load address == execution address).

 


Refer to ARM Compiler toolchain v4.1 Linker Reference

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值