Bind system ordinal imports by their stored ordinal #81
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/82"
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 R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T15:41:09Z.
Change
tools/cpu_call_aot.pydecided whether an import was by ordinal fromimp.name is None. pefile names ordinal imports from ws2_32.dll, wsock32.dll and oleaut32.dll from its built-in table but keepsimport_by_ordinalset. For those providers the translator rejected a correct#N --link-namebinding as unbound, and accepted a binding to the table name, resolving it by name in the provider rather than by the ordinal the image calls. The translator now readsimport_by_ordinal.call_evidence.pyandcpu_chained_aot.pyonly match fixed named imports outside these DLLs, and pefile's skipped entries do not shift IAT slot addresses, so those tools are unchanged.Verification
Linux, pefile 2024.8.26, stand-in fixtures built with clang-cl, llvm-ml and lld-link from
tests/cpu/direct.asm,import.def,import_provider.cppandordinal_provider.def:import_check.system_ordinalbefore the fix:unbound import ws2_32.dll!WSAInstallServiceClassA at IAT slot RVA 0x2090. After the fix: passes.ws2_32.dllthat also exportsWSAInstallServiceClassAby name at ordinal 1,--bind ws2_32.dll WSAInstallServiceClassAwas accepted before the fix and generated a named dllimport; after the fix it is rejected withunbound import ws2_32.dll!#77.Windows:
ctest --preset dev --no-tests=error -R '^cpu_aot_(ordinal_import|import_call)$' -Vat8289615on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, Python 3.12, RTX 5080 (driver 32.0.16.1692):cpu_aot_import_callandcpu_aot_ordinal_importpassed. The Windows CI job also passed: https://github.com/R0Y00/Xbox2Windows/actions/runs/44920494779.Evidence and follow-up
The regression test reuses the existing ordinal fixtures: it copies the provider to
ws2_32.dlland rewrites the image's import DLL name in place, so no new binary inputs are added. The nameWSAInstallServiceClassAfor ordinal 77 comes from pefile's built-in table. The binding contract stays "ordinal imports require#Nand--link-name".Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T15:46:28Z.
Thanks for covering system ordinal imports. Please mark this ready for review once you're satisfied with the named and ordinal binding tests.