Fix symbol resolution for rust binaries #321
Draft
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.
Currently symbol resolution on rust binaries returns an address that is 0x1000 above the correct symbol leading to triggers not working.
The current logic seems to assume the symbol value is an offset from the start of the file, but the spec actually states for an executable that this value is a virtual address already: "In executable and shared object files, st_value holds a virtual address."
Most cases can be solved by just picking the first address from the maps file and adding the symbol value to it but there is an edge case where an exotic binary could select a base virtual address that doesn't start at 0x0. This can be detected by reading the program headers and looking at
p_vaddr
for the firstLOAD
segment and subtracting it from the first mapping address that is pulled from /proc/pid/maps.This PR is blocked by let-def/owee#35 being merged and released.