PE: keep every name for a shared export ordinal #555
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/555"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T04:50:14Z.
What
ImageInfo::parseused the PE-specific export table, which keeps one nameper address-table slot. When two names aliased one ordinal, the earlier name
was silently dropped from
ImageInfo::exportsand fromvictory inspect --exports. The genericObject::exportsiterator yields every named export(and then ordinal-only entries), so the parser now uses it and maps its
target and flags back to our representation. A synthetic PE with two names
for one ordinal plus a separate export covers the alias case.
An AI tool wrote part of this change.
Tested
cargo test --workspace: 165 passed, 0 failed, 3 ignored. The new regression asserts all three names and their RVAs survive parsing.cargo check --target x86_64-pc-windows-gnu --workspace --testspasses. No Windows host here.cargo xtask policypasses (150 files ok). No game files or data from them were added.Checklist
cargo xtask policypasses. No game files or data from them were added.Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T04:55:44Z.
Review: APPROVED
Verified on Windows 11:
Imported from Marvisak/VIctory. Originally posted by sebastianspicker on 2026-11-24T11:02:09Z.
Tested
b71c252applied ontomainffe310e(macOS, Rust 1.98.1).mainexactly as described:[("beta", 1, 0x1200), ("gamma", 2, 0x1204)], so "alpha" is dropped. It passes with the PR.Address(0)slots itself.object0.41'sPeExportIteratorstill skips zero addresses in its ordinal-only pass (export.rs,address == 0 => continue), andunused_export_slots_are_not_exportsstill passes, so the gap handling isn't lost. The only difference is a named entry pointing at a zero slot, which is malformed anyway.victory inspect --exports, so that's cosmetic.cargo clippy -p victory-pe --all-targets -D warnings: clean on macOS and forx86_64-pc-windows-msvc(with-p victory).Looks good to me.
AI-assisted.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:46:19Z.
Review: APPROVED
Tested
b71c252on Windows 11, RTX 5070, MSVC:cargo test -p victory-pe8 passed, includingevery_name_of_a_shared_ordinal_survives.cargo clippy -p victory-pe --all-targetsis clean.victory inspect --exportson a local title executable gives the same export list before and after (identical lines, apart from unrelated output differences), so images without aliased ordinals are unaffected.Object::exportskeeps every name. Converting the address back to an RVA withwrapping_sub(image_base)is right, because the generic iterator adds the base.Address(0)(unused address-table slots) is gone. The generic iterator only yields named entries and ordinal entries that have a target, so gaps don't come back. Worth a one-line comment, since the old code called that out explicitly.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T12:38:19Z.
Review: APPROVED
Fixes a real data-loss bug: the PE-specific export table keeps one name per address-table slot, so two names sharing an ordinal lost all but the last. Switching to the generic
file.exports()iterator yields every name (then ordinal-only entries), and the new test proves alpha+beta both survive on ordinal 1.Checked the risky bits against
object0.41.0 sources:ReadTarget::Address { address }is image-base-relative absolute;wrapping_sub(image_base) as u32correctly recovers the RVA, and the iterator is name/ordinal-driven, so unused address-table slots (the oldAddress(0)filter) are never yielded.ExportTargetvariants (Absolute,Tls,TlsDescriptor,Resolver) are ELF/Mach-O-only — unreachable for PE, so the_ => (None, None)catch-all is dead code in practice (adebug_assert!(false)or comment wouldn't hurt, but not blocking).ExportFlags::Pe { ordinal }is what the PE iterator returns; the_ => 0fallback is likewise unreachable for PE exports.Reexportmaps library+name/ordinal to the same"dll.name"/"dll.#N"strings as before — format preserved.Verified locally: test-merge with current main (
ffe310e) clean;cargo test -p victory-pe --locked(macOS arm64, rustc 1.98.1) → 4 passed / 4 failed, where the 4 failures are the pre-existingimage::testsplatform issue I flagged on #529 (they fail identically on unmodified main — the test binary is Mach-O, not PE). The newevery_name_of_a_shared_ordinal_survivestest is among the 4 passing.