serge1/ELFIO

Read only required section information in the elfio class 'load' function

oss-explorer opened this issue · 5 comments

Can only the required sections of the executable be read into the memory instead of reading the complete binary/all the sections and segments of the binary in the 'class elfio' load() function?
With the complete executable being read into the memory, there is a peak in memory usage when binary sizes are in GB.
Can you please consider this enhancement?

Thank you for your suggestion.
The current design of the library based on the fact that lifetime of the file stream cannot be garanteed after elfio::load() function finishes.
I'll see whether a lazy section/segment data loading is possible as far as user garantees proper lifetime of the stream.

beside the peak in the memory, there is another reason to take this approach. some of linux distribution have live memory dump file in /proc/kcore, in this elf file you can't always read from all of his segments(some of them are not readable although the file is with read permissions). this scenario lead to error in the stream and later to mistakes in the data elfio parse from this file.

Hi @Meiri28, it is interesting aspect. How do you urge the library to treat /proc/kcore being an ELF file?

This file is in elf formate. It's looks like a core dump but his size is enormous and as I said not all the data is readable. You can read more about kcore file in here.

The commit 9827eac implementing 'lazy' load for segments and sections should finalize the initial request. Please reopen the issue if it does not work for you