fix(relinker): default module path to input elf directory

This commit is contained in:
boykopovar 2026-10-10 14:12:04 +03:00
parent bec6d62b29
commit 336d481bff
4 changed files with 13 additions and 5 deletions

View File

@ -22,7 +22,7 @@ struct Args {
std::uint32_t unusedFilterLevel = 0;
std::string inputPath;
std::string outputPath;
std::string sceModulePath = ".";
std::string sceModulePath;
std::string runPath = "$ORIGIN/libs";
std::set<std::string> excludedSceModules;
};

View File

@ -1,4 +1,5 @@
#include <Cli.hpp>
#include <filesystem>
#include <iostream>
#include <stdexcept>
#include <string>
@ -86,6 +87,8 @@ Args ParseArgs(int argc, char* argv[]) {
throw std::runtime_error(Usage());
if (!sceModulePathSpecified && !args.skipSceModule && !args.inputPath.empty()) args.sceModulePath = std::filesystem::absolute(args.inputPath).parent_path().string();
return args;
}

View File

@ -34,7 +34,12 @@ def main():
run("absolute", ["--sce-module-path", str(parent)], artifact=True)
run("relative", ["--sce-module-path", "module root"], artifact=True)
run("default", [], cwd=parent, artifact=True)
inputModules = source.parent / "sce_module"
inputModules.mkdir()
(inputModules / "needed.prx").write_bytes(guest_fixture(PLAIN_SITE))
run("default", [], artifact=True)
(inputModules / "needed.prx").unlink()
inputModules.rmdir()
run("explicit-dot", ["--sce-module-path", "."], cwd=parent, artifact=True)
run("skip", ["--skip-sce-module"])
run("conflict", ["--sce-module-path", str(parent), "--skip-sce-module"], error="conflicts with --skip-sce-module")
@ -46,7 +51,7 @@ def main():
run("missing-parent", ["--sce-module-path", "absent"], error="parent directory does not exist")
run("file-parent", ["--sce-module-path", str(source)], error="parent path is not a directory")
run("wrong-level", ["--sce-module-path", str(modules)], error="--skip-sce-module")
run("module-directory-is-file", [], error="Guest module path is not a directory")
run("module-directory-is-file", ["--sce-module-path", "."], error="Guest module path is not a directory")
(parent / "sce_modules").mkdir()
run("ambiguous", ["--sce-module-path", str(parent)], error="Both sce_module and sce_modules")
(parent / "sce_modules").rmdir()

View File

@ -2,7 +2,7 @@
## Input and conversion
Use a clean ELF executable. Place its bundled ELF modules in `sce_module/`, `sce_modules/`, or `prx/` under the current working directory, or under the parent directory selected with `--sce-module-path <path>`. The option accepts absolute paths and paths relative to the current working directory; do not include the `sce_module` directory itself. Only files directly inside the module directories are processed. A bundled module in a SELF container is an error, as the executable is. `prx/` can coexist with either `sce_module/` or `sce_modules/`. Both `sce_module/` and `sce_modules/` present, or all three absent, is an error.
Use a clean ELF executable. Place its bundled ELF modules in `sce_module/`, `sce_modules/`, or `prx/` beside the input executable, or under the parent directory selected with `--sce-module-path <path>`. The option accepts absolute paths and paths relative to the current working directory; do not include the `sce_module` directory itself. Only files directly inside the module directories are processed. A bundled module in a SELF container is an error, as the executable is. `prx/` can coexist with either `sce_module/` or `sce_modules/`. Both `sce_module/` and `sce_modules/` present, or all three absent, is an error.
```text
source/
@ -54,7 +54,7 @@ All switches are disabled by default. `unused-filter` defaults to `0`; `--rpath`
| `--registry` | Write `<output-stem>.registry.json` beside the output executable, and `<output-stem>.<module>.registry.json` for each converted bundled module. |
| `--rpath <path>` | Set the system library search path. Quote `$ORIGIN` to prevent shell expansion, for example `--rpath '$ORIGIN/libs'` in Bash or PowerShell. Linux guest modules require an absolute path or a path beginning with `$ORIGIN`. Windows requires a nonempty ASCII path and supports `$ORIGIN` as the executable directory. |
| `--autorun` | Run the output after conversion, print its exit code, and wait for Enter. Adds executable permissions for Linux output. Requires the target OS and prepared runtime layout. |
| `--sce-module-path <path>` | Set the parent directory of bundled module directories (default: current working directory). Conflicts with `--skip-sce-module`. |
| `--sce-module-path <path>` | Set the parent directory of bundled module directories (default: the input ELF parent directory). Conflicts with `--skip-sce-module`. |
| `--skip-sce-module` | Deprecated. Skip all bundled module processing. |
| `--exclude-sce-module <file>` | Deprecated. Exclude a bundled module by exact filename, not path. Repeat for multiple files; a missing filename is an error. Conflicts with `--skip-sce-module`. |
| `--skip-syscall-check` | Deprecated. Disable syscall scanning in the executable and bundled modules. |