[PATCH] libelf: handle PN_XNUM in elf_getphdrnum before shdr 0 is cached
Sun Mar 22 22:40:34 GMT 2020
On Sat, 2020-03-21 at 11:21 -0700, Omar Sandoval wrote:
> I encountered this in drgn on a vmcore for a large server created by
That makes sense since [vm]cores contain lots of segments.
> but I was able to put together a minimal reproducer.
> Generate the ELF file with this python script:
> And run this program:
> This should output 66000, but it outputs 65535 instead.
That is a really nice testcase. If we tweak it a little (so all
segments have the same load address) then it compresses to just 188
bytes with bzip2. Would you mind, and give your signed-off-by, for
adding the attached to the testsuite? It fails before, and passes after
> Looking at file_read_elf, the cache is only initialized from
> from ELF_C_RDWR_MMAP and ELF_C_READ_MMAP_PRIVATE as long as
> matches the host and the section headers are properly aligned:
> if (map_address != NULL && e_ident[EI_DATA] == MY_ELFDATA
> && cmd != ELF_C_READ_MMAP /* We need a copy to be able to
> write. */
> && (ALLOW_UNALIGNED
> || (((uintptr_t) ((char *) ehdr + e_shoff)
> & (__alignof__ (Elf64_Shdr) - 1)) == 0)))
I had missed that part. So it is actually common to not have the phdrs
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 8033 bytes
More information about the Elfutils-devel