mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(relinker): accept zero alignment for empty tls segments
This commit is contained in:
@@ -91,7 +91,7 @@ PeDirectory WindowsTlsBuilder::Build(const std::vector<std::uint8_t>& source, co
|
||||
return {};
|
||||
}
|
||||
|
||||
if (tls->FileSize > tls->MemorySize || tls->Offset > source.size() || tls->FileSize > source.size() - tls->Offset || !std::has_single_bit(tls->Alignment) || tls->Alignment > 8192 || tls->MemorySize > 0x7fff0000u)
|
||||
if (tls->FileSize > tls->MemorySize || tls->Offset > source.size() || tls->FileSize > source.size() - tls->Offset || (tls->Alignment > 1 && !std::has_single_bit(tls->Alignment)) || tls->Alignment > 8192 || tls->MemorySize > 0x7fff0000u)
|
||||
throw Domain::RelinkerException("Invalid or unsupported ELF TLS layout", tls->Offset);
|
||||
// Native homebrew linkers can emit an empty PT_TLS placeholder.
|
||||
// It needs no Windows TLS directory unless guest code accesses TLS.
|
||||
|
||||
@@ -54,7 +54,7 @@ GuestImage GuestImageReader::Read(const std::filesystem::path& path, std::vector
|
||||
dynlib = &header;
|
||||
}
|
||||
if (header.Type == 7) {
|
||||
if (tls != nullptr || header.FileSize > header.MemorySize || !std::has_single_bit(header.Alignment)) fail("Invalid TLS segment");
|
||||
if (tls != nullptr || header.FileSize > header.MemorySize || (header.Alignment > 1 && !std::has_single_bit(header.Alignment))) fail("Invalid TLS segment");
|
||||
tls = &header;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user