Take into account the load point when copying memory from ELF files #183
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we need to copy memory from ELF files (normally from the static
data section) we need to take into account the load point of the first
PT_LOAD segment to properly map an address to an offset in the file. Our
procedure to do this transformation is to find the first loaded map in
/proc/PID/maps and then calculate the offset of the target address from
the start of this map. This offset only will be the same as the offset
from the start of the ELF file if the load point of the corresponding
PT_LOAD segment is 0, otherwise we need to calculate it to ensure we are
mapping it correctly.
Closes: #174