mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-24 10:00:45 +02:00
Merge pull request #61 from Sonicadvance1/ELFLoader_arg_plumbing
Plumbs ELFLoader arguments through the CodeLoader
This commit is contained in:
commit
628a208db2
9 files changed
+25
-8
No files matched your search
@@ -111,6 +111,9 @@ namespace FEXCore::Context {
|
||||
|
||||
uintptr_t CompileBlock(FEXCore::Core::InternalThreadState *Thread, uint64_t GuestRIP);
|
||||
uintptr_t CompileFallbackBlock(FEXCore::Core::InternalThreadState *Thread, uint64_t GuestRIP);
|
||||
|
||||
FEXCore::CodeLoader *GetCodeLoader() const { return LocalLoader; }
|
||||
|
||||
protected:
|
||||
IR::RegisterAllocationPass *GetRegisterAllocatorPass();
|
||||
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public:
|
||||
virtual uint64_t GetFinalRIP() { return ~0ULL; }
|
||||
|
||||
virtual char const *FindSymbolNameInRange(uint64_t Address) { return nullptr; }
|
||||
|
||||
virtual void GetExecveArguments(std::vector<char const*> *Args) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Vendored
+1
-1
Submodule External/cpp-optparse updated: 5d46ee5bb5...b8c75f118e.
@@ -4,6 +4,7 @@
|
||||
|
||||
namespace FEX::ArgLoader {
|
||||
std::vector<std::string> RemainingArgs;
|
||||
std::vector<std::string> ProgramArguments;
|
||||
|
||||
void Load(int argc, char **argv) {
|
||||
|
||||
@@ -190,12 +191,16 @@ namespace FEX::ArgLoader {
|
||||
const char* Value = Options.get("IPCID");
|
||||
Config::Add("IPCID", Value);
|
||||
}
|
||||
|
||||
}
|
||||
RemainingArgs = Parser.args();
|
||||
ProgramArguments = Parser.parsed_args();
|
||||
}
|
||||
|
||||
std::vector<std::string> Get() {
|
||||
return RemainingArgs;
|
||||
}
|
||||
std::vector<std::string> GetParsedArgs() {
|
||||
return ProgramArguments;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,4 +7,6 @@ namespace FEX::ArgLoader {
|
||||
void Load(int argc, char **argv);
|
||||
|
||||
std::vector<std::string> Get();
|
||||
std::vector<std::string> GetParsedArgs();
|
||||
|
||||
}
|
||||
@@ -70,10 +70,11 @@ int main(int argc, char **argv, char **const envp) {
|
||||
FEX::Config::Value<std::string> LDPath{"RootFS", ""};
|
||||
|
||||
auto Args = FEX::ArgLoader::Get();
|
||||
auto ParsedArgs = FEX::ArgLoader::GetParsedArgs();
|
||||
|
||||
LogMan::Throw::A(!Args.empty(), "Not enough arguments");
|
||||
|
||||
FEX::HarnessHelper::ELFCodeLoader Loader{Args[0], Args, envp};
|
||||
FEX::HarnessHelper::ELFCodeLoader Loader{Args[0], Args, ParsedArgs, envp};
|
||||
|
||||
FEXCore::Context::InitializeStaticTables();
|
||||
auto SHM = FEXCore::SHM::AllocateSHMRegion(1ULL << 32);
|
||||
@@ -81,7 +82,6 @@ int main(int argc, char **argv, char **const envp) {
|
||||
FEXCore::Context::InitializeContext(CTX);
|
||||
FEXCore::Context::SetApplicationFile(CTX, std::filesystem::canonical(Args[0]));
|
||||
|
||||
|
||||
FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_DEFAULTCORE, CoreConfig() > 3 ? FEXCore::Config::CONFIG_CUSTOM : CoreConfig());
|
||||
FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_MULTIBLOCK, MultiblockConfig());
|
||||
FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_ACCURATESTDOUT, AccurateSTDConfig());
|
||||
|
||||
@@ -381,7 +381,7 @@ namespace FEX::HarnessHelper {
|
||||
|
||||
class ELFCodeLoader final : public FEXCore::CodeLoader {
|
||||
public:
|
||||
ELFCodeLoader(std::string const &Filename, [[maybe_unused]] std::vector<std::string> const &args, char **const envp = nullptr)
|
||||
ELFCodeLoader(std::string const &Filename, [[maybe_unused]] std::vector<std::string> const &args, std::vector<std::string> const &ParsedArgs, char **const envp = nullptr)
|
||||
: File {Filename, false}
|
||||
, DB {&File}
|
||||
, Args {args} {
|
||||
@@ -427,6 +427,10 @@ public:
|
||||
//AuxVariables.emplace_back(auxv_t{26, 0}); // AT_HWCAP2
|
||||
AuxVariables.emplace_back(auxv_t{32, 0ULL}); // sysinfo (vDSO)
|
||||
AuxVariables.emplace_back(auxv_t{33, 0ULL}); // sysinfo (vDSO)
|
||||
|
||||
for (auto &Arg : ParsedArgs) {
|
||||
LoaderArgs.emplace_back(Arg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t StackSize() const override {
|
||||
@@ -591,11 +595,14 @@ public:
|
||||
return DB.InitializeThreadSlot(Writer);
|
||||
};
|
||||
|
||||
void GetExecveArguments(std::vector<char const*> *Args) override { *Args = LoaderArgs; }
|
||||
|
||||
private:
|
||||
::ELFLoader::ELFContainer File;
|
||||
::ELFLoader::ELFSymbolDatabase DB;
|
||||
std::vector<std::string> Args;
|
||||
std::vector<std::string> EnvironmentVariables;
|
||||
std::vector<char const*> LoaderArgs;
|
||||
struct auxv_t {
|
||||
uint64_t key;
|
||||
uint64_t val;
|
||||
|
||||
@@ -589,7 +589,7 @@ int main(int argc, char **argv) {
|
||||
FEXCore::Context::AddGuestMemoryRegion(CTX, SHM);
|
||||
|
||||
if (ConfigELFType()) {
|
||||
FEX::HarnessHelper::ELFCodeLoader Loader{File, {}};
|
||||
FEX::HarnessHelper::ELFCodeLoader Loader{File, {},{}};
|
||||
bool Result = FEXCore::Context::InitCore(CTX, &Loader);
|
||||
printf("Did we Load? %s\n", Result ? "Yes" : "No");
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ void CreateCoreCallback(char const *Filename, bool ELF) {
|
||||
|
||||
bool Result{};
|
||||
if (ELF) {
|
||||
FEX::HarnessHelper::ELFCodeLoader Loader{Filename, {}};
|
||||
FEX::HarnessHelper::ELFCodeLoader Loader{Filename, {}, {}};
|
||||
Result = FEXCore::Context::InitCore(CTX, &Loader);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in new issue
Block a user