Small fixes for better cross-platform compatibility (#200)
* Add ifdef check before the Microsoft-specific movsq in memory.cc * Added ifdef before Microsoft-specific movsq and replaced with memcpy in other cases. In memory.cc * Update image_sha_bytes_ from 16 to 20 xex_module.h The value 16 is less than the expected value 20, causing a buffer overflow during sha1 finalization. * Update image_sha_bytes_ loop from 16 to 20 iterations xex_module.cc * Update mapped_memory_posix.cc: Must resize file to map_length. * Should not map nullptr with MAP_FIXED flag. Update memory_posix.cc.
This commit is contained in:
@@ -85,6 +85,12 @@ void* AllocFixed(void* base_address, size_t length,
|
||||
AllocationType allocation_type, PageAccess access) {
|
||||
// mmap does not support reserve / commit, so ignore allocation_type.
|
||||
uint32_t prot = ToPosixProtectFlags(access);
|
||||
int flags = 0;
|
||||
if (base_address != nullptr) {
|
||||
flags = MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS;
|
||||
} else {
|
||||
flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||
}
|
||||
void* result = mmap(base_address, length, prot,
|
||||
MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
|
||||
if (result == MAP_FAILED) {
|
||||
|
||||
Reference in New Issue
Block a user