Repository navigation
|
Currently ELFIO succeeds in parsing the header of a memory-mapped ELF dump file, but fails to parse other elements of the ELF file that are present also in memory such as segment headers and For some of these structures no changes in parsing code need to be made since fields in the header point to them even in memory (segment headers, for example). For others (symbols, for example), different parsing logic is needed so I suggest adding a flag to |
Replies: 10 comments 4 replies
|
I am not sure what you call “memory-mapped ELF dump file”. An ELF file loaded to memory has limited amount of information available. Even file sections names are not available due to the lack of string tables. Basically, in common case which includes bare metal images, only segment data payload is accessible. You still may use ELFIO library for parsing original file and dump memory by following virtual memory locations. |
|
@serge1 What I mean by “memory-mapped ELF dump file” is reading from the /proc/PID/mem of a process the segments that contain the loaded ELF file and writing them into a new file - a dump of the loaded ELF file. As for the lack of information - you are right. There's less information to recover in memory-mapped ELFs. But there's still some interesting data to get such as the header, the segment headers and their content, the In |
|
The idea of dump file processing sounds interesting. Would you please advise which tool can I use to produce an example of such file? Edit: I have managed to produce the dump by using 'gcore' utility |
|
Here's a short python script I found here. It dumps all the used parts of a process memory. This is a little extensive since all we need is the mapping of the process exe file (the first mapped file shown in `/proc/PID/maps), so it needs a little editing in order to extract only the relevant parts. |
|
My attempt to implement this request is located at branch 'translate_offset'. Specifically the commit b527ea9. It is able to take the translation table located in /proc/pid/maps and use it to access ELF file components located in memory. For example, for /usr/bin/base file I got the following: Reading afterwards from /proc/pid/mem gives: vs. the content located in the original ELF file: Segment data is also looks in sync. For example: vs. the same segment data in the file: So, nothing interesting so far. I am stuck with the section header content. While the file contains: corresponding information is not available in memory: So, without section header information, no interesting data can be retrieved from memory. Please let me know if I am missing something essential, but, I didn't find any info that cannot be taken from the original ELF file. I stuck with the section header and didn't continue implementation of the similar translation mechanism for segments |
|
I am moving the issue to "Discussions" |
|
I have implemented address translation for segments too. It looks better than sections. You need to provide program arguments like: For example: or Is that what you have in mind? Please note - it is different from processing of a core dump. The core dump looks like a regular ELF file. Just a note: I found it convinient to compare segments' data by using 'proc_mem' vs. 'elfdump' examples |
Symbol information is located in a section. The section header is not accessible. I guess a dynamic linker used the information from corresponding sections, but didn't map it to memory, or, even didn't uploaded it.
Do you propose to create a customized class derived from |
I am going to merge the branch to the main one.
Thank you for the initial idea of /proc/mem parsing and participating in this discussion! |
|
To finish the discussion, I'd like to let you know that the implementation has been merged to the main branch and branch 'translate_offset' has been removed. The order and meaning of the address translation table has been modified, so, be careful in case you already have some examples |
I have implemented address translation for segments too. It looks better than sections.
Please give a try to 'proc_mem' example located in 'translate_offset' branch.
You need to provide program arguments like:
For example:
or
Is that what you have in mind?
Please note - it is different from processing of a core dump. The core dump looks like a regular ELF file.
Just a note: I found it convinient to compare segments' data by using 'proc_mem' vs. 'elfdump' examples