mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 10:00:16 +02:00
Merge pull request #5392 from neobrain/fix_code_cache_dupfd
LinuxSyscalls: Re-open file descriptors for parsing ELF headers
This commit is contained in:
1 file changed
+5
-1
@@ -219,8 +219,12 @@ static ReadELFHeadersResult ReadELFHeaders(int FD, std::span<std::byte> HeaderDa
|
||||
// Read from FD in case the caller didn't have a mapped header available
|
||||
}
|
||||
|
||||
// Re-open the file with a fresh file descriptor (and let ELFParser close it on return).
|
||||
// NOTE: FDs returned by dup() share the same cursor state, so reading from them would have observable side effects.
|
||||
auto NewFD = open(fextl::fmt::format("/proc/self/fd/{}", FD).c_str(), O_RDONLY);
|
||||
|
||||
ELFParser Parser;
|
||||
Parser.ReadElf(dup(FD));
|
||||
Parser.ReadElf(NewFD);
|
||||
|
||||
auto Relocations = Parser.PopulateRelocations();
|
||||
if (!Relocations.empty()) {
|
||||
|
||||
Reference in new issue
Block a user