This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using libelf for modify files


Hi all,

I try to use libelf for modify Linux kernel modules (for
instrumentation purposes).

When only some bytes in ELF sections' data are changed, everything
works.

When new data blocks are appended to some sections, everything works
provided that previous blocks has been read (using elf_getdata()).
Otherwise previouse section's content are zeroed or even entire
section disappears.

When try to append new section to the file, either error about
insufficient memory occures at update (elf_update()) stage, or no error
generated, but section is not added.

Attached simple program demonstrates another behaviour, when section
with garbage in its header is added. Valgrind shows that library calls
pwrite() with buffer contained some unaddressable bytes.

I even try to manually mark different ELF elements as dirty (using
elf_flag*()), but nothing is changed.

Does the example is wrong? Or library contains errors in implementation?

-- 
With regards,
Andrey Tsyvarev                          mailto:tsyvarev@ispras.ru

Attachment: test.c
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]