flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [request]Default Stack Size for PE

Author
Thread Post new topic Reply to topic
Chewy509



Joined: 19 Jun 2003
Posts: 297
Location: Bris-vegas, Australia
Chewy509 05 Jul 2007, 22:27
Hi Guys,

I was wondering about why the default stack size for PE files is only 4096 bytes?

I'm finding that for the project I'm currently working on, a larger stack size is always needed, particularly for PE64 executables.

Is it possible to raise the default stack size to 1MB (as this is the default for MS Compilers/Linkers)?

PS. I'm having a problem with using the 'stack' keyword with large *.asm files, FASM crashes (and at least on my XP x64 PC, it deletes the source file as well). Using 1.67.21, and the same occurs on 1.67.6 as well.

PPS. The delete thing doesn't happen on XP 32bit.
Post 05 Jul 2007, 22:27
View user's profile Send private message Visit poster's website Reply with quote
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
Maverick 06 Jul 2007, 06:55
The best thing you can do is to keep it to 4KB in the PE, and then handle it dynamically with your own code. Remember, though, to set FS:4 and FS:8 to the correct value (or set it to the $00000000..$7FFFFFFF extremes and forget) otherwise your ESP will be checked in most Win32 functions and your thread will be terminated by the OS (should it lay outside the FS:4..FS:8 boundaries).
For my programming style, I tend to use the stack a lot, and the heap as little as possible. Allocating memory on the stack, when you use the technique above, is just using [ESP-xxxxx] straight. Superfast allocation, and no need to free anything. Also, you don't have to probe for stack pages, etc.. like the usual stack Win32 programming style.
Post 06 Jul 2007, 06:55
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 06 Jul 2007, 11:47
Just remember to allocate memory for your new manual stack Razz
Post 06 Jul 2007, 11:47
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.