Files
DroidDeck/tools/fex/patches/0014-guest-preload-drops-host-libraries.patch
T
MaxsTechReview 78f942313d fix(fex): x86 programs no longer see the host's arm64 preload libraries (#3098)
* fix(fex): x86 programs no longer see the host's arm64 preload libraries

* test(fex): build the x86 preload fixtures with an x86-64 compiler
2026-11-23 20:02:08 -05:00

52 lines
1.7 KiB
Diff

diff --git a/Source/Tools/FEXInterpreter/ELFCodeLoader.h b/Source/Tools/FEXInterpreter/ELFCodeLoader.h
index e1f601b..cebf1f5 100644
--- a/Source/Tools/FEXInterpreter/ELFCodeLoader.h
+++ b/Source/Tools/FEXInterpreter/ELFCodeLoader.h
@@ -222,6 +222,32 @@ class ELFCodeLoader final : public FEX::CodeLoader {
public:
+ static fextl::string GuestPreload(const char* List, const fextl::string& RootFS) {
+ fextl::string Result;
+ for (const char* Start = List; *Start; Start += *Start ? 1 : 0) {
+ size_t Length = strcspn(Start, ": ");
+ fextl::string Entry(Start, Length);
+ Start += Length;
+ if (Entry.empty()) {
+ continue;
+ }
+ if (Entry[0] == '/') {
+ auto Type = ::ELFLoader::ELFContainer::GetELFType(ResolveRootfsFile(Entry, RootFS));
+ if (Type == ::ELFLoader::ELFContainer::TYPE_NONE) {
+ Type = ::ELFLoader::ELFContainer::GetELFType(Entry);
+ }
+ if (Type == ::ELFLoader::ELFContainer::TYPE_OTHER_ELF) {
+ continue;
+ }
+ }
+ if (!Result.empty()) {
+ Result += ':';
+ }
+ Result += Entry;
+ }
+ return Result;
+ }
+
static fextl::string ResolveRootfsFile(const fextl::string& File, fextl::string RootFS) {
// If the path is relative then just run that
if (File[0] != '/') {
@@ -330,6 +356,13 @@ public:
if (envp[i] == nullptr) {
break;
}
+ if (strncmp(envp[i], "LD_PRELOAD=", 11) == 0) {
+ auto Preload = GuestPreload(envp[i] + 11, RootFS);
+ if (!Preload.empty()) {
+ EnvironmentVariables.emplace_back("LD_PRELOAD=" + Preload);
+ }
+ continue;
+ }
EnvironmentVariables.emplace_back(envp[i]);
}
}