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]

Re: libelf RDWR and elf_newscn do not work


On Tue, 2013-10-08 at 13:49 +0200, Jiri Slaby wrote:
> On 10/08/2013 11:24 AM, Mark Wielaard wrote:
> >> The attached patch fixed it for me. Any ideas?
> > 
> > Not immediately. Would you mind posting the full code?
> > In particular where does the Elf_Scn that you are adding come from?
> > The code you posted seems incomplete since it only sets sh_type but
> > nothing else.
> 
> It does not matter (the other members are set implicitly). With the
> patch, it works.
> 
> Anyway, see the "#if 0" section in the attached file, even if I
> uncomment it, it does not work.

It is hard to see what you are actually trying to do since as given the
program just crashes and it has several different sections #if 0 and/or
commented out. I am not exactly sure which parts you do and do not
intent to have enabled/uncommented or why.

>  See also the patch I attached earlier
> what it does...

The patch doesn't come with any explanation making it somewhat hard to
know what you intended.

So your patch changes the section write loop in "updatefile".
It ignores the check to see whether the byte order changed or the shdr
comes from reading a file. Then always allocas a new shdr_data instead
of reusing the data from the file. Then for each section memcpy the data
into the new shdr_data ignoring the existing the existing elf state shdr
from the file.

I assume in your case the number of sections changed and the current
test doesn't take that into account? So you also want to reallocate the
shdr in that case?

Thanks,

Mark


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