Validate symbols against advertised object files - #1200
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63104006d9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let supports_object_symbol_validation = | ||
| matches!(object_file_format.as_str(), "coff" | "elf" | "mach-o"); |
There was a problem hiding this comment.
Match the declared object format to the target
This treats every recognized format as valid for every target, without comparing it to target_object_format(triple). For example, an x86-64 Linux archive that declares coff and contains x86-64 COFF objects can pass the subsequent kind, architecture, endianness, and symbol checks even though downstream Linux linkers cannot consume those advertised objects.
Useful? React with 👍 / 👎.
| if !is_static | ||
| && (supports_object_symbol_validation || is_llvm_bitcode_format) | ||
| && advertised_object_paths.contains(&path) |
There was a problem hiding this comment.
Validate advertised objects in static archives
For every +static distribution this guard skips collect_advertised_object_symbols, including its parsing, relocatable-kind, format, architecture, and endianness checks. Consequently, a referenced object in a static archive can contain arbitrary bytes or an unusable format (especially Windows COFF objects, which validate_possible_object_file otherwise ignores) and validation only confirms that its path exists.
Useful? React with 👍 / 👎.
Summary
PYTHON.jsonCloses #459.
Test plan
cargo fmt --checkcargo test --lockedcargo build --release --lockedcargo clippy --locked --all-targets./check.py