-
Dear all, I am checking if elfio is a good replacement for libelf which I used to use to post-process elf files for some micro-controller development. Mainly I use it for some crc calculation, so I need to rebuild a memory dump like it would be on the device, calculate a crc and write the result to some specific section. But while working fine, libelf is somehow difficult to integrate (using windows, cmake etc) The other option is to use binutils libbfd(could use mingw libs here), but I really like the low dependency approach of elfio, which in addition would give me the chance learn some c++ again In order to rebuild the memory structure, I need to know the lma (load memory address) of sections, which is, at least according to my understanding, just possible if using the program/segment headers where I can find a mapping of VIRTUAL to PHYSCAL So, my first question is, does elfio offer a method to obtain the lma of a section? 2nd question: There is no mapping table etc, its is done by iteration and some address + offset magic. In the past I played around and found a method which worked for the elf files I had a that time, but now having a different compiler this method is failing, because the section sizes are overlapping. Anyway, readelf does this correct, but is kind of complex: Here at binutils https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/readelf.c;hb=HEAD#l6711 or here at elfutils https://sourceware.org/git/?p=elfutils.git;a=blob;f=src/readelf.c;hb=HEAD#l1503 can I achieve similar functionality using elfio?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Needed to add some checks, so can align section to segments now:
|
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
Hi,
load_segments() function in elfio.hpp contains a code that determines whether a section is located within a segment. Look for is_sect_in_seg().
Does it answers your question?