Skip to content

fix(relinker): resolve a needed module on the executable that exports its imports - #15245

Closed
simnJS wants to merge 11 commits into
boykopovar:mainfrom
simnJS:fix/needed-module-on-executable
Closed

simnJS wants to merge 11 commits into
boykopovar:mainfrom
simnJS:fix/needed-module-on-executable

Conversation

@simnJS

@simnJS simnJS commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What

Builds on #11432, which is in main; only the commits after it are new here.

A converted module can name the executable of its title as a dependency, under a module name the image does not record. Trackmania (PPSA02195) has such a module: the Windows entry stub then looks for a library of that name in libs/ and stops with error 126.

--executable-module <name> (repeatable) names the needed libraries to resolve on the executable. For a named library the Windows entry stub takes the image handle with GetModuleHandleW(NULL) when there is no libs/<name>.dll; a libs/<name>.dll that is present but fails to load stops start-up with its load error. Linux and macOS leave a named library out of DT_NEEDED and LC_LOAD_DYLIB at conversion. GetProcAddress resolution stays on the export table #11432 adds. Conversion fails when the executable does not export a symbol imported from a named library, and prints a line for each library resolved this way.

The name is given explicitly because the image does not keep the executable's module name, and overlapping export names do not show that a library is the executable. A library that is not named loads as before, and a bundled module of the same name is still loaded. The debt file records how the provider is chosen and the remaining gaps: on Windows the name stays in .needed.json, and a TLS import from the executable fails at conversion.

Tested

Linux x86-64, relinker-only build (-DANYPS5_RELINKER_ONLY=ON), Release: executable_module_imports (a named library, an unnamed library whose imports the executable exports, and a named library with an import the executable does not export, converted for Windows, Linux and macOS), windows_executable_exports, cli_args, cli_help and the guest module tests pass. With the named binding disabled, executable_module_imports fails. The native Windows cases of executable_module_imports run only on Windows and were not run on this head; on Linux the test checks that the generated PE holds the .dll path only for a named library. On Linux and macOS only the converted dependency lists were checked; nothing was executed there. Trackmania (PPSA02195) was not converted with --executable-module.

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: fix(relinker): export Windows executable symbols #11432
  • Fixes: none
  • Unblocks: PPSA02195 Trackmania (PPSA02195) #13709
  • GPUs tested: n/a
  • AI-assisted: yes

muhmuhkuh and others added 4 commits November 2, 2026 21:54
… its imports

A converted module can name the title's executable as a dependency under
a module name the image does not record. The Windows entry stub now takes
the image handle for a needed name with no module suffix and no file in
the run path when the executable exports every symbol imported from it.
Linux and macOS leave such a name out of the dependencies at conversion.
@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line build relinker docs labels Nov 2, 2026

@XairRrR XairRrR 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.

Reviewed — changes requested

The change builds, the relinker tests it reaches pass, and the negative control fails as it should. One problem blocks it: the Windows stub checks for the file libs/<name>, but the loader opens libs/<name>.dll. So a libs/<name>.dll that is present but fails to load for any reason is silently replaced by the executable, and the debt entry and the test do not show this.

What I ran

Head 16b292dab4a936dc9737b79357e62f481a62baee, main 5cb015caaaaf83f8ee431414ee6a457b5b307d49, merged tree df336d6a6cf8b23a2340d3104e49dad981fe4576, on Debian 13 with GCC 14.2.0 (Release, Ninja).

git diff --check 5cb015caaaaf83f8ee431414ee6a457b5b307d49...16b292dab4a936dc9737b79357e62f481a62baee
python3 tools/check_conventions.py --base 5cb015caaaaf83f8ee431414ee6a457b5b307d49
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "^(windows_executable_exports|executable_module_imports|linux_executable_exports|macos_executable_exports|guest_module_dir|guest_module_directories|guest_module_identity|guest_module_fini|guest_module_args|windows_import_modules|macos_output|windows_fixed_base|agc_driver_image_sample_lod_clamp_shader_lane|agc_driver_image_sample_lod_clamp)$"
# negative control 1: production files of 4807af4ff254 back to 67d34af2df49 (#11432 only)
ninja -C build -j32 -l32 relinker
ctest --test-dir build --output-on-failure -R "^(executable_module_imports|windows_executable_exports)$"
# negative control 2: also WindowsElfPatcher.hpp, WindowsPePatcher.cpp, Conversion.cpp from main
ninja -C build -j32 -l32 relinker
ctest --test-dir build --output-on-failure -R "^windows_executable_exports$"
# restore the merged tree, rebuild, rerun both tests
ninja -C build -j32 -l32 relinker
ctest --test-dir build -R "^(executable_module_imports|windows_executable_exports)$"
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure / build / libs (script) ok
windows_executable_exports, executable_module_imports pass (0.12 s and 0.14 s)
linux_executable_exports, macos_executable_exports, guest_module_*, windows_import_modules, macos_output, windows_fixed_base pass
agc_driver_image_sample_lod_clamp_shader_lane (new failure in build.json) fails again; not caused by this PR, see below
unwrap_self_..._destination_directory_group (new failure in build.json) not caused by this PR, see below
Worktree after restore git status --porcelain empty

About the two failures build.json lists as new:

  • agc_driver_image_sample_lod_clamp_shader_lane: the failure baseline is from 096c45570f, 227 commits behind main. Since then main has merged AGC changes to the same feature (#12980, 4e2a028e43 fix(agc): bind a T# minimum LOD through an S# that holds the LOD at 0). This PR changes only files under core/relinker, its tests and a debt doc, and nothing of the AGC driver or the shader recompiler. The failure comes from main, not this PR. I did not rebuild the AGC test with the PR's files reverted.
  • unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group: fails with os.chown(...) → EINVAL inside the sandbox. This PR does not touch tools/, so the failure comes from the test environment.
Failing AGC test, last line
AGC graphics: image_sample_lz through the S# that holds the LOD at 0 with T# MIN_LOD 768 over BASE_LEVEL 0 with a second S# of words 1 0 and 2 5242880, and a second T# of MIN_LOD 0 and LAST_LEVEL 0: thread 0 component 1 is 0.000000, expected 0.062500

Negative control

  1. I set the production files of commit 4807af4ff254 back to their state at 67d34af2df49, which keeps only #11432's export table: WindowsEntryStubBuilder.{hpp,cpp}, WindowsExportBuilder.{hpp,cpp}, WindowsPePatcher.cpp and GuestModuleBuilder.cpp. After rebuilding relinker, executable_module_imports fails in check_linux, and windows_executable_exports still passes, as expected:

    output
    AssertionError: ['$ORIGIN/app0/sce_module/consumer.prx.guest.prx', 'SyntheticMain', 'libkernel.prx']
    
  2. I then also restored WindowsElfPatcher.hpp, WindowsPePatcher.cpp and Conversion.cpp from main, which unhooks the executable export table. windows_executable_exports fails with AssertionError: {}.

  3. I restored the merged files and rebuilt. Both tests pass again, and the worktree matches the merged tree.

On Linux this control covers only the Linux and macOS dependency lists and the presence of the PE export. The Windows parts of executable_module_imports run only when os.name == 'nt', so this machine does not run the new entry-stub code (see "Not verified").

Findings

Blocking

The file probe checks a different file than the one LoadLibraryExW opens, so a broken libs/<name>.dll silently falls back to the executable
WindowsEntryStubBuilder.cpp#L656-L676, #L705-L711

  • What the code does: the path in rsi is path + libraries[index] (L150-L152). An executable provider has no module suffix, so that path has no extension. LoadLibraryExW adds .dll to such a path. The PR's own windows-library case depends on that: it puts the provider at libs/SyntheticMain.dll and expects it to load (test L90-L99). GetFileAttributesW does not add anything, so probeMissingFile checks libs\SyntheticMain.
  • Result: a libs/<name>.dll can be present and still fail to load: missing dependency, corrupt file, wrong architecture, failing DllMain. The probe then finds no libs\<name>, takes the missingOptional branch, and resolves every import against the executable. It prints a message only with --windows-diagnostics, and that message says the module was "not found".
  • Why it blocks: CONTRIBUTING says missing imports fail at startup with a clear error, and fallbacks that keep running are not allowed. The debt entry also understates the gap: it names only "a libs/<name>.dll whose own dependency is missing", and the gap covers every load failure.
  • Test: the "not a module" case in the test writes libs/SyntheticMain with no extension (test L66-L69). The loader never opens that file, so the case fails for the wrong reason. A broken .dll is not tested at all.
  • Suggested fix:
    • For an executable provider, probe the name the loader opens, <path>.dll. A trailing . would also do if you prefer to keep the bare name: then add . to the LoadLibraryExW path for these names instead.
    • Change the test to write the invalid file as libs/SyntheticMain.dll and expect the load to fail.
    • Shorten the debt sentence about libs/<name>.dll to what is still open, or drop it once the probe matches.

Non-blocking

  • The bare-name file and the .dll file are not told apart. The same mismatch affects the existing optional-library probe on main (the !imported[index] path). After the fix, a stray libs/<name> with no extension would still make the stub fail instead of falling back. That is safe, but worth keeping consistent with whatever fix you choose.
  • Earlier commit: the branch carries #11432's commit 67d34af2df49, as the description says. Its executable export table is only checked here through windows_executable_exports and negative control 2, and I did not review it beyond its interaction with this change.

Not verified

  • The Windows entry stub was not run. The test's native cases (GetModuleHandleW(NULL), the diagnostics text, the partial, suffix and library cases) execute only on Windows, and this machine is Linux. The blocking finding rests on the code and on the PR's own windows-library case, which needs the .dll added; I did not reproduce it on Windows.
  • macOS: only the Linux-hosted --macos dependency-list check ran; nothing was executed on macOS.
  • Trackmania (PPSA02195): not converted or run.
  • I did not confirm the AGC failure on main by rebuilding the AGC test with this PR's relinker files reverted. My conclusion that it comes from main rests on the PR touching no AGC files and on recent main commits to the same feature.
  • Vulkan validation comparison: skipped by the script because no AGC driver, shader recompiler or VideoOut file changed. It does not apply to this PR.

To get this to a good state

  1. Make the executable-provider probe check the file LoadLibraryExW opens (<name>.dll), so a present but broken library stops startup with the load error.
  2. Change the "not a module" case to libs/SyntheticMain.dll, and rerun the Windows tests on Windows.
  3. Cut the debt entry's libs/<name>.dll sentence to whatever remains open.

… module

The executable provider path had no extension, so LoadLibraryExW opened
libs/<name>.dll while GetFileAttributesW probed libs/<name>. A libs/<name>.dll
that was present but failed to load fell back to the executable. The path now
ends in .dll, so the load and the probe name the same file and a broken library
stops startup with its load error.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@oneandonlydean oneandonlydean self-assigned this Nov 3, 2026

@XairRrR XairRrR 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.

Re-checked — approved

The new commit c547f5e845 adds .dll to the path of an executable-provider library. The GetFileAttributesW probe and LoadLibraryExW now check the same libs\<name>.dll, so a present but broken library stops startup with its load error. The commit also changes the test and the debt entry to match.

What changed since my last review

  • The first four commits are unchanged (delta: 1:1 through 4:4 are identical).
  • New commit c547f5e845 fix(relinker): probe the .dll file the loader opens for an executable module:
    • WindowsEntryStubBuilder.cpp: the executableProviders computation moves before the path table, and name += ".dll" is added for providers (L148-L166). The probe after a failed load (L671-L678) therefore checks the file the loader opened.
    • Test: the "not a module" case now writes libs/SyntheticMain.dll (test L66-L70).
    • Debt: the sentence about a libs/<name>.dll being passed over for the executable is removed.
  • There are no new comments by others. The description's Tested section is unchanged; the Windows runs it reports are accepted as author-reported.

What I ran

Head c547f5e8457d3b76619883caf2de85884dac1b98, main d1ae628bc2f62459cce1e9872ba5632c938c71f2, merged tree db181f9d5678bf0a557f330da16bff08c0678a21, on Debian 13 (GCC 14.2.0, Release, Ninja).

git diff --check d1ae628bc2f62459cce1e9872ba5632c938c71f2...c547f5e8457d3b76619883caf2de85884dac1b98
python3 tools/check_conventions.py --base d1ae628bc2f62459cce1e9872ba5632c938c71f2
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "^(windows_executable_exports|executable_module_imports|windows_import_modules|guest_module_identity|guest_module_directories|macos_output|windows_fixed_base)$"
# convert the test's windows-resolved and windows-absent fixtures with the built relinker and search the PE for the UTF-16 library path
python3 -c "...test_executable_module_imports.convert(...)..."
git status --porcelain
Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure / build / libs (script) ok
Script test run (791 tests) no new failures, no timeouts; only unwrap_self_..._destination_directory_group fails, and it fails on main too (known failure)
7 focused relinker tests all pass (≤ 0.43 s each)
Embedded library path, provider case (windows-resolved) libs\SyntheticMain.dll present, bare libs\SyntheticMain absent
Embedded library path, non-provider case (windows-absent) bare libs\SyntheticMain, unchanged; the loader still appends .dll itself
Worktree afterwards git status --porcelain empty

The AGC failure I reported last time as coming from main no longer appears. The baseline is now current main.

Previous findings

  • Blocking: the probe checked libs/<name> while the loader opened libs/<name>.dll. Resolved.
    • Provider paths now end in .dll (L163-L164), and I confirmed the converted PE embeds libs\SyntheticMain.dll for the provider case.
    • After a failed LoadLibraryExW, the probe at L678 sees the existing file and branches to the failure path instead of missingOptional.
    • The test's invalid file is now libs/SyntheticMain.dll.
    • The debt sentence is removed.
  • Non-blocking: the bare name and .dll were not told apart. No longer applies to this PR's path: a stray extensionless libs/<name> is now ignored for providers. The same mismatch remains in the optional-library probe that is already on main (the !imported[index] path at L671), but this PR does not change it.
  • Non-blocking: #11432's commit 67d34af2df49 was reviewed only through its interaction with this change. Still open as a scope note. The commit is unchanged; windows_executable_exports passes.

New findings

Blocking

None.

Non-blocking

None.

Negative control

The only test line that changed runs only when os.name == 'nt'. Reverting the production change on this Linux machine would leave the test's result unchanged, so a ctest-based control would prove nothing. Instead, I checked the effect on the converted PE (table above): the provider path carries .dll and the non-provider path does not. The earlier negative controls for the Linux/macOS dependency lists and the export table still apply, because those files did not change.

Not verified

  • Windows execution: the entry stub was not run. The native cases (GetModuleHandleW(NULL) fallback, the broken libs/SyntheticMain.dll failing startup, diagnostics text) execute only on Windows. The author reports that they pass on Windows 11 with WinLibs GCC 15.2.0.
  • macOS: only the Linux-hosted --macos dependency-list check ran.
  • Trackmania (PPSA02195): not converted or run.
  • Vulkan validation: skipped by the script; no AGC driver, shader recompiler or VideoOut file changed.

@bunbeans2-arch

Copy link
Copy Markdown
Contributor

On Windows, the native cases of executable_module_imports fail without this PR's changes and pass with them. That includes the broken libs/SyntheticMain.dll case that the review above couldn't run on Linux. I did not convert or run Trackmania (PPSA02195); these are the PR's own tests only.

Setup: Windows 11 Pro 10.0.22631, i9-9900K, MSYS2 UCRT64 GCC 16.1.0, Release, this PR (c547f5e845) merged into main d1ae628.

  • ✅ With this PR: executable_module_imports and windows_executable_exports passed 5 of 5.
  • ❌ This PR's own sources reverted, keeping fix(relinker): export Windows executable symbols #11432's commit 67d34af2df as this branch carries it. The six production files of 4807af4ff2..c547f5e845 (WindowsEntryStubBuilder.{hpp,cpp}, WindowsExportBuilder.{hpp,cpp}, WindowsPePatcher.cpp, GuestModuleBuilder.cpp) were taken from main + 67d34af2df. After that, the tree differed from main + 67d34af2df only in this PR's test, its CMakeLists.txt test entry and the debt doc. Rebuilt; result in 5 of 5 runs:
    • executable_module_imports failed at its first native case (check_windows → expect_entry). The windows-resolved program exited 3221225781 with Failed to load module: ...\libs\SyntheticMain / GetLastError: 126. So without this PR, a module whose import is exported by the executable can't start on Windows.
    • windows_executable_exports still passed, so fix(relinker): export Windows executable symbols #11432's part was intact.
  • ❌ Only the last commit's WindowsEntryStubBuilder.cpp change reversed (c547f5e845, the .dll probe). Rebuilt; executable_module_imports failed in 5 of 5 runs at expect_load_failure (test line 70). With a broken libs/SyntheticMain.dll in place, the program printed Transferring control to ELF entry point and exited 42 instead of failing to load. So the silent fallback found in the earlier review is real on Windows, and c547f5e845 fixes it.
  • main d1ae628 alone: both tests are new, so main has none of them to run.

Looks good on Windows 👍

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 3, 2026

@XairRrR XairRrR 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.

Re-checked — approved

The only new commit is ccb32747bb, a merge of main 4f41f4c375 into the branch. The PR's five commits are unchanged, the merged tree builds and passes the PR's tests, and the Windows-only cases I could not run now have an independent Windows report.

What changed since my last review

  • Commits: ccb32747bb merges main 4f41f4c375 into the branch. The range-diff shows the five PR commits as =, so the PR's own content is the same as in c547f5e845, which I reviewed last time.

  • Overlap with main: between d1ae628bc2 and 4f41f4c375, main changed two files this PR also changes.

    • GuestModuleBuilder.cpp gained unavailableUnused and --omit-unavailable-dependencies.
    • Conversion.cpp changed too.
    • Interaction: unavailableUnused returns false whenever a module imports a symbol from the dependency. A name the executable provides always has at least one import, so unavailableUnused never removes it. The two filters chain without conflict: unavailableUnused runs first, then loadsHost, at the addHost and neededLibraries call sites.
  • New comment by bunbeans2-arch (Windows 11, MSYS2 UCRT64 GCC 16.1.0):

    • Both tests pass 5 of 5 with the PR.
    • With the PR's production files reverted, executable_module_imports fails at expect_entry with error 126.
    • With only the .dll probe change reverted, it fails at expect_load_failure.

    This covers the Windows execution and the Windows negative control that I listed under "Not verified". I accept these results as reported by that reviewer; I did not reproduce them.

  • The description is unchanged.

What I ran

Head ccb32747bbae78d7d83363658dc9229133fc31a5, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 3272c5e643371d626caef780118bd8d54b3557b7, on Debian 13 (GCC 14.2.0, Release, Ninja).

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...ccb32747bbae78d7d83363658dc9229133fc31a5
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
git diff --stat d1ae628bc2f62459cce1e9872ba5632c938c71f2 4f41f4c375f5abb487dbd184fbc150f31994d762 -- <the PR's production paths>
git diff d1ae628bc2f62459cce1e9872ba5632c938c71f2 4f41f4c375f5abb487dbd184fbc150f31994d762 -- core/relinker/relinker/src/guest/GuestModuleBuilder.cpp core/relinker/elfpatcher/src/windows/WindowsTlsBuilder.cpp core/relinker/elfpatcher/src/windows/WindowsGuestModuleWriter.cpp
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "^(windows_executable_exports|executable_module_imports|windows_import_modules|guest_module_identity|guest_module_directories|macos_output|windows_fixed_base)$"
git status --porcelain
Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure / build / libs (script) ok
Script test run (822 tests) no new failures, no timeouts. Only unwrap_self_..._destination_directory_group fails, and it also fails on main (known failure).
7 focused relinker tests 7/7 pass, each ≤ 0.15 s
Worktree afterwards git status --porcelain empty

Previous findings

  • Non-blocking: #11432's commit 67d34af2df49 was reviewed only through its interaction with this change. Still open, as a scope note. The commit is unchanged, and windows_executable_exports passes here and in the new Windows report.

All other earlier findings were resolved or no longer applied in my last review, and nothing has changed them since.

New findings

Blocking

None.

Non-blocking

None.

Not verified

  • Windows execution: I did not run anything on Windows. The native cases and their Windows negative control are reported by the author and by bunbeans2-arch.
  • Negative control: I did not repeat it on this machine. Neither the tests nor the production files changed since my last review, and on Linux the changed test lines run only under os.name == 'nt'.
  • macOS: only the Linux-hosted --macos dependency-list check ran.
  • Trackmania (PPSA02195): not converted or run.
  • Vulkan validation: the script skipped it because no AGC driver, shader recompiler or VideoOut file changed.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 3, 2026
@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head ccb3274 merged onto main 1c8c0ef · tested 2026-11-04 06:03 UTC · 15 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 1,069 passed · 4 failed (0 new, 3 also fail on main, 1 unstable on main) · 8 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 1,081 of 3,842 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (523 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.2 s, ⚠️ agc_driver_image_sample_unnormalized 40.0 s, ⚠️ public_headers 37.2 s, ⚠️ agc_driver_sample_multisample_target 32.5 s, ⚠️ agc_driver_lazy_resolved_abi 32.4 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 8 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
Validation IDs already present on main (8 IDs in 446 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (446 tests): agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, agc_driver_bindless_images, and 438 more
VUID-vkCmdCopyImage-srcImage-01548 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
VUID-VkSamplerCreateInfo-addressModeU-01079 (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeU-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeV-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeW-parameter (1 test): agc_driver_image_gather_volume
Skipped (8)
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
Reproduce
git fetch origin ccb32747bbae78d7d83363658dc9229133fc31a5 1c8c0efc8c41314402e6966da5bef6ea3d639d10
git checkout 1c8c0efc8c41314402e6966da5bef6ea3d639d10 && git merge --no-ff ccb32747bbae78d7d83363658dc9229133fc31a5
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi simnJS,

Thanks for the work on resolving the executable's own exports. One change before this can go in: please let the conversion be told which module is the executable, instead of guessing it from the import list.

At ccb32747bb, a suffixless needed library is treated as the executable when it has at least one import and every imported name is in the executable's export set. On Windows that is executableProviders in WindowsEntryStubBuilder.cpp:148-159. When libs/<name> is missing, the stub then binds the library to GetModuleHandleW(NULL) (:707-710). On Linux and macOS the same test drops the needed-library entry in GuestModuleBuilder.cpp:220-229, :269 and :337. Overlapping export names do not show that a library is the executable, so a different library that happens to import only names the executable also exports would silently bind to the executable. The missing library then fails later, at the first call into it, instead of at start-up with a clear error. The only message today is the "executable module" line at :713, and that is written only when dependencyDiagnostics is on. The non-Windows path prints nothing.

Could you add an explicit way to name the provider, for example a repeatable option that lists the needed-library names to resolve on the executable (--exclude-sce-module in CliArgs.cpp:155 is a model for a list option)? A library would be bound to the executable only when it is named there, and an unnamed library would keep today's behaviour, so nothing that loads now changes. The tests would then name the intended provider, and one more would check that an overlapping but unnamed library is not bound to the executable.

If a new option is more than you want to take on here, a second-best step is to keep the guess but make it visible: print a conversion-time warning naming each library that was treated as the executable (the converter already reports through inputProgress.Message, for example Conversion.cpp:106), on all three platforms and whether or not the dependency diagnostics are on. That makes a wrong match visible when the output is built, though it still binds it.

Whichever you pick, please update the debt entry to say how the provider is chosen.

Thanks again.

…n-executable

# Conflicts:
#	core/relinker/CMakeLists.txt
#	core/relinker/elfpatcher/include/elfpatcher/windows/WindowsExportBuilder.hpp
#	core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp
#	core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
#	docs/dev/debt/relinker.md
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 5, 2026
A needed library was resolved on the executable when it had at least one
import and the executable exported every imported name. Overlapping export
names do not show that a library is the executable, so a different library
could be bound to it silently and fail later, at its first call.

The library is now resolved on the executable only when --executable-module
names it. An unnamed library keeps loading as before. Conversion fails when
the executable does not export a symbol imported from a named library, and
prints a line for each library resolved this way on Windows, Linux and macOS.
@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 6, 2026

@Superseabas Superseabas 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.

Windows run of the --executable-module head, 068fccf2bb, the first on Windows since the change @oneandonlydean asked for. The native Windows cases of executable_module_imports pass, and nothing else in the Windows relinker and entry-stub tests changes.

Head merged onto main e64c194c43 (clean merge, local only). Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Python 3.13, Release, BUILD_TESTING=ON, run from PowerShell so that the WinLibs runtime DLLs come first on PATH.

Tests. ctest -R '^(windows_|entry_stub|guest_zero_finalizer|cli_|linux_executable_exports|macos_executable_exports|executable_module)' -j 4, 3 runs:

Tree Result, each run
main 54 of 55
this PR 55 of 56: the same plus executable_module_imports

The one failure on both trees is windows_crash_thread_name (#15578). guest_zero_finalizer, entry_stub, windows_entry_stub_bounds, windows_import_modules, windows_dependency_diagnostics, windows_executable_exports, cli_args and cli_help pass in every run. executable_module_imports runs its native cases here (os.name == 'nt'): the resolved entry, a broken libs/SyntheticMain.dll stopping startup with Failed to load module:, the diagnostics line, the unnamed load failure and the provider copied into place.

Red check. With executableProviders[index] = false; in WindowsEntryStubBuilder.cpp, executable_module_imports fails 3 of 3, at assert PROBED in output.read_bytes() (line 91).

The resolved line. WindowsPePatcher and GuestModuleBuilder both print it, so I checked whether a Windows conversion prints it twice. It doesn't. Converting the test's consumer.prx fixture with --executable-module SyntheticMain prints Needed module SyntheticMain is resolved on the executable (--executable-module) once with --windows, once for Linux and once with --macos.

Non-blocking. A name that matches no needed library is ignored without a word. The same fixture converted with --executable-module SyntheticMian exits 0 with no resolved line and nothing on stderr, so SyntheticMain is then loaded as an unnamed library and fails at startup. A warning for a name that matches no needed library would make a typo show up at conversion time.

check_conventions.py --base main passes. No title was converted.

AI-assisted: yes (Claude Code)

@github-actions

github-actions Bot commented Nov 7, 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 4847 docs/user/USAGE.md
PR 5925 docs/user/USAGE.md
PR 6149 core/relinker/CMakeLists.txt
PR 6924 docs/user/USAGE.md
PR 7173 core/relinker/CMakeLists.txt
docs/dev/debt/relinker.md
PR 7531 core/relinker/CMakeLists.txt
docs/dev/debt/relinker.md
PR 7642 docs/user/USAGE.md
PR 9345 docs/user/USAGE.md
PR 9508 docs/user/USAGE.md
PR 10193 docs/user/USAGE.md
PR 10861 core/relinker/CMakeLists.txt
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
core/relinker/relinker/src/guest/GuestModuleBuilder.cpp
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 11525 core/relinker/relinker/src/guest/GuestModuleBuilder.cpp
core/relinker/relinker/src/pipeline/Conversion.cpp
docs/dev/debt/relinker.md
PR 11628 core/relinker/CMakeLists.txt
core/relinker/elfpatcher/include/elfpatcher/windows/WindowsEntryStubBuilder.hpp
core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
docs/dev/debt/relinker.md
PR 11661 core/relinker/CMakeLists.txt
core/relinker/elfpatcher/include/elfpatcher/windows/WindowsEntryStubBuilder.hpp
core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
docs/dev/debt/relinker.md
PR 11689 core/relinker/CMakeLists.txt
core/relinker/elfpatcher/include/elfpatcher/windows/WindowsEntryStubBuilder.hpp
core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
docs/dev/debt/relinker.md
PR 11698 core/relinker/CMakeLists.txt
core/relinker/elfpatcher/include/elfpatcher/windows/WindowsEntryStubBuilder.hpp
core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
docs/dev/debt/relinker.md
PR 12678 core/relinker/CMakeLists.txt
core/relinker/cli/include/Cli.hpp
core/relinker/cli/src/CliArgs.cpp
core/relinker/cli/tests/CliArgsTests.cpp
core/relinker/main.cpp
core/relinker/relinker/include/relinker/guest/GuestImage.hpp
core/relinker/relinker/include/relinker/pipeline/Conversion.hpp
core/relinker/relinker/src/guest/GuestModuleBuilder.cpp
core/relinker/relinker/src/pipeline/Conversion.cpp
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 12746 docs/user/USAGE.md
PR 12863 docs/user/USAGE.md
PR 12910 docs/dev/debt/relinker.md
PR 13486 core/relinker/CMakeLists.txt
PR 13928 docs/user/USAGE.md
PR 13929 docs/user/USAGE.md
PR 14241 docs/dev/debt/relinker.md
PR 15456 docs/user/USAGE.md
PR 15642 core/relinker/CMakeLists.txt
docs/dev/debt/relinker.md
PR 15973 docs/user/USAGE.md
PR 16354 docs/user/USAGE.md
PR 16371 core/relinker/relinker/src/pipeline/Conversion.cpp
PR 16372 core/relinker/relinker/src/pipeline/Conversion.cpp
PR 16571 docs/user/USAGE.md
PR 17259 docs/user/USAGE.md
PR 17557 core/relinker/CMakeLists.txt
core/relinker/cli/src/CliArgs.cpp
core/relinker/main.cpp
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 17558 core/relinker/CMakeLists.txt
core/relinker/cli/src/CliArgs.cpp
core/relinker/main.cpp
docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 18082 docs/user/USAGE.md
PR 18293 core/relinker/relinker/src/pipeline/Conversion.cpp
PR 18373 core/relinker/CMakeLists.txt
PR 18449 core/relinker/CMakeLists.txt
PR 18523 core/relinker/elfpatcher/include/elfpatcher/windows/WindowsEntryStubBuilder.hpp
core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
docs/dev/debt/relinker.md
PR 18693 docs/user/USAGE.md
PR 19462 docs/user/USAGE.md
PR 19532 docs/user/USAGE.md
PR 20389 core/relinker/relinker/src/guest/GuestModuleBuilder.cpp
core/relinker/relinker/src/pipeline/Conversion.cpp
docs/dev/debt/relinker.md
PR 21211 docs/user/USAGE.md
PR 21420 docs/user/USAGE.md
PR 21678 docs/user/USAGE.md
PR 21877 core/relinker/CMakeLists.txt
core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp
core/relinker/relinker/src/guest/GuestModuleBuilder.cpp
PR 22434 docs/user/USAGE.md
PR 22466 core/relinker/CMakeLists.txt
PR 22546 docs/user/USAGE.md
PR 22647 docs/user/USAGE.md
PR 22995 docs/user/USAGE.md
PR 23420 core/relinker/CMakeLists.txt
PR 23636 core/relinker/CMakeLists.txt
docs/user/USAGE.md
PR 23747 core/relinker/CMakeLists.txt
PR 23781 core/relinker/CMakeLists.txt
docs/user/USAGE.md
PR 23842 core/relinker/CMakeLists.txt
docs/user/USAGE.md
PR 23975 docs/user/USAGE.md
PR 24062 core/relinker/CMakeLists.txt
PR 24090 docs/user/USAGE.md
PR 24152 core/relinker/relinker/src/guest/GuestModuleBuilder.cpp
PR 24277 docs/user/USAGE.md
PR 24472 core/relinker/CMakeLists.txt
docs/user/USAGE.md
PR 24658 core/relinker/cli/tests/CliArgsTests.cpp
PR 24722 docs/user/USAGE.md
PR 24756 docs/user/USAGE.md
PR 24915 core/relinker/CMakeLists.txt
core/relinker/cli/src/CliArgs.cpp
core/relinker/cli/tests/CliArgsTests.cpp
core/relinker/elfpatcher/include/elfpatcher/windows/WindowsElfPatcher.hpp
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
core/relinker/relinker/include/relinker/guest/GuestImage.hpp
core/relinker/relinker/src/guest/GuestModuleBuilder.cpp
core/relinker/relinker/src/pipeline/Conversion.cpp
docs/user/USAGE.md
PR 24967 core/relinker/cli/src/CliArgs.cpp
core/relinker/relinker/src/pipeline/Conversion.cpp
docs/user/USAGE.md
PR 25435 docs/dev/debt/relinker.md
PR 25483 core/relinker/CMakeLists.txt
docs/user/USAGE.md
PR 25605 core/relinker/main.cpp
PR 25633 core/relinker/main.cpp
PR 25672 core/relinker/CMakeLists.txt
PR 26232 core/relinker/CMakeLists.txt
core/relinker/relinker/src/pipeline/Conversion.cpp
PR 26606 docs/user/USAGE.md
PR 26611 docs/user/USAGE.md
PR 26633 core/relinker/CMakeLists.txt
PR 27011 core/relinker/cli/include/Cli.hpp
core/relinker/cli/src/CliArgs.cpp
core/relinker/cli/tests/CliArgsTests.cpp
core/relinker/main.cpp
docs/user/USAGE.md
PR 27133 docs/user/USAGE.md
PR 27255 core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp
PR 27274 core/relinker/relinker/src/pipeline/Conversion.cpp
PR 27374 core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
PR 27454 docs/user/USAGE.md
PR 27684 docs/user/USAGE.md
PR 27741 core/relinker/relinker/src/guest/GuestModuleBuilder.cpp

@MarcZX10 MarcZX10 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.

Reviewed — looks good

Nothing blocks this change; I reviewed all changed files, and the inspected code supports the documented behavior.

What I ran

  • Read the complete review diff and all 18 changed files at head 8a5e0a362f1bc5cb2edc3113d72fbe7f7cc350ca.
  • No commands were run; the review interface is read-only.

Results

Check Result Note
Changed files read passed 18 of 18
Automated checks not run No shell access
Platform execution not run Native Windows and macOS behavior unconfirmed

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • Automated build and test results were not independently verified. The PR description reports Linux x86-64 test results; Windows execution cases run only on Windows, and Linux/macOS outputs are checked for dependency lists rather than executed.
  • Trackmania conversion and physical-console behavior were not verified.
  • Read: core/relinker/CMakeLists.txt, core/relinker/cli/include/Cli.hpp, core/relinker/cli/src/CliArgs.cpp, core/relinker/cli/tests/CliArgsTests.cpp, core/relinker/elfpatcher/include/elfpatcher/windows/WindowsElfPatcher.hpp, core/relinker/elfpatcher/include/elfpatcher/windows/WindowsEntryStubBuilder.hpp, core/relinker/elfpatcher/include/elfpatcher/windows/WindowsExportBuilder.hpp, core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp, core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp, core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp, core/relinker/main.cpp, core/relinker/relinker/include/relinker/guest/GuestImage.hpp, core/relinker/relinker/include/relinker/pipeline/Conversion.hpp, core/relinker/relinker/src/guest/GuestModuleBuilder.cpp, core/relinker/relinker/src/pipeline/Conversion.cpp, core/relinker/relinker/tests/test_executable_module_imports.py, docs/dev/debt/relinker.md, and docs/user/USAGE.md.
  • Excluded changed files: none.

To get this to a good state

Nothing is required. Optional: run the described tests on the pinned head and exercise the native Windows startup cases on Windows.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

This passed review on 8a5e0a3, but it now conflicts with main in CliArgs.cpp, WindowsEntryStubBuilder.cpp, GuestImage.hpp and 2 more. Please merge main into the branch and push; it goes back to the merge queue on the new head.

@simnJS simnJS closed this Nov 27, 2026
@simnJS
simnJS deleted the fix/needed-module-on-executable branch November 27, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs needs rebase Conflicts with main, rebase needed relinker unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.