Hi,
When using libelf from elfutils 0.143, the elf_rawdata function fails (and
elf_errmsg says "out of memory") when trying to get raw data using these
function calls:
int fd = open(elfinput, O_RDONLY);
Elf* elf = elf_begin(fd, ELF_C_READ, NULL);
size_t filesize = 0;
const char* rawdata = elf_rawfile(elf, &filesize);
(The full uncut example reproducing this bug is attached.)
As far as I can tell, this is due to elf->maximum_size being ~0 when this
call is made. If I change the flags given to elf_begin to ELF_C_READ_MMAP,
this works fine.
The same example above works just fine when using libelf by Michael
Riepe.
Is this a bug, or are there any prerequisites for calling elf_rawfile?
Kind regards,
// Martin Storsjö