Bootloader及GNU映像机理.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Bootloader及GNU映像机理.ppt

Bootloader及GNU映像机理 宋健建 Makefile及Bootloader源代码结构 Bootloader源代码结构 Makefile -mapcs-32:生成可以运行在具有32位程序计数器的处理器上的目标文件,并且遵循APCS-32函数调用标准。 -mcpu=strongarm110:目标处理器是strongarm110 Makefile CC = /usr/local/hybus-arm-linux-R1.1/bin/arm-linux-gcc OBJCOPY = /usr/local/hybus-arm-linux-R1.1/bin/arm-linux-objcopy INCLUDE = -I./include CFLAGS = -O2 -nostdinc -mcpu=strongarm110 -mapcs-32 -fomit-frame-pointer -fPIC $(INCLUDE) -Wall $(CFLAGSII) OCFLAGS = -O binary -R .note -R .comment –S LDFLAGS = -static –nostdlib ELF32_LDFLAGS = -Wl, -T ld-xscale COMPILE = $(CC) $(CFLAGS) CFILES = $(wildcard *.c) SFILES = $(wildcard *.S) OBJ_FILES = $(SFILES:%.S=%.o) $(CFILES:%.c=%.o) BIN_FILE = x-boot255 all : $(OBJ_FILES) $(CC) $(LDFLAGS) -o $(BIN_FILE)-elf32 $(ELF32_LDFLAGS) $(OBJ_FILES) –lgcc $(OBJCOPY) $(OCFLAGS) $(BIN_FILE)-elf32 $(BIN_FILE) ELF文件格式 ELF – Executable Linkable Format 三种类型 可重定位目标文件(relocatable object) :保存着代码和适当的数据,用来和其他目标文件一起创建一个可执行文件或目标文件 可执行文件(executable):保存着代码和适当的数据,是一个可执行的程序;exec用来它创建进程映像 共享目标文件(shared object):保存着代码和适当的数据。相当于Windows的DLL。 从不同角度观察ELF文件格式 几个重要的section An object file written by as has at least three sections, any of which may be empty. These are named text, data and bss sections. .text - 程序的“text”或可执行指令,相当于RO。 .data - 程序的初始化数据,相当于RW。 .bss - 未初始化数据。该section不占文件空间,相当于ZI。当程序运行时,系统初始化这些数据为0。 Within the object file, the text section starts at address 0, the data section follows, and the bss section follows the data section. .rodata段 .rodata – 保存着只读数据,在进程映像中构造不可写的段。系统自动生成 生成最终的可执行文件时,仅连接.text, .rodata, .data, .bss段。一般.rodata连接到.text段中。 用readelf查看文件格式 readelf –a main.o 用objdump查看ELF文件格式 objdump –h main.o ld连接工具和连接脚本 The main purpose of the linker script is to describe how the sections in the input files should be mapped into the output file, and to control the memory layout of the output file. OUTPUT_ARCH(arch) Specify a particular output machine architecture. ENTRY(symbol) 定义程序入口点 SECTIONS The SECTIONS command tells the linker how to map input sections into output s

文档评论(0)

gsgtshb + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档