elf_newdata() does not append

Paul Stravers varkentje at oink-oink-oink.net
Fri Aug 24 13:41:51 UTC 2012


My intention is to read an ELF file, then append some data to the end of a
section, then update the existing ELF file.
I wrote a small example program that works fine with libelfg0, but it fails
to append with elfutils (it replaces the data instead of appending to it).

The following is observed on Ubuntu-11.10 (installed version of libelf1 is
0.152). I have attached a small example program that demonstrates the
behavior.

With libelfg0 version 0.8.13 the effect of the elf_newdata() call is to
__append__ the new data buffer to the end of any existing data in a section.
However, with libelf1 the elf_newdata() call actually __replaces__ existing
data when elf_update() executes.

The man page at
http://docs.oracle.com/cd/E19253-01/816-5172/elf-getdata-3elf/index.htmlsuggests
that appending is the intended behavior. Can anyone confirm this?
It would be very inconvenient to have two libraries in the world that seem
to provide the same source-level API but with slightly different semantics
...

Thanks for clearing this up,
Paul Stravers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fedorahosted.org/pipermail/elfutils-devel/attachments/20120824/6f9696d3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_append.c
Type: text/x-csrc
Size: 2569 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/elfutils-devel/attachments/20120824/6f9696d3/attachment.bin>


More information about the elfutils-devel mailing list