From: Eric S. <sch...@gm...> - 2011-10-20 18:18:07
|
Joseph Koshy <jk...@us...> writes: > e.s> Would it be possible to share a simple C script which opens, edits and > e.s> then writes out a modified elf file using libelf? > > There are a few such examples in libelf's test suite; please look for > the constant "ELF_C_RDWR" in: > > http://sourceforge.net/apps/trac/elftoolchain/browser/trunk/test/libelf/tset/elf_update/update.m4 > Thanks for the pointer. Attached is my attempt to re-write one of the test cases into an external C file to allow extending a data section in an existing elf file. The resulting script fails with the following... $ ./extend-a-section hello fstat() failed: "Bad address". Size error: expected=118, elf_update()=6536 I imagine that I broke something while replacing the TC_* macros with C code. I apologize for asking such a simple question, but would you mind taking a look to see if the error is obvious to you. Thanks -- Eric |