BootLoader及GNU映像文件.pptVIP

  • 2
  • 0
  • 约2.91千字
  • 约 13页
  • 2018-03-26 发布于河南
  • 举报
BootLoader及GNU映像文件

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)

1亿VIP精品文档

相关文档