From f40acdb2c625f16472cf013283822478581a728e Mon Sep 17 00:00:00 2001 From: thuanquang <60096168+thuanquang@users.noreply.github.com> Date: Mon, 12 Oct 2026 23:19:00 +0700 Subject: [PATCH] fix(relinker): list converted modules correctly for a relative output path The runtime layout printed ../app0/sce_module/... under app0/ when the output path contained . or .. components (./out.elf), because the module paths are normal and the output directory was not. Co-Authored-By: Claude Opus 5.5 --- core/relinker/main.cpp | 2 +- core/relinker/relinker/tests/test_guest_needed_modules.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/relinker/main.cpp b/core/relinker/main.cpp index 6d486d6112..b7938752fe 100644 --- a/core/relinker/main.cpp +++ b/core/relinker/main.cpp @@ -346,7 +346,7 @@ int Run(const int argc, char* argv[]) { } std::vector modulePaths; for (const auto& artifact : guestArtifacts) { - std::string relative = Io::Utf8Path(artifact.Path.lexically_relative(Io::NativePath(absPath).parent_path() / "app0")); + std::string relative = Io::Utf8Path(artifact.Path.lexically_relative(Io::NativePath(absPath).parent_path().lexically_normal() / "app0")); std::replace(relative.begin(), relative.end(), '\\', '/'); modulePaths.push_back(std::move(relative)); } diff --git a/core/relinker/relinker/tests/test_guest_needed_modules.py b/core/relinker/relinker/tests/test_guest_needed_modules.py index 5440ee396f..6b2b18f2c8 100644 --- a/core/relinker/relinker/tests/test_guest_needed_modules.py +++ b/core/relinker/relinker/tests/test_guest_needed_modules.py @@ -114,7 +114,12 @@ def main(): artifact = case / "app0" / "sce_module" / "needed.prx.guest.prx" assert artifact.read_bytes().startswith(b"MZ" if windows else b"\x7fELF"), artifact assert list((case / "app0").rglob("*.guest.prx")) == [artifact] - assert " |-- sce_module/\n |-- needed.prx.guest.prx\n" in result.stdout, result.stdout + layout = " |-- sce_module/\n |-- needed.prx.guest.prx\n" + assert layout in result.stdout, result.stdout + for spelling in (os.path.join(".", output.name), os.path.join("..", case.name, output.name)): + relative = subprocess.run([str(relinker), *(["--windows"] if windows else []), "input.elf", spelling], cwd=case, + capture_output=True, text=True, timeout=30) + assert relative.returncode == 0 and layout in relative.stdout, (spelling, relative.stdout, relative.stderr) if windows and os.name == "nt": run = subprocess.run([str(output)], capture_output=True, text=True, timeout=30) assert run.returncode == 42, (run.returncode, run.stdout, run.stderr)