mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 11:00:19 +02:00
FEXInterpreter: Override glibc set program invocation name
Mesa uses this to determine what the executable name is in a process for application profiles. Without thunking, the guest glibc sets this correctly, with thunking mesa would pick up `FEX` instead of the app. With this fixed, it fixes Dead Island rendering when thunks are enabled. Plenty of other games in Mesa's application profiles that it would fix as well.
This commit is contained in:
2 files changed
+27
-1
No files matched your search
@@ -226,6 +226,16 @@ else()
|
||||
add_definitions("-DFEX_PRESERVE_ALL_ATTR=" "-DFEX_HAS_PRESERVE_ALL_ATTR=0")
|
||||
endif()
|
||||
|
||||
check_cxx_source_compiles(
|
||||
"
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
int main() {
|
||||
return program_invocation_name == nullptr;
|
||||
}"
|
||||
HAS_PROGRAM_INVOCATION_NAME)
|
||||
add_definitions("-DHAS_PROGRAM_INVOCATION_NAME=${HAS_PROGRAM_INVOCATION_NAME}")
|
||||
|
||||
if (ENABLE_VIXL_SIMULATOR)
|
||||
# We can run the simulator on both x86-64 or AArch64 hosts
|
||||
add_definitions(-DVIXL_SIMULATOR=1 -DVIXL_INCLUDE_SIMULATOR_AARCH64=1)
|
||||
|
||||
@@ -886,7 +886,8 @@ public:
|
||||
|
||||
// Setup ExecFN aux
|
||||
AuxExecFN->val = StackPointer + ExecFNLocation;
|
||||
strncpy(reinterpret_cast<char*>(AuxExecFN->val), ApplicationArgs[0].c_str(), ApplicationArgs[0].size() + 1);
|
||||
const auto InvocationName = reinterpret_cast<char*>(AuxExecFN->val);
|
||||
strncpy(InvocationName, ApplicationArgs[0].c_str(), ApplicationArgs[0].size() + 1);
|
||||
|
||||
// Stack setup
|
||||
// [0, 8): Argument Count
|
||||
@@ -911,6 +912,21 @@ public:
|
||||
}
|
||||
|
||||
RemapArgumentData(StackPointer + ArgumentOffset, ArgumentBackingSize);
|
||||
#if defined(HAS_PROGRAM_INVOCATION_NAME) && HAS_PROGRAM_INVOCATION_NAME
|
||||
// Set the glibc invocation names to the process name.
|
||||
// Mesa uses this to determine application profiles.
|
||||
// Necessary when thunking is enabled otherwise mesa would only see FEX.
|
||||
|
||||
std::string_view INV = std::string_view(InvocationName, ApplicationArgs[0].size());
|
||||
auto short_name = InvocationName;
|
||||
auto iter = INV.rfind('/');
|
||||
if (iter != INV.npos) {
|
||||
short_name = &InvocationName[iter + 1];
|
||||
}
|
||||
|
||||
program_invocation_name = InvocationName;
|
||||
program_invocation_short_name = short_name;
|
||||
#endif
|
||||
}
|
||||
|
||||
fextl::vector<const char*> GetExecveArguments() const override {
|
||||
|
||||
Reference in new issue
Block a user