Files
David 35fe448155 feat(relinker): place macOS executables at a fixed base with --macos-fixed-base
Ruffle (PPSA68091), VLC (PPSA85300) and XPSemu (PPSA97358) read
app0/imports.txt, whose import slot addresses assume the executable's
lowest ELF load page at 0x400000, and dereference them at once. macOS
output always placed that page at 0x140010000, so all three fault on
their first slot read. Linux and Windows have --linux-fixed-base and
--windows-fixed-base for this; macOS had no equivalent.

--macos-fixed-base <address> builds the load image so that the lowest
ELF load page is at the address, as --windows-fixed-base does. The
Mach-O header takes the 64 KiB below it and __PAGEZERO ends there. The
executable is MH_EXECUTE without MH_PIE, so dyld does not slide it. The
address must be 64 KiB aligned, from 0x20000 through 0x7fffffff0000,
and an image ending past the macOS user address space is refused.
2026-10-19 10:32:30 +02:00

53 lines
1.3 KiB
C++

#ifndef CORE_RELINKER_CLI_INCLUDE_CLI_HPP
#define CORE_RELINKER_CLI_INCLUDE_CLI_HPP
#include <set>
#include <string>
#include <vector>
#include <cstdint>
#include <optional>
namespace Cli {
struct Args {
bool showHelp = false;
bool skipSyscallCheck = false;
bool trapSdkSyscallStubs = false;
bool skipSceModule = false;
bool toIntel = false;
bool toRosetta = false;
bool writeRegistry = false;
bool toWindows = false;
bool toMacos = false;
bool lazyBinding = false;
bool autorun = false;
bool windowsDiagnostics = false;
bool windowsGui = false;
std::optional<std::uint64_t> windowsFixedBase;
bool traceImports = false;
std::optional<std::uint64_t> linuxFixedBase;
std::optional<std::uint64_t> macosFixedBase;
std::uint32_t unusedFilterLevel = 0;
std::string inputPath;
std::string outputPath;
std::string sceModulePath;
std::string patchesPath;
bool noPatches = false;
std::string verifyPatchesPath;
bool verifyOutput = false;
std::string runPath = "$ORIGIN/libs";
std::set<std::string> excludedSceModules;
std::vector<std::string> moduleDirectories;
std::vector<std::string> executables;
};
Args ParseArgs(int argc, char* argv[]);
const char* Usage();
int Autorun(const std::string& absPath, bool toWindows);
}
#endif