dotnet/runtime · error
Invalid Image Base specified for 32-bit target
Error message
Invalid Image Base specified for 32-bit target
What it means
When producing a PE32 (32-bit) image, ilasm checks (main.cpp:586) that the requested image base does not exceed 0x80000000 (2GB). A higher base is unreachable in a 32-bit address space, so ilasm deletes the assembler and exits. The base comes from `/BAS=`; this is separate from the alignment check (226).
Source
Thrown at src/coreclr/ilasm/main.cpp:588
{
if((pAsm->m_dwCeeFileFlags & ICEE_CREATE_MACHINE_ARM64)
||(pAsm->m_dwCeeFileFlags & ICEE_CREATE_MACHINE_AMD64))
{
printf("\n64 bit target must be specified for machine type /ARM64 or /X64.");
if(!pAsm->OnErrGo)
{
pAsm->m_dwCeeFileFlags &= ~ICEE_CREATE_FILE_PE32;
pAsm->m_dwCeeFileFlags |= ICEE_CREATE_FILE_PE64;
printf(" Target set to 64 bit.");
}
printf("\n");
}
}
if(pAsm->m_dwCeeFileFlags & ICEE_CREATE_FILE_PE32)
{
if(g_stBaseAddress > 0x80000000)
{
fprintf(stderr,"Invalid Image Base specified for 32-bit target\n");
delete pAsm;
goto ErrorExit;
}
}
if (COR_IS_32BIT_PREFERRED(pAsm->m_dwComImageFlags) &&
((pAsm->m_dwCeeFileFlags & ICEE_CREATE_FILE_PE64) ||
((pAsm->m_dwCeeFileFlags & ICEE_CREATE_FILE_PE32) == 0) ||
((pAsm->m_dwCeeFileFlags & ICEE_CREATE_MACHINE_I386) == 0) ||
((pAsm->m_dwComImageFlags & COMIMAGE_FLAGS_ILONLY) == 0)))
{
fprintf(stderr,"/32BITPREFERRED valid only with PE32/X86/ILONLY images\n");
delete pAsm;
goto ErrorExit;
}
if (!pAsm->Init(bGeneratePdb))
{
fprintf(stderr,"Failed to initialize Assembler\n");
delete pAsm;View on GitHub (pinned to 290d5ab72c)
Solutions
- Lower the base address to <= 0x80000000 for PE32/X86 targets.
- Switch to a 64-bit target (`/X64` or `/ARM64` with PE64) if a high base is required.
Example fix
// before ilasm /X86 /BAS=0x100000000 foo.il // after ilasm /X86 /BAS=0x400000 foo.il
Defensive patterns
Strategy: validation
Validate before calling
// For PE32/X86, cap base at 0x80000000.
const isPe32 = flags.has('X86') || flags.has('PE32');
if (isPe32 && baseAddr > 0x80000000) throw new Error('Base 0x'+baseAddr.toString(16)+' invalid for 32-bit target'); Prevention
- Use a low base (e.g. 0x400000) for 32-bit images.
- Switch to /X64//ARM64 if a high base is truly needed.
- Validate base against the target bitness in build scripts.
When it happens
Trigger: Combining a PE32/X86 target with `/BAS=` greater than 0x80000000 (e.g. `/BAS=0x100000000 /X86`).
Common situations: Reusing a 64-bit base address from another project on a 32-bit build; default assumptions about ASLR ranges.
Related errors
- Base address must be 0x10000-aligned
- File Alignment must be power of 2 from 0x200 to 0x10000
- Error: Output file name exceeds %d characters
- Error : Invalid Option: %s
- event.eventName is a required parameter, in event: ${JSON.st
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/347e6c7d361b3610.
Report an issue: GitHub.