Skip to content

fix(libSceSystemService): find a converted executable by the main executable's extension - #18857

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
atinseau:codex/fix-loadexec-secondary-executable
Nov 16, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
atinseau:codex/fix-loadexec-secondary-executable

Conversation

@atinseau

Copy link
Copy Markdown
Contributor

What

The relinker names an executable converted with --executable after its guest path and the extension of the main output. sceSystemServiceLoadExec looked for it with the extension of the executable that calls it. From a secondary executable that sits beside an extensionless main output (the usual macOS output), the lookup added the secondary's own suffix and failed: Black Ops II stopped when its Zombies executable started the Multiplayer one.

The lookup now takes the extension of the main executable that the first LoadExec records in APS5_EBOOT, and falls back to the calling executable when the variable is unset. The same applies to the Windows path of the function.

guest_system_load_exec_secondary starts a third executable from a secondary one, beside a main executable with an extension (.elf) and beside one without, each time through hard links of the test executable and a recorded APS5_EBOOT.

Tested

macOS 27.0.1, Apple M3 Max (36 GB), Release build with -DBUILD_TESTING=ON, x86_64 under Rosetta 2. main does not run its libraries on macOS, so both sides are main 3b7f31fa7 with the macOS port (the squash of #8658, which its author upstreams in parts) and local macOS build fixes for tests of main that Apple clang refuses; the change side adds this PR's commit.

  • guest_system_load_exec_secondary passes with the change.
  • The 32 tests whose names start with guest_system or guest_lnc_util_load_exec pass on both sides, and the new test is the 33rd on the change.
  • python3 tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py and a title search found no open pull request that changes sceSystemServiceLoadExec.

Not tested: Linux and Windows.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Context

Found while bringing up Call of Duty: Black Ops II (the Zombies executable starts the Multiplayer one).

…cutable's extension

The relinker names an executable converted with --executable after its
guest path and the main output's extension. sceSystemServiceLoadExec
looked for it with the extension of the executable that calls it. From a
secondary executable beside an extensionless main output, such as the
usual macOS output, the lookup added the secondary's own suffix and
failed: Black Ops II stopped when its Zombies executable started the
Multiplayer one.

The lookup now takes the extension of the main executable that the first
LoadExec records in APS5_EBOOT, and falls back to the calling executable
when the variable is unset.
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 8651 core/libs/prx/libSceSystemService/Export.cpp
PR 13327 core/libs/prx/libSceSystemService/Export.cpp
PR 15973 core/libs/prx/libSceSystemService/CMakeLists.txt

@atinseau

Copy link
Copy Markdown
Contributor Author

Red before green, run on the same macOS tree: with the new test and without the Export.cpp change, guest_system_load_exec_secondary aborts on its second case (the extensionless main output): sceSystemServiceLoadExec: /app0/anyps5-load-exec-secondary-<pid>-bare/third.bin without its converted executable; relink with --executable ... and a secondary executable did not start another one beside a main executable without an extension. With the change it passes.

@JJenkx

JJenkx commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Windows check of head b3b8daed41, merged onto main 631278973f (merge a9b86bb8e7). Setup: Windows 11 Enterprise 22621, MinGW-w64 GCC 15.2 UCRT, Release.

The merge configures cleanly. This PR's test target, guest_system_load_exec_secondary_tests, is not defined in a Windows build, so no test of this change runs here.

AI-assisted: yes.

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against b3b8daed41:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_system_load_exec_secondary_tests built cleanly.
  • CTest (guest_system_load_exec_secondary):
    1/1 Test #4120: guest_system_load_exec_secondary ...   Passed    0.13 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceSystemService/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4120: guest_system_load_exec_secondary ...Subprocess aborted***Exception:   1.15 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libSceSystemService/Export.cpp: Verified PrepareLaunch reads APS5_EBOOT on Windows (GetEnvironmentVariableW) and POSIX (std::getenv), properly falling back to ownPath/own when unset or empty, and avoiding buffer overruns when recordedLength >= recorded.size().
    • core/libs/prx/libSceSystemService/Export.cpp: Verified that converted secondary executable lookup resolves via main.extension() rather than own.extension(), correctly appending .exe, .elf, or an empty string to HostExecutable::ConvertedName without duplicate extension defects.
    • core/libs/prx/libSceSystemService/Export.cpp: Verified the MainExecutable (/app0/eboot.bin) branch preserves existing launch semantics, correctly targeting the recorded main executable when invoked from a secondary executable.
    • core/libs/tests/GuestSystemServiceLoadExecSecondary.cpp: Verified test logic covers both extensionless and .elf-suffixed main binary layouts using hard links, sets APS5_EBOOT to main, and confirms sceSystemServiceLoadExec successfully transfers control to the third executable.
    • core/libs/prx/libSceSystemService/CMakeLists.txt: Verified guest_system_load_exec_secondary is registered under if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR APPLE) with correct include directories, link libraries (libSceSystemService, libkernel, libc), and a 20-second timeout.
    • AGENTS.md compliance: Verified zero comments in code across all modified and newly added files (Export.cpp, CMakeLists.txt, GuestSystemServiceLoadExecSecondary.cpp), no title-specific hardcoding, and adherence to Conventional Commits in the PR title.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

@oneandonlydean
oneandonlydean merged commit 7c444b7 into boykopovar:main Nov 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants