fix(elf): detect imports via SHN_UNDEF instead of st_value (fixes #419)#534
Open
wyf027 wants to merge 2 commits into
Open
fix(elf): detect imports via SHN_UNDEF instead of st_value (fixes #419)#534wyf027 wants to merge 2 commits into
wyf027 wants to merge 2 commits into
Conversation
On MIPS, undefined dynamic symbols can have a non-zero st_value while still referencing SHN_UNDEF. Using st_shndx fixes false positives when filtering exported symbols (fixes m4b#419). Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Resolved the rustfmt CI failure in commit 2b42a39 by applying the formatter to src/elf/sym.rs. Local verification: cargo fmt -- --check. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Sym::is_import()to treat symbols withst_shndx == SHN_UNDEFas imports instead of relying onst_value == 0.is_import()helper to takeshndxrather thanst_value.st_value.Fixes #419.
On MIPS ELF, undefined dynamic symbols (e.g.
memcpy@GLIBC_2.0) can have a non-zerost_valuewhile still being imports. The previous heuristic incorrectly classified them as defined exports.As suggested by @philipc in the issue, checking
st_shndx == SHN_UNDEFis the reliable indicator.Test plan
cargo test is_importcargo test --lib