7

I am very very new to this, I have elf file input.out and need to create hex executable from it. I am using objcopy to create executable in intel hex format as follows

objcopy -O ihex input.out out.hex

by this out.hex contains data from all sections (.interp, .note.ABI-tag etc), but i am not sure if all of it is required for executable. Is just .text section enough for creating executable hex so can i just use as below or any more sections are required

objcopy -j.text -O ihex input.out out.hex

Also if there any good reference to understand this in detail, I couldn't find much by Goggling. Probably I don't know what to search.

DevC
  • 7,055
  • 9
  • 39
  • 58
  • 1
    What do you mean by 'hex executable'? Those Intel hex files are often used to specify executable code that can be loaded by other software. They are also used to load firmware. – Peter L. Oct 18 '13 at 23:36
  • @Peter sorry if I used wrong term, yes I mean that only "http://en.wikipedia.org/wiki/Intel_HEX" – DevC Oct 19 '13 at 01:58
  • OK, I guess it would help if you mention what you are trying to do. Almost every time I've seen those Intel hex code files it has been to load firmware, not to execute on the host processor. – Peter L. Oct 19 '13 at 02:35
  • I am from release team and I have been asked to create hex file from elf, I think it will be used to burn some chip/mc at later stages. I want to understand do I need to use all sections of elf or only some to create this file like I shown in example above – DevC Oct 19 '13 at 03:02
  • 1
    It depends on what the processor architecture is, what is running on that processor, etc. – Peter L. Oct 19 '13 at 20:20

2 Answers2

12

It could work with

objcopy -O ihex input.elf output.hex
Bolor
  • 413
  • 6
  • 14
1

Add the -S will strip useless sections.

Zhang Li
  • 117
  • 1
  • 11