mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 07:00:20 +02:00
Merge pull request #5941 from Plagman/plagman/relaxrelocfilter_mr
DiskCache: allow relocations within the same ELF image
This commit is contained in:
3 files changed
+22
No files matched your search
@@ -825,6 +825,11 @@ namespace DiskCache {
|
||||
if (Target >= Region->BeginVA && Target < Region->EndVA) {
|
||||
continue;
|
||||
}
|
||||
// let it through if it's inside the same ELF image? (like bss)
|
||||
if (Region->FileInfo.MappedSize && Target >= Region->FileStartVA && Target < Region->FileStartVA + Region->FileInfo.MappedSize) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto TargetSection = CTX->SyscallHandler->LookupExecutableFileSection(Thread, Target);
|
||||
if (!TargetSection || TargetSection->FileInfo.FileId != Region->FileInfo.FileId) {
|
||||
// we don't know where it's pointing, so we don't know how to encode the offset, so we can't cache atm
|
||||
|
||||
@@ -51,6 +51,7 @@ struct ExecutableFileInfo {
|
||||
uint64_t FileId = 0;
|
||||
fextl::string Filename;
|
||||
fextl::robin_map<uint32_t, GuestRelocationType> Relocations;
|
||||
uint64_t MappedSize = 0;
|
||||
};
|
||||
|
||||
// Information associated with a specific section of an executable file
|
||||
|
||||
@@ -636,6 +636,22 @@ SyscallHandler::TrackMmap(FEXCore::Core::InternalThreadState* Thread, uint64_t a
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t MinAddress = 0;
|
||||
uint64_t MaxAddress = 0;
|
||||
for (auto& ProgramHeader : Resource->ProgramHeaders) {
|
||||
if (ProgramHeader.p_type == PT_LOAD) {
|
||||
if (!MinAddress && !MaxAddress) {
|
||||
MinAddress = ProgramHeader.p_vaddr;
|
||||
MaxAddress = ProgramHeader.p_vaddr + ProgramHeader.p_memsz;
|
||||
}
|
||||
MinAddress = std::min(MinAddress, ProgramHeader.p_vaddr);
|
||||
MaxAddress = std::max(MaxAddress, ProgramHeader.p_vaddr + ProgramHeader.p_memsz);
|
||||
}
|
||||
}
|
||||
if (MaxAddress > MinAddress) {
|
||||
Resource->MappedFile->MappedSize = MaxAddress - MinAddress;
|
||||
}
|
||||
|
||||
LOGMAN_THROW_A_FMT(Resource->ProgramHeaders.empty() || offset == 0, "Expected file offset 0 for the first mapping of an ELF "
|
||||
"file");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user