Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?
like image 281
Richard Avatar asked Oct 24 '08 12:10

Richard


1 Answers

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.

like image 62
Ben Combee Avatar answered Nov 10 '22 00:11

Ben Combee