Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase Stack Size on Windows (GCC)

Is there a way to increase the stack size of a Windows application at compile/link time with GCC?

like image 889
Landon Avatar asked Oct 01 '08 07:10

Landon


People also ask

Can we change the size of stack?

One cannot increase the stack size.

Why is stack size limited?

If the stack would be allowed to grow arbitrarily large, these errors (like infinite recursion) would be caught very late, only after the operating systems resources are exhausted. This is prevented by setting an arbitrary limit to the stack size.


2 Answers

IIRC, In GCC you can provide the --stack,[bytes] parameter to ld.

E.g.

gcc -Wl,--stack,16777216 -o file.exe file.c

To have a stack of 16MiB, I think that the default size is 8MiB.

like image 161
Jonas Engström Avatar answered Sep 20 '22 02:09

Jonas Engström


You could run editbin after linking.

like image 45
leppie Avatar answered Sep 18 '22 02:09

leppie