0

As I know basic difference between bin and elf that

Bin file contain only bit or bytes of data and you need to give address of memory when you load it in memory,

while in case of elf it have symbol look-ups and relocatable table, so no need to give address when you program it.

Now see attached image. I am using LPCexpresso to program elf file in device. if you not give base address then it will take 0x00000000 by default. Now i first programme bootloader.elf and then main.elf. in both case I am not giving base address.

Now my question is if I am not giving address then how elf file decide to program correct location and after programming one image if I programme another image then isn't it overwrite first one? (because in both case we haven't give address and by default it 0x00000000)

4

1 回答 1

3

通常,此信息位于链接描述文件创建的 ELF 文件中。

作为 GNU binutils 的一部分,有一个名为“readelf”的工具,它显示有关 ELF 部分和标题的信息。不幸的是,这些工具根据其配置工具使用前缀,很可能它会被称为“arm-none-readelf”。如果您没有,请查看 http://www.yagarto.org/

因此,如果您输入“arm-none-readelf main.elf -a”,它应该显示如下内容:

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           YOUR ARCHITECTURE
  Version:                           0x1
  Entry point address:               YOUR ENTRY ADDRESS
  Start of program headers:          52 (bytes into file)
  Start of section headers:          YOUR SIZE
  Flags:                             0x300
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         36
  Size of section headers:           40 (bytes)
  Number of section headers:         55
  Section header string table index: 52

(请注意,这只是示例数据)。

通常在所有编译器中都有允许指定 ELF 加载地址的链接器选项(通常称为 .ld 文件)。

希望能帮助到你。

于 2016-05-20T09:31:33.747 回答