Skip to content

Fix symbol resolution for rust binaries#321

Merged
Xyene merged 1 commit intojanestreet:masterfrom
JosiahWhite:symbol-resolution-fixes
Apr 12, 2025
Merged

Fix symbol resolution for rust binaries#321
Xyene merged 1 commit intojanestreet:masterfrom
JosiahWhite:symbol-resolution-fixes

Conversation

@JosiahWhite
Copy link
Contributor

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 first LOAD 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.

@viluon
Copy link

viluon commented Mar 25, 2025

Thanks for your work on this! Now that owee v0.8 is out, perhaps this PR is ready for review @JosiahWhite?

@JosiahWhite JosiahWhite force-pushed the symbol-resolution-fixes branch from 0343b31 to 28cd489 Compare March 26, 2025 20:13
@JosiahWhite JosiahWhite marked this pull request as ready for review March 26, 2025 20:13
Copy link
Member

@Xyene Xyene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

@Xyene
Copy link
Member

Xyene commented Apr 12, 2025

Could you please rebase on top of the latest master? Don't expect there'll be merge conflicts, but the GitHub build workflow bitrotted.

Signed-off-by: Josiah White <me@josiahwhite.io>
@JosiahWhite JosiahWhite force-pushed the symbol-resolution-fixes branch from 28cd489 to b5e7a39 Compare April 12, 2025 20:24
@JosiahWhite
Copy link
Contributor Author

Should be all set

@Xyene Xyene merged commit 2dca730 into janestreet:master Apr 12, 2025
2 checks passed
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.

3 participants