The PE32 file structure, in particular the header formats, are set by Microsoft and widely published. There are tools to view and print the contents of the headers. I chose to use Prof. Agner Fog's excellent ObjConv utility ( http://www.agner.org/optimize/#objconv ) to help demystify the issue. You could use the MS DUMPBIN program similarly.
Here is an example program with a substantial stack consumption.
program stkovfl
implicit none
call sub()
end program
subroutine sub()
implicit none
integer, parameter :: N = 70000
integer x(N),i
double precision s
do i=1,N
x(i)=2*i-1
end do
s=0
do i=1,N
s=s+x(i)
end do
write(*,*)s
return
end subroutine
By default, SLINK provides enough stack for this program to run with no special effort but, for illustration, I built it with a smaller stack:
ftn95 stk.f90 & slink stk.obj /stack:0x40000,0x20000
The program crashes with stack overflow. So, I double the second stack size parameter, i.e.,
slink stk.obj /stack:0x40000,0x40000
This time, the program runs. Running OBJCONV on the EXE with the -df option gave, among other things, the following:
Size of stack reserve: 0x40000
Size of stack commit: 0x40000
As you can see, even if you have an EXE with no information regarding which linker was used, you can use a utility such as OBJCONV to obtain the stack size information that is contained in the file headers. This particular tool also displays the '0x' prefix to remove an ambiguity about the numbers being decimal/hexadecimal.
How much stack does your program need? That can be a bit hard to ascertain, if your compiler system does not provide help. Some versions of MS Link warn when they build an EXE with an insufficient stack size. You may need to experiment. For instance, If I had started with /stack:0x1000,0x1000 and repeatedly doubled the two numbers until the program ran, I would have seen 'no apparent effect' after five attempts, but the program would have run on the sixth attempt.
If your program is big and linking is slow, it would be more efficient to link once and simply modify the stack fields in the EXE header using a tool such as EDITBIN (included in MS C, Windows SDKs, etc):
editbin /stack:0x40000,0x40000 stk.exe
For details regarding what 'commit' and 'reserve' mean, please see https://msdn.microsoft.com/en-us/library/windows/desktop/ms686774(v=vs.85).aspx .