[LinkerScript.6] 简单的链接器脚本命令: 格式命令 - Simple Linker Script Commands: Format Command


A couple of linker script commands deal with object file formats.

处理对象文件格式的一对链接器脚本命令


OUTPUT_FORMAT(bfdname) OUTPUT_FORMAT(defaultbiglittle)--------------------------------------------------------------------

The OUTPUT_FORMAT command names the BFD format to use for the output file (see BFD). Using OUTPUT_FORMAT(bfdname) is exactly like using ‘--oformat bfdname’ on the command line (see Command Line Options). If both are used, the command line option takes precedence.

You can use OUTPUT_FORMAT with three arguments to use different formats based on the ‘-EB’ and ‘-EL’ command line options. This permits the linker script to set the output format based on the desired endianness.

If neither ‘-EB’ nor ‘-EL’ are used, then the output format will be the first argument, default. If ‘-EB’ is used, the output format will be the second argument, big. If ‘-EL’ is used, the output format will be the third argument, little.

OUTPUT_FORMAT命令指定BFD格式用于定义输出文件(参看BFD).

使用OUTPUT_FORMAT(bfdname)就象使用命令行“--oformat bfdname'(参看命令行选项)。如果两者都使用,命令行选项优先。

你可以使用带三个参数的OUTPUT_FORMAT指定基于'-EB'和'-EL'命令行选项的不同格式。这样可以允许链接器脚本去设置基于某个端格式的输出格式。

如果'-EB'和'-EL'都没被使用,那么输出格式将是第一个参数,default。如果'-EB'被使用,输出格式将使用第二参数,big。如果'-EL'被使用,输出格式将是第三个参数,little。


For example, the default linker script for the MIPS ELF target uses this command:

          OUTPUT_FORMAT(elf32-bigmips, elf32-bigmips, elf32-littlemips)

This says that the default format for the output file is ‘elf32-bigmips’, but if the user uses the ‘-EL’ command line option, the output file will be created in the ‘elf32-littlemips’ format. 


比如,以MIPS ELF目标的默认链接器脚本使用这样的命令:

 OUTPUT_FORMAT(elf32-bigmips, elf32-bigmips, elf32-littlemips)
这说明了输出文件的默认格式是'elf32-bigmips',但是如果用户使用了‘-EL'命令行选项,输出文件将在'elf32-littlemips'格式中被创建。



TARGET(bfdname)

----------------------------------------

The TARGET command names the BFD format to use when reading input files. It affects subsequent INPUT and GROUP commands. This command is like using ‘-b bfdname’ on the command line (see Command Line Options). If the TARGET command is used but OUTPUT_FORMAT is not, then the last TARGET command is also used to set the format for the output file. See BFD.

TARGET命令用于指定读取输入文件时所使用的BFD格式。它影响了随后的INPUT和GROUP命令。这条命令如同使用‘-b bfdname’命令行(参看命令行选项)。如果使用TARGET命令,而没有使用OUTPUT_FORMAT,则上一次TARGET命令也会被用于设置输出文件的格式。(参看BFD)


意思是:TARGET主要负责输入文件的格式,而OUTPUT_FORMAT只负责输出文件的格式,但是如果OUTPUT_FORMAT不提供输出文件的格式,就默认使用TARGET提供输出文件的格式。




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值