Search code examples
embeddedhexmicrocontrollerelfhexdump

Elf representation in HEX


I am working on understanding some ground concepts in embedded Systems. My question is similar to understand hexedit of an elf . In order to burn compiler output to ROM, the .out file is converted to HEX (say intel-hex). I wonder how the following informations are preserved in HEX format:

  1. Section header
  2. Symbol tables, debug symbols, linker symbols etc.
  3. Elf header.
  4. If these are preserved in HEX file, how they can be read from hex file?
  5. A bit out question but how the microcontroller on boot knows where .data .bss etc. exists in HEX and to be coppied to RAM?

Solution

  • None of that is preserved. A HEX file only contains the raw program and data. https://en.wikipedia.org/wiki/Intel_HEX

    The microcontroller does not know where .data and .bss are located - it doesn't even know that they exist. The start-up code which is executed before main() is called contains the start addresses of those sections - the addresses are hard-coded into the program. This start-up code will be in the HEX file like everything else.