Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take into account the load point when copying memory from ELF files #183

Closed
wants to merge 1 commit into from

Conversation

pablogsal
Copy link
Member

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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version check makes potentially invalid assumptions about ELF layout
1 participant