ELF file headers

2019-03-19 06:41发布

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?

9条回答
Anthone
2楼-- · 2019-03-19 07:35

I didn't finish the book but iirc Linkers and Loaders by John Levine had the gory details that you would need to be able to do this.

查看更多
闹够了就滚
3楼-- · 2019-03-19 07:35

In Solaris you can use elfedit but I think you are really asking solutions for Linux. Linux Is Not UniX :P

查看更多
女痞
4楼-- · 2019-03-19 07:37

I haven't done this in awhile, but can't you just append arbitrary data to an executable. If you always append fixed-size data it would be trivial to recover anything you append. Variable size wouldn't be much harder. Probably easier than messing w/ elf headers and potentially ruining you executables.

查看更多
登录 后发表回答