relinker: sfiii-ps5 (PPSA93303) companion libc.prx is refused because its function st_size values are the real libc sizes, not the stub sizes #14893
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-11-01T23:17:44Z.
What happens
Converting sfiii-ps5 (
PPSA93303, v1.0.0 release,PPSA93303.zipsha256632efadfaf9f6e73316c51268813719fa42f277a482144ae3c225894259af1b2) withrelinker --windowsonmain0580e5c951fails on its bundledsce_module/libc.prx:That module isn't Sony's
libc.prx. It's the title's own loader companion, generated bytools/ps5/companion-exports.pyfromtools/ps5/libc-exports.tsv(2568 NIDs, each with a binding, kind and size). Per the README, the title runs natively on the console.movl $i,%eax; jmp sf3_stub(line 71). Only a few, such assetjmp, have real bodies.st_sizefrom the TSV (line 130). Those are the sizes of the real libc functions, not of the stubs.The result in the shipped module:
PT_LOADis 0x75a2 bytes (flags=PF_X). It holds 1875 function symbols, each at its own address.[st_value, st_value + st_size)running past the next function's start.CLT04GjI7UE, size 7598, and 0x5908 + 7598 = 0x76b6.Where the relinker rejects it
GuestImageReader.cpp:218requires every defined function symbol's whole[value, value + max(size, 1))to lie in one executablePT_LOAD. The Windows and macOS writers pass the same extent toGetRva(WindowsGuestModuleWriter.cpp:143,MacOsGuestModuleWriter.cpp:92).CodeInstructionCollector.cpp:304→:221, "Code analysis: function exceeds executable segment" at 0x5908, because code analysis uses each function symbol's size as a range to decode.test_tls_function_coverage.py:580and:587require exactly that rejection for a symbol range that overruns its segment.So converting this module needs code analysis to stop trusting function
st_sizehere, beyond the 13 overrunning symbols.What the loader does with
st_sizeIn FreeBSD 11.4's rtld, the only place a symbol's
st_sizeis read isdo_copy_relocations(amd64/reloc.c:85), which copies a data object. The otherst_sizeuses inrtld.candmap_object.carestruct statfile sizes. A function symbol's size affects nothing at load time, which fits with this module loading on the console. I don't have a measurement of what Sony's loader checks.Question
Should the relinker accept a guest module whose function-symbol sizes don't describe its code? If so, how should code analysis find those functions? For example, when a module's function ranges overlap one another or overrun their segment, it could use the symbols only as roots and follow control flow. Or should this stay refused, and the companion's generator emit stub-sized symbols instead? I haven't opened a PR because either answer changes what
test_tls_function_coverage.pypins.Not run: the title itself, since it doesn't convert. Even once it does, it needs the player's own disc images to get past its launcher.
🤖 Generated with Claude Code