UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 25252

14.2 EDK - An error message occurs when I attempt to convert an ".elf" file to binary file using mb-objcopy

Description

When I attempt to convert an ".elf" file to a binary file using mb-objcopy.exe, the following error message occurs and a corrupt output (bin) file is generated:

"Error Message:

---------------------------------------

mb-objcopy -O binary loader.elf loader.bin
BFD: Warning: Writing section `.text' to huge (ie negative) file offset 0x86000000.
BFD: Warning: Writing section `.init' to huge (ie negative) file offset 0x86000b2c.
BFD: Warning: Writing section `.fini' to huge (ie negative) file offset 0x86000b58.
BFD: Warning: Writing section `.ctors' to huge (ie negative) file offset 0x86000b78.
BFD: Warning: Writing section `.dtors' to huge (ie negative) file offset 0x86000b80.
BFD: Warning: Writing section `.rodata' to huge (ie negative) file offset 0x86000b88.
BFD: Warning: Writing section `.data' to huge (ie negative) file offset 0x86000cc8.
BFD: Warning: Writing section `.jcr' to huge (ie negative) file offset 0x86001014.
mb-objcopy: loader.bin: File truncated"

Solution

The warnings are caused by a huge gap in memory between the vectors sections and the main sections for the executable file.

When the objcopy program encounters discontinued memory sections, it automatically pads them with 0s. In the above case, since the offset is so large, the program truncates the output ".bin" file and issues the warning messages. Otherwise, the output file will be extremely large (imagine the size in bytes from 0x00 to 0x86000000 = 2 GB!).

To work around this problem, you can use the following commands to prevent the padding in the discontinued memory sections.

mb-objcopy -O binary -j .vectors.reset -j .vectors.sw_exception -j .vectors.interrupt -j .vectors.hw_exception ./spi_user_app/executable.elf ./flash_burn/spi_user_app1.b
mb-objcopy -O binary -R .vectors.reset -R .vectors.sw_exception -R .vectors.interrupt -R .vectors.hw_exception ./spi_user_app/executable.elf ./flash_burn/spi_user_app2.b
cat ./flash_burn/spi_user_app1.b >> ./flash_burn/spi_user_app2.b

These commands generate the bin file individually for different sections (with only and without the vector sections) and concatenates them together afterward.

This Answer Record also applies when you want to reduce the size of the resulting bin file from mb-objcopy and store the bin in Flash. This bin file cannot be run from Flash, a bootloader will need to be used to copy the bin file from Flash into DDR.

Note: It has been seen that some Xilkernel applications converted into bin format were not executing once bootloaded into DDR. To workaround this issue the catcommand was not run.

Instead, when generating the MCS file in impact (or from command line) the two bin files where past in separately in concatenation. So, for example if the bin file containing the vector space was placed at an SPI offset of b400000, then the other sections would be placed at b400000 + vector space (400hex). To do this from command line will look like:

promgen -spi -w -p mcs -u 0 download.bit -data_file up b40000 app1.bin -data_file up b40400 app2.bin

Linked Answer Records

Master Answer Records

Answer Number Answer Title Version Found Version Resolved
34609 12.x EDK - Master Answer Record List N/A N/A

Associated Answer Records

Answer Number Answer Title Version Found Version Resolved
36497 12.1 EDK - Bootloader Fails to Load User Application if it Contains an Interrupt Routine N/A N/A
AR# 25252
Date Created 09/04/2007
Last Updated 01/30/2013
Status Active
Type General Article
Tools
  • EDK - 10.1 sp2
  • EDK - 10.1
  • EDK - 10.1 sp1
  • More
  • EDK - 10.1 sp3
  • EDK - 11.1
  • EDK - 11.2
  • EDK - 11.3
  • EDK - 11.4
  • EDK - 11.5
  • EDK - 12.1
  • EDK - 12.2
  • EDK - 12.3
  • EDK - 12.4
  • EDK - 13.1
  • Less