From: Brabes <br...@po...> - 2009-08-28 11:19:13
|
Hello, I am going through all sections with elf_nextscn() then getting the header with elf32_getshdr(). For some sections I modify the sh_flags member of the shdr, and then call elf_flagshdr on the scn. When I call elf_update, though, the sh_size member of shdrs whose flags I updated is set to zero! Using gdb and a watchpoint, I found that the sh_size member is being zeroed in _libelf_compute_section_extents(). I think the problem is when _libelf_compute_section_extents sees a scn marked dirty, it recomputes its size by adding up the Elf_Data d_size values. However, because I haven't used elf_getdata on the scn, the scn's s->s_data STAILQ is empty, and so the scn_size remains at zero. This is backed up by that fact that if I do elf_getdata on the scn before doing elf_flagshdr, the problem goes away. I also note that the problem does not happen with the LGPL version of libelf. I believe the solution would be to ensure that the Elf_Data structures are loaded before calculating the section size in _libelf_compute_section_extents(). Thanks, |