Windows import resolution only searched the module an import declared,
plus a one-way libkernel_sys/libkernel_web to libkernel.prx fallback.
Modules declaring libkernel.prx for exports AnyPS5 implements in
libkernel_sys.prx or libkernel_web.prx failed to bind at startup; Linux
resolves them through the dynamic linker's global scope. GTA V's
bundled libSceAmpr is such a case. Needed-library augmentation and the
per-import search order now cover the whole kernel family in every
direction.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
BuildEntryStub subtracted the call's next instruction address from the
real entry point in uint64 and range-checked the signed result, so an
entry point more than 2^63 from the stub wrapped into a small in-range
displacement and was written verbatim. The check now goes through
SignedDistance, which classifies both addresses by the 2^63 boundary
and rejects a magnitude int64 cannot hold. The new entry_stub test
places the stub at 0x1000 and the entry near 2^64: main wrote a
wrapped rel32, the change throws.
Resolves the conflict with #8867 in EntryStubTests.cpp: keep its two
kernel-variant tests and the BufferUtils include, and this branch's
libSceAmpr-to-libc fallback test, with all three called from main.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The entry stubs called the title's entry with rbp left as the process
started it (0 on Linux) or as a loop counter left it (0 on Windows). The
title's start code pushes rbp, so the frame-pointer chain of its main
thread ended in a null frame pointer. Unreal Engine walks that chain to
capture call stacks (for an ensure, for example) and reads the return
address at [rbp + 8], so the walk read address 8 and crashed.
Both stubs now push a zero frame record (saved rbp 0, return address 0)
and point rbp at it before the call, so frame-pointer walks stop at the
entry. The Linux stub pushes it below the aligned stack pointer, keeping
the 16-byte alignment at the call. The Windows stub writes it into free
slots of its own frame at rsp+0x40.
PPSA15657 crashed in its stack walk at the title screen in about half of
its runs.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0134RWCyiyydJBbfKz8g9Bwe