Suppose you need to add a section to an ELF binary to contain information gathered at compile time, but to be used at link time or run time. Here's how to add a section named .okdata
and either populate it with data either after or before emitting the ELF binary.
In this case, you'll add file’s contents to an already existing binary. objcopy
copies and translates object files, such that adding a new section is a matter of writing that new section’s contents into the ELF file.
(Optional) Create a simple program’s object file.