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

  1. Lower the base address to <= 0x80000000 for PE32/X86 targets.
  2. 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

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


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/347e6c7d361b3610. Report an issue: GitHub.