Commit 71d9f327 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Allocate the ARM64EC code map when the first ARM64X binary is loaded.

parent 30040cc9
......@@ -1869,7 +1869,6 @@ static void init_peb( RTL_USER_PROCESS_PARAMETERS *params, void *module )
break;
case IMAGE_FILE_MACHINE_AMD64:
if (main_image_info.Machine == current_machine) break;
peb->EcCodeBitMap = virtual_alloc_arm64ec_map();
ERR( "starting %s in experimental ARM64EC mode\n", debugstr_us(&params->ImagePathName) );
break;
}
......
......@@ -233,7 +233,6 @@ extern void virtual_free_teb( TEB *teb ) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_clear_tls_index( ULONG index ) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, ULONG_PTR limit, SIZE_T reserve_size,
SIZE_T commit_size, BOOL guard_page ) DECLSPEC_HIDDEN;
extern void *virtual_alloc_arm64ec_map(void) DECLSPEC_HIDDEN;
extern void virtual_map_user_shared_data(void) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack ) DECLSPEC_HIDDEN;
extern unsigned int virtual_locked_server_call( void *req_ptr ) DECLSPEC_HIDDEN;
......
......@@ -2384,6 +2384,23 @@ static NTSTATUS map_pe_header( void *ptr, size_t size, int fd, BOOL *removable )
#ifdef __aarch64__
/***********************************************************************
* alloc_arm64ec_map
*/
static void alloc_arm64ec_map(void)
{
SIZE_T size = ((ULONG_PTR)user_space_limit + page_size) >> (page_shift + 3); /* one bit per page */
unsigned int status = NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&arm64ec_map, 0, &size,
MEM_COMMIT, PAGE_READWRITE );
if (status)
{
ERR( "failed to allocate ARM64EC map: %08x\n", status );
exit(1);
}
peb->EcCodeBitMap = arm64ec_map;
}
/***********************************************************************
* apply_arm64x_relocations
*/
static void apply_arm64x_relocations( char *base, const IMAGE_BASE_RELOCATION *reloc, size_t size )
......@@ -2449,8 +2466,9 @@ static void update_arm64x_mapping( char *base, IMAGE_NT_HEADERS *nt, IMAGE_SECTI
if (size <= offsetof( IMAGE_LOAD_CONFIG_DIRECTORY, CHPEMetadataPointer )) return;
if (!cfg->CHPEMetadataPointer) return;
if (!arm64ec_map) alloc_arm64ec_map();
metadata = (void *)(base + (cfg->CHPEMetadataPointer - nt->OptionalHeader.ImageBase));
if (metadata->CodeMap && arm64ec_map)
if (metadata->CodeMap)
{
const IMAGE_CHPE_RANGE_ENTRY *map = (void *)(base + metadata->CodeMap);
......@@ -3524,25 +3542,6 @@ done:
/***********************************************************************
* virtual_alloc_arm64ec_map
*/
void *virtual_alloc_arm64ec_map(void)
{
#ifdef __aarch64__
SIZE_T size = ((ULONG_PTR)user_space_limit + page_size) >> (page_shift + 3); /* one bit per page */
unsigned int status = NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&arm64ec_map, 0, &size,
MEM_COMMIT, PAGE_READWRITE );
if (status)
{
ERR( "failed to allocate ARM64EC map: %08x\n", status );
exit(1);
}
#endif
return arm64ec_map;
}
/***********************************************************************
* virtual_map_user_shared_data
*/
void virtual_map_user_shared_data(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment