Bootloader及GNU映像机理课件_第1页
Bootloader及GNU映像机理课件_第2页
Bootloader及GNU映像机理课件_第3页
Bootloader及GNU映像机理课件_第4页
Bootloader及GNU映像机理课件_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Makefile及Bootloader源代码结构Bootloader源代码结构Makefile-mapcs-32:生成可以运行在具有32位程序计数器的处理器上的目标文件,并且遵循APCS-32函数调用标准。-mcpu=strongarm110:目标处理器是strongarm110MakefileCC = /usr/local/hybus-arm-linux-R1.1/bin/arm-linux-gccOBJCOPY = /usr/local/hybus-arm-linux-R1.1/bin/arm-linux-objcopyINCLUDE = -I./includeCFLAGS = -O2 -

2、nostdinc -mcpu=strongarm110 -mapcs-32 -fomit-frame-pointer -fPIC $(INCLUDE) -Wall $(CFLAGSII)OCFLAGS = -O binary -R .note -R .comment SLDFLAGS = -static nostdlibELF32_LDFLAGS = -Wl, -T ld-xscaleCOMPILE = $(CC) $(CFLAGS)CFILES = $(wildcard *.c)SFILES = $(wildcard *.S)OBJ_FILES = $(SFILES:%.S=%.o) $(C

3、FILES:%.c=%.o)BIN_FILE = x-boot255all : $(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) :保存着代码和适当的数据,用来和其他目标文件一起创建一个可执行文件或目标文件可执行文件(executabl

4、e):保存着代码和适当的数据,是一个可执行的程序;exec用来它创建进程映像共享目标文件(shared object):保存着代码和适当的数据。相当于Windows的DLL。从不同角度观察ELF文件格式几个重要的sectionAn 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 -

5、 未初始化数据。该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查看文件

6、格式readelf a main.o用objdump查看ELF文件格式objdump h main.old连接工具和连接脚本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 archi

7、tecture.ENTRY(symbol)定义程序入口点SECTIONS The SECTIONS command tells the linker how to map input sections into output sections, and how to place the output sections in memory.一个连接脚本文件 - ldxscale:ENTRY(_start)OUTPUT_FORMAT(elf32-littlearm, elf32-littlearm, elf32-littlearm)OUTPUT_ARCH(arm)SECTIONSldxscale文

8、件SECTIONS . = ALIGN(4); .text 0 xA4000000 - 0 x80000: _ld_text_start = .; *(.text) *(.got) *(.got.pld) *(.rodata) _ld_text_end = .; _ld_text_size = SIZEOF(.text); . = ALIGN(4); .data _ld_text_end : AT(ADDR(.text) + SIZEOF(.text) _ld_data_start = .; *(.data) _ld_data_end = .; _ld_data_size = SIZEOF(.data); _ld_text_and_data_size = SIZEOF(.text) + SIZEOF(.data); . = ALIGN(4); .bss : _ld_bss_start = .; *(.bss) *(CO

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论