Skip to content
Advertisement

ELF file headers

A quick question about elf file headers, I can’t seem to find anything useful on how to add/change fields in the elf header. I’d like to be able to change the magic numbers and to add a build date to the header, and probably a few other things.

As I understand it the linker creates the header information, but I don’t see anything in the LD script that refers to it (though i’m new to ld scripts).

I’m using gcc and building for ARM.

thanks!

Updates:

  • ok maybe my first question should be: is it possible to create/edit the header file at link time?

Advertisement

Answer

I don’t know of linker script commands that can do this, but you can do it post-link using the objcopy command. The –add-section option can be used to add a section containing arbitrary data to the ELF file. If the ELF header doesn’t contain the fields you want, just make a new section and add them there.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement