EXEのスタックサイズの確認方法
>dumpbin /HEADERS CheckStack.exe Microsoft (R) COFF/PE Dumper Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file CheckStack.exe PE signature found File Type: EXECUTABLE IMAGE FILE HEADER VALUES 14C machine (x86) 7 number of sections 503F15D6 time date stamp Thu Aug 30 16:27:18 2012 0 file pointer to symbol table 0 number of symbols E0 size of optional header 102 characteristics Executable 32 bit word machine OPTIONAL HEADER VALUES 10B magic # (PE32) 9.00 linker version 3600 size of code 4200 size of initialized data 0 size of uninitialized data 11078 entry point (00411078) @ILT+115(_wmainCRTStartup) 1000 base of code 1000 base of data 400000 image base (00400000 to 0041AFFF) 1000 section alignment 200 file alignment 5.00 operating system version 0.00 image version 5.00 subsystem version 0 Win32 version 1B000 size of image 400 size of headers 0 checksum 3 subsystem (Windows CUI) 8140 DLL characteristics Dynamic base NX compatible Terminal Server Aware 10 size of stack reserve <=16をセットした。(4で割り切れる値になる) 8 size of stack commit <=8をセットした。(4で割り切れる値になる) 100000 size of heap reserve 1000 size of heap commit 0 loader flags 10 number of directories
/STACK 16:8の設定をした場合、
16が最大と想定した。
しかし、以下のプログラムを実行すると184まで進む。
つまり、約184KBでStackOverFlowになる。
なにかおかしい。
void test(int count) { unsigned char a[1000]; const int size = 1000; int i; for(i = 0; i < size; i++) { a[i] = i; } printf("Count=%d\n",count); test(count+1); } int _tmain(int argc, _TCHAR* argv[]) { test(0); return 0; }