{"record":{"id":"347e6c7d361b3610","repo":"dotnet/runtime","slug":"invalid-image-base-specified-for-32-bit-target","errorCode":null,"errorMessage":"Invalid Image Base specified for 32-bit target\n","messagePattern":"Invalid Image Base specified for 32-bit target\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/ilasm/main.cpp","lineNumber":588,"sourceCode":"            {\n                if((pAsm->m_dwCeeFileFlags & ICEE_CREATE_MACHINE_ARM64)\n                  ||(pAsm->m_dwCeeFileFlags & ICEE_CREATE_MACHINE_AMD64))\n                {\n                    printf(\"\\n64 bit target must be specified for machine type /ARM64 or /X64.\");\n                    if(!pAsm->OnErrGo)\n                    {\n                        pAsm->m_dwCeeFileFlags &= ~ICEE_CREATE_FILE_PE32;\n                        pAsm->m_dwCeeFileFlags |= ICEE_CREATE_FILE_PE64;\n                        printf(\" Target set to 64 bit.\");\n                    }\n                    printf(\"\\n\");\n                }\n            }\n            if(pAsm->m_dwCeeFileFlags & ICEE_CREATE_FILE_PE32)\n            {\n                if(g_stBaseAddress > 0x80000000)\n                {\n                    fprintf(stderr,\"Invalid Image Base specified for 32-bit target\\n\");\n                    delete pAsm;\n                    goto ErrorExit;\n                }\n            }\n            if (COR_IS_32BIT_PREFERRED(pAsm->m_dwComImageFlags) &&\n                ((pAsm->m_dwCeeFileFlags & ICEE_CREATE_FILE_PE64) ||\n                 ((pAsm->m_dwCeeFileFlags & ICEE_CREATE_FILE_PE32) == 0) ||\n                 ((pAsm->m_dwCeeFileFlags & ICEE_CREATE_MACHINE_I386) == 0) ||\n                 ((pAsm->m_dwComImageFlags & COMIMAGE_FLAGS_ILONLY) == 0)))\n            {\n                fprintf(stderr,\"/32BITPREFERRED valid only with PE32/X86/ILONLY images\\n\");\n                delete pAsm;\n                goto ErrorExit;\n            }\n            if (!pAsm->Init(bGeneratePdb))\n            {\n                fprintf(stderr,\"Failed to initialize Assembler\\n\");\n                delete pAsm;","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/ilasm/main.cpp#L570-L606","documentation":"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).","triggerScenarios":"Combining a PE32/X86 target with `/BAS=` greater than 0x80000000 (e.g. `/BAS=0x100000000 /X86`).","commonSituations":"Reusing a 64-bit base address from another project on a 32-bit build; default assumptions about ASLR ranges.","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."],"exampleFix":"// before\nilasm /X86 /BAS=0x100000000 foo.il\n// after\nilasm /X86 /BAS=0x400000 foo.il","handlingStrategy":"validation","validationCode":"// For PE32/X86, cap base at 0x80000000.\nconst isPe32 = flags.has('X86') || flags.has('PE32');\nif (isPe32 && baseAddr > 0x80000000) throw new Error('Base 0x'+baseAddr.toString(16)+' invalid for 32-bit target');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["ilasm","cli","pe32","base-address","validation"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}