3 How to modify section data
Serge Lamikhov-Center edited this page 2021-08-14 07:10:36 +03:00

The primarily design of the library is to use 'elfio' object as a read-only reader or as a writer for newly created ELF object or executable files. In both such scenarios, modification of existing section data is not required.

Saying this, there are couple of ways to alternate the section data. One of the ways is demonstrated in 'anonymizer' example. An external file is modified on base of the parsed information.

The second way is just altering raw memory pointed by section->get_data(). An example of this can be found in generic_set_entry_rel() function in elfio_relocation.hpp file.

Please be warned: read/modify/write scenario may or may not work - there are too many cross references inside the format and it is easy to damage them. This will lead to incorrect object/executable file