u-boot:gnu objcopy

objcopy概括:
      gnu objcopy实用程序将一个对象文件的内容复制到另一个文件。objcopy使用gnu bfd库来读取和写入对象文件。它可以以与源对象文件不同的格式写入目标对象文件。objcopy的确切行为是由命令行选项控制的

BFD Library概括:
中文名称: 二进制文件描述库(Binary File Descriptor library)
       BFD是GNU项目用于对各种格式的对象文件进行可移植操作的主要机制。它支持大约50种文件格式,适用于大约25种指令集架构(2003年)。

列出可用的BFD target 
$ objdump -i

objcopy说明

参数

说明

-j  <section name>

只将由sectionname指定的section拷贝到输出文件

-B <architecture>

如 -B  arm 或者 -B aarch64

-O <output-target bfdname>

指定输出目标(主要为以下几种情况)

-O srec

16进制ascii 文本格式

摩托罗拉开发, 后缀.srec (S-record)

-O ihex

16进制ascii 文本格式

用于intel 处理器,后缀.hex

-O binary

生成raw binary file

it will essentially produce a memory dump of the contents of the input object file. All symbols and relocation information will be discarded. The memory dump will start at the load address of the lowest section copied into the output file.

-O elf32-littlearm

-S

remove sections containing debugging information

-R

remove sections which contain information that is not needed by the binary file.

--pad-to <addr>

Pad the output file up to the load address address. This is done by increasing the size of the last section. The extra space is filled in with the value specified by --gap-fill

-gap-fill <val>

填充值 默认为0

objcopy实例1: 生成u-boot.srec

arm-linux-gnueabihf-objcopy \

-j .text -j .secure_text -j .secure_data -j .rodata -j .hash -j .data -j .got \

 -j .got.plt -j .u_boot_list -j .rel.dyn -j .binman_sym_table -j .text_rest \ -j .dtb.init.rodata -j .efi_runtime -j .efi_runtime_rel  \

--gap-fill=0xff \

-O srec \

u-boot u-boot.srec

objcopy实例2: 制作u-boot.elf

step0:变量设置

ifdef CONFIG_ARM64

PLATFORM_ELFFLAGS += -B aarch64 -O elf64-littleaarch64

else

PLATFORM_ELFFLAGS += -B arm -O elf32-littlearm

endif

#define CONFIG_SYS_TEXT_BASE 0x00400000

step1:u-boot.bin 转换为u-boot.o

objcopy -I binary $(PLATFORM_ELFFLAGS) u-boot.bin u-boot-elf.o

step2:u-boot.o 转换为u-boot.elf

ld  u-boot-elf.o -o u-boot.elf\

--defsym=$(PLATFORM_ELFENTRY)=$(CONFIG_SYS_TEXT_BASE) \

-Ttext=$(CONFIG_SYS_TEXT_BASE)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值