{"record":{"id":"4163a724ce3ed442","repo":"dotnet/runtime","slug":"base-address-must-be-0x10000-aligned","errorCode":null,"errorMessage":"\nBase address must be 0x10000-aligned\n","messagePattern":"\nBase address must be 0x10000-aligned\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/ilasm/main.cpp","lineNumber":495,"sourceCode":"                    {\n                        WCHAR *pStr = EqualOrColon(argv[i]);\n                        if(pStr == NULL) goto InvalidOption;\n                        pStr++;\n                        const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? \"%x\" : \"%d\";\n                        NarrowForNumberParsing str{pStr};\n                        if(sscanf_s(str,pFmt,&g_dwComImageFlags)!=1) goto InvalidOption;\n                    }\n                    else if (!_stricmp(szOpt, \"BAS\"))\n                    {\n                        WCHAR *pStr = EqualOrColon(argv[i]);\n                        if(pStr == NULL) goto InvalidOption;\n                        pStr++;\n                        const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? \"%llx\" : \"%lld\";\n                        NarrowForNumberParsing str{pStr};\n                        if(sscanf_s(str,pFmt,&g_stBaseAddress)!=1) goto InvalidOption;\n                        if(g_stBaseAddress & 0xFFFF)\n                        {\n                            fprintf(stderr,\"\\nBase address must be 0x10000-aligned\\n\");\n                            if(!pAsm->OnErrGo) goto InvalidOption;\n                        }\n                    }\n                    else if (!_stricmp(szOpt, \"STA\"))\n                    {\n                        WCHAR *pStr = EqualOrColon(argv[i]);\n                        if(pStr == NULL) goto InvalidOption;\n                        pStr++;\n                        const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? \"%x\" : \"%d\";\n                        NarrowForNumberParsing str{pStr};\n                        if(sscanf_s(str,pFmt,&g_stSizeOfStackReserve)!=1) goto InvalidOption;\n                    }\n#ifdef _SPECIAL_INTERNAL_USE_ONLY\n                    else if (!_stricmp(szOpt, \"TES\"))\n                    {\n                        WCHAR *pStr = EqualOrColon(argv[i]);\n                        if(pStr == NULL) goto InvalidOption;\n                        pStr++;","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/ilasm/main.cpp#L477-L513","documentation":"The `/BAS=<addr>` (image base) switch (main.cpp:492) parses a 64-bit value and then checks `g_stBaseAddress & 0xFFFF`; if any of the low 16 bits are set the address is not 64KiB-aligned and ilasm prints this, going to InvalidOption unless OnErrGo is set. PE image bases must fall on a 64KiB boundary.","triggerScenarios":"Passing `/BAS=` with an address whose low 16 bits are nonzero (e.g. `/BAS=0x401000`).","commonSituations":"Mistakenly using a 4KiB-aligned address from an ELF context; copy-pasting a hint address that isn't 64KiB-aligned.","solutions":["Round the base address up to the next 0x10000 multiple (e.g. `/BAS=0x400000`).","Omit `/BAS` to let the linker pick a valid default base."],"exampleFix":"// before\nilasm /BAS=0x401000 foo.il\n// after\nilasm /BAS=0x400000 foo.il","handlingStrategy":"validation","validationCode":"// Validate /BAS 0x10000-alignment before invoking ilasm.\nfunction validBase(addr) { return (addr & 0xFFFF) === 0; }\nif (!validBase(baseAddr)) throw new Error('Base address not 64KiB-aligned: 0x' + baseAddr.toString(16));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Round image bases up to 0x10000 multiples.","Omit /BAS unless a fixed base is required.","Remember PE uses 64KiB alignment, not ELF's 4KiB."],"tags":["ilasm","cli","pe","base-address","validation"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}