Repository navigation
feat(relinker): add --trace-imports for Windows executables - #4547
Conversation
|
On the overlap comment: none of the four implements the same thing, and this PR does not build on any of them, so
AI-assisted (Claude Code). |
7450d06 to
ff34ff9
Compare
ff34ff9 to
c73d027
Compare
With --trace-imports the entry stub resolves TraceImport_nid_no_patch in libc.prx and passes each function import through it before writing the slot: every PLT slot, and a GOT slot only when the original symbol is a function, so data imports such as __stdoutp keep their address. Without the option the output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto current Checked the entry-stub change, the function/data split of imports ( |
c73d027 to
430e5c8
Compare
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
What
--trace-importsmakes the Windows entry stub pass each function import throughTraceImport_nid_no_patchin libc.prx (#4546) before writing its slot, so the calls a title makes to the libraries named inAPS5_TRACE_CALLSare recorded and shown by the crash and abort reports. Without the option the output is unchanged. It covers part of #3815: the entry of a call, on Windows; arguments, results and Linux are not done.Traced: every PLT slot, and a GOT slot only when the original symbol is a function. The second rule matters: the rebuilt dynamic symbol table types every import as a function, so the original type is carried from the input relocation. Without it a data import such as
__stdoutpgot a thunk and a homebrew title crashed when it wrote through it.The option conflicts with
--lazy-bindingand needs libc.prx among the libraries; a libc.prx without the export fails at start-up with a message. Weak imports, imports of modules loaded at run time and functions looked up withsceKernelDlsymare not traced. Limits are indocs/dev/debt/libc.mdanddocs/dev/debt/relinker.md, usage in USAGE.md.This branch contains the commit of #4546; only the second commit belongs to this PR.
Tested
Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), on main 43e3a70.
windows_trace_imports(new): a relinked fixture reaches the hook with the import's name and library and runs the address the hook returns; a data-typed GOT import is left alone; a weak import still resolves; a libc.prx without the export fails with the message; the option is rejected without--windows, with--lazy-bindingand without libc.prx.getpagesizefrom the built libkernel.prx returns 0x4000 without the option, with it and the variable unset, and with it andAPS5_TRACE_CALLS=libkernel; only the last prints the call.eboot.binandsce_module/libc.prxunwrapped from fSELF, relinked with--windows --to-intel --trace-imports; Intel i7-1165G7; before the rebase onto current main): with every library traced it reaches the same point as the untraced run (WAD loaded, audio opened at 48000 Hz,ST_Init) and ends with a normal process exit after 901,307,599 recorded calls. The last 64 were 62sin, onepthread_mutex_unlockand onesceAudioOutOutput, which is why feat(libc): record traced import calls on Windows #4546 also counts calls per import.--windows --to-intel --trace-imports: the option was used, together withAPS5_HANG_DUMP_SECS, to confirm the start-up hang described in fix(libc): find mspace chunks for minimum-aligned allocations by index #4280 (main thread inside the mspace allocator, no window), now addressed by fix(libc): round mspace block sizes to the 32-byte alignment #4407. The report from that run was not kept. With local changes outside this PR the title goes on to loaddemo1and present frames; that part does not depend on this option.tools/check_conventions.pyandtools/check_test_registration.pypass.Not tested: either title after the rebase, a commercial title, Linux or macOS output (the option is rejected there).
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code