elf file thinks its small, but its large! can not generate .bin and .hex files

安稳与你 提交于 2020-01-15 05:18:27

问题


I am working on migrating a project from Kail to Gcc.

Makefile http://www.copypastecode.com/73860/ .ld file http://www.copypastecode.com/73856/

I have a Makefile and a platform.ld script and some .c and .h files. When i make, everything compiles and links and it looks good.

arm-none-eabi-size -B Output/stm32_gps_test.elf

text    data   bss      dec     hex filename
  0       0    2048    2048     800 Output/stm32_gps_test.elf

but when i check the generated files i see this:

ls Output/

7327274 2011-07-02 04:28 stm32_gps_test.elf
0 2011-07-02 04:28 stm32_gps_test.bin
34 2011-07-02 04:28 stm32_gps_test.hex

and:

tail Output/stm32_gps_test.hex

:0400000508000000EF
:00000001FF

Some info on the elf file:

arm-none-eabi-readelf -h Output/stm32_gps_test.elf

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:                           ARM
  Version:                           0x1
  Entry point address:               0x8000000
  Start of program headers:          52 (bytes into file)
  Start of section headers:          7323752 (bytes into file)
  Flags:                             0x5000002, has entry point, Version5 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         1
  Size of section headers:           40 (bytes)
  Number of section headers:         18
  Section header string table index: 15

What is wrong? i have tried to run objcopy to create a binfile and hexfile but the result is always the same.


回答1:


When you disassemble it what do you see? (objdump -D) If you have for example a rom image at 0x80000000 and ram at 0x20000000 the .bin file from objcopy will be at a minimum 0x60000000 bytes plus the size of the image in rom. The intel hex file or srec should work though.



来源:https://stackoverflow.com/questions/6553153/elf-file-thinks-its-small-but-its-large-can-not-generate-bin-and-hex-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!