Repository navigation
Upstream sync 10A: relinker, libkernel, libc, unwrap - #493
Conversation
… load with error 126 A relinked executable that cannot load a library reports "GetLastError: 126 - The specified module could not be found.", which also covers a library whose dependent DLLs are missing. On Windows a self-built libs/ directory needs libgcc_s_seh-1.dll, libstdc++-6.dll and libwinpthread-1.dll next to it. For error 126 the stub now adds a line naming them. Refs boykopovar#4482 (cherry picked from commit 1915039)
…erent system libraries On Linux and macOS every guest module listed the converting executable's own DT_NEEDED system libraries, so its bytes could depend on which executable converted it. --executable then failed with "Guest modules convert differently" when the executables need different system libraries that the modules do not, or the same ones in another order. It is the error a title reports on Linux (boykopovar#5268) for its launcher and main executable. Guest modules now list only the system libraries the guest modules themselves need, with the libSceLibcInternal.prx to libc.prx rule. The executable's own DT_NEEDED is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 6adf63c)
Add the missing wide secure formatting exports required by a title whose load failed with `undefined symbol: Im55VJ-Bekc`: swprintf_s and its va_list counterpart follow C11 Annex K.3.9.1.4 (the complete output, including the terminator, must fit), while vsnwprintf_s is the va_list counterpart of snwprintf_s (K.3.9.1.3, truncation with full length). The export names produce NIDs Im55VJ-Bekc, oDoV9tyHTbA and 8SKVXgeK1wY respectively. Document the new functions in docs/dev/debt/libc.md. (cherry picked from commit a0bd257)
The relinker reads a plain ELF executable and skips SELF containers with a warning, so an eboot.bin or a *.prx taken from a title cannot be relinked before it is unwrapped, and the repository has no tool for that. The inner ELF program headers of a container carry stale offsets: a SELF inserts its own metadata blocks between the segments, so the data sits at the offsets of the SELF segment-record table at file offset 0x40. The segments are also packed without honouring p_align, while ELF requires p_offset % p_align == p_vaddr % p_align, which the relinker enforces on guest modules. The tool places the segments from the records, falls back to the vaddr to file mapping of the containing PT_LOAD for segments the table does not cover, copies every region to an offset satisfying the alignment, and refuses a container whose load segments all look encrypted. (cherry picked from commit 2a01e9e)
(cherry picked from commit 31abd1a)
(cherry picked from commit 6beefcc)
Map fixed private anonymous ranges through the existing guest arena. Preserve occupied ranges for MAP_EXCL and use FreeBSD 11.4 errors. Cover replacement, exclusivity, range validation, rounding, and memory access. (cherry picked from commit 6215101)
A title imports setpriority and stops at start-up once getpriority is implemented. Accept PRIO_PROCESS, PRIO_PGRP and PRIO_USER for the guest's own process and fail with ESRCH for any other id and EINVAL for any other which, leaving errno unchanged on success like FreeBSD's libc; the value is not applied, since the guest nice is not the host's scheduling class. (cherry picked from commit afc04c7)
Charge each recorded protection ranges 2 MiB granules to the gpu pool when the range has GPU-access protection bits and to the cpu pool otherwise, so the available counts reflect committed usage instead of staying at the 2048-entry budget. Follows KytyPS5s counting model. (cherry picked from commit 975ed12)
Partial port: the streamed instruction scans (VisitCodeSection in the instruction scanner, the syscall scanner and the call-site resolver) are kept. The executable-buffer reuse and scan progress reporting are not, because this fork's relinker pipeline has no progress reporting and a different conversion entry point. (cherry picked from commit 94ae3f1)
(cherry picked from commit bc71ffb)
(cherry picked from commit e53268d)
(cherry picked from commit 6b8ddfb)
A title queries RLIMIT_NOFILE at start-up in QEMU's os_setup_limits and stopped on the unsupported resource. It reports the descriptor count after which AnyPS5 fails with EMFILE: the C runtime's 8192 low-level descriptors on Windows and the host limit on Linux. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 1aaec97)
…ensions Titles run natively, so a host CPU without an extension that compiled Zen 2 code uses faults with an illegal instruction deep inside a title (boykopovar#3719: SHLX, BMI2). libkernel now reads CPUID and XCR0 when it loads on Linux and Windows, logs the host CPU's extensions and throws, naming the CPU and the missing extensions, before any title code runs. (cherry picked from commit 83a268a)
…5 serves Map hw.model, hw.ncpu, hw.physmem, hw.realmem, kern.arandom and kern.proc.pathname to their FreeBSD MIBs with the size handling of FreeBSD's libc wrapper over name2oid, fail with ENOENT and ENAMETOOLONG as name2oid does, and throw for null pointers, which FreeBSD's wrapper dereferences, and for names sysctl does not serve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit cc3d25d)
…Windows The Windows startup stub stopped at the first import it could not resolve, so a title missing several functions showed one "FAIL: unresolved ELF import" line per run and needed a run per missing function to list them all. The stub now counts unresolved imports, writes the FAIL line of each and goes on with the next import. After the last import it fails once, with the searched library list and the last Windows error as before, and exits with STATUS_ENTRYPOINT_NOT_FOUND. Weak imports, lazy binding and a startup where every import resolves are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4ae26f8)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 74b93ad)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 34cf0e2)
(cherry picked from commit 32a11a5)
… debt lines Upstream keeps these in docs/dev/debt/*.md; this fork keeps them in docs/dev/TechnicalDebt.md. The Host CPU check does not run on macOS hosts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed06a35c03
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| SELF_MAGIC = 0x1D3D154F | ||
| SELF_MAGIC_KERNEL = 0xEEF51454 | ||
| RECORD_OFFSET = 0x40 |
There was a problem hiding this comment.
Start reading SELF records at byte 0x20
A SELF's segment table begins immediately after its 32-byte container header; the existing decoders in tools/unself.py and tools/rosetta/launcher/Unself.cpp both read entry i from 32 + i * 32. Starting at 0x40 skips the first entry, which is normally the data record for the first loadable program, so real plaintext SELF files either retain that segment's stale ELF offset and are refused or silently copy unrelated container bytes. Read from 0x20, preferably bounded by the entry count stored in the SELF header.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real. The record table is now read from 0x20 bounded by the header entry count; fixed in #497
| for index, (_, segment, size) in enumerate(records): | ||
| if index in used: | ||
| continue | ||
| if size == header["size"]: | ||
| used.add(index) |
There was a problem hiding this comment.
Map SELF records by their encoded program index
Valid SELF entries encode their target program-header index in bits 20–35 of flags, and entries without flags & 0x800 are digest metadata rather than program data. Matching every record solely by byte size can therefore swap equally sized programs or select a same-sized digest block, producing a corrupt ELF while reporting success. Filter for data records and assign each one to (flags >> 20) & 0xffff, as the repository's other SELF decoders do.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real. Only data records (flags 0x800) are kept and mapped by program index (flags bits 20-35); fixed in #497
…s) (#497) * Address Codex review findings left on merged #489, #493, #494 NGS2: custom-submixer voices now run their filter chain after mixing; a drained custom-sampler stream reports the EMPTY state flag like a sampler. AJM M4AAC: the first non-delay frame is sized from the ADTS channel configuration and one AAC-LC frame before FFmpeg consumes it. tools: unwrap_self reads the SELF record table from 0x20 bounded by the header entry count, keeps only data records and assigns each by its encoded program index (duplicates refused); check_compile keys compile commands against the repository root so sibling build trees work. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj * AJM M4AAC: size the first raw frame by the configured channel count Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Upstream sync 10A: relinker, libkernel, libc, tools/unwrap (range
d8888df9b..upstream/main, scopes relinker, libkernel, libkernel_sys, libc, kernel, libs, cli, unwrap, host, build). Each commit isgit cherry-pick -xof one upstream commit; upstream'sdocs/dev/debt/*.mdhunks were moved intodocs/dev/TechnicalDebt.md, and commit messages and ported debt lines that named titles or title IDs were reworded.Ported (21 upstream commits + 2 fork commits)
test_windows_import_modules.py).RLIMIT_NOFILE; sysctlnametomib;sceKernelGetSocPowerConsumption; committed ranges insceKernelGetPageTableStats; mmap of regular files (+ test, + debt note); host CPU extension check at start-up (compiled out on Apple hosts, only Linux/Windows x86-64 run it).swprintf_s/vswprintf_s,wcsnlen_s,fegetenv(+ test, refactor, debt move).tools/unwrap_self.py,unwrap_selfctest).docs/dev/TechnicalDebt.mdand keep title names out of them.Adaptations
DoMapAnon, which still callsDarwinRelocateFixedfirst, so fixed maps in [64,512) GiB are still shifted on Darwin. Verified by reading the code path, not by a targeted runtime test.VisitCodeSectionstreaming in the instruction scanner, syscall scanner and call-site resolver is kept. The executable-buffer reuse (Patchby value,TakeBytes) and the scan progress reporting are not ported, because this fork's pipeline has no progress reporting and a different conversion entry point (Conversion.cppdoes not exist here).Skipped
build(macos): configure the full build for x86-64 under Rosetta: forcesCMAKE_OSX_ARCHITECTURES=x86_64and a configure error otherwise; our CI builds the Metal utilities and shader bridge as arm64, so it would break them.fix(libkernel): find main-program symbols when the executable is not position independent: uses glibclink_map,dlinfoanddladdr1; it does not compile on macOS (tried,DynamicLoader.cppfailed).--linux-fixed-base(75cfcec) and its follow-up (3d101e8); case-insensitive relinked module lookup (f0c3a5c; macOS hosts already ignore case).disconnect_datagramEAFNOSUPPORT follow-up is outside these scopes. CI-only, Tracy, web UI and Vulkan commits skipped as instructed; other-slice commits (agc, shader, recompiler, libSce*) belong to other PRs.Evidence
-DANYPS5_ROSETTA_LIBS=ON):rosetta_libs rosetta_engine rosetta_launcher_tests direct_memory_darwin_testsbuilt clean.-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON): ctest 131/131 passed, includingunwrap_selfandwindows_import_modules.guest_memory_testsfixed-anonymous,guest_page_table_stats_tests,host_cpu_tests), because this fork's x86_64 build does not build them.🤖 Generated with Claude Code