ELFIO icon indicating copy to clipboard operation
ELFIO copied to clipboard

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

Open oss-explorer opened this issue 4 years ago • 4 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?

oss-explorer avatar Oct 01 '21 10:10 oss-explorer

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.

serge1 avatar Oct 01 '21 17:10 serge1

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.

Meiri28 avatar Jan 01 '22 13:01 Meiri28

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

serge1 avatar Jan 01 '22 16:01 serge1

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.

Meiri28 avatar Jan 01 '22 17:01 Meiri28

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

serge1 avatar Nov 12 '22 22:11 serge1