I have managed to use elftoolchain to read an ELF file and write my
own version of objdump, a disassembler, a loader, etc.  So I can get
it to read ELF files just fine.

What I am having a lot of trouble with is writing ELF files.  I tried
opening the ELF file using

    Elf *elf = elf_begin(fd, ELF_C_RDWR, NULL);

I then just do nothing to the ELF object and then write it back out using:

    elf_update(elf, ELF_C_WRITE);

I end up with a corrupted ELF file.

Any ideas?

My goal is to post-process an ELF file after it has been linked.  I
just need to be able to iterate over the sections and edit them and
then just write the file out again.

Additional question: is there some reason that when opening with
ELF_C_RDWR that we must write the ELF object back out to the same
input file?  I would rather not modify the file in place, but instead
create another one.  Not a show-stopper, it just feels like an
unnecessary restriction.  Perhaps I mis-read the documentation.

Note that I'm using version 0.6.1 instead of version 0.7.1 because the
latter seems to overwrite the system ld when we install it.  One thing
that would really help would be if elftoolchain could be used in-place
without installing it; perhaps this can be done, but I could not get
it to work.  This is not a show-stopper as we can use 0.6.1.

Daniel


_______________________________________________
Elftoolchain-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/elftoolchain-developers

Reply via email to