Hack Forums
[C] increasing the stack size using compiler flags - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] increasing the stack size using compiler flags (/showthread.php?tid=4865115)



increasing the stack size using compiler flags - Writz - Jun 14, 2015

i'm using gcc version 4.8.2, i'm on linux, having trouble with making a stack of size 8MB(8388608 bytes), due to the default stack size limit, tried "--main-stacksize=8388608" , but it didn't work.

any suggestions ?

my makefile...
Code
CPPFLAGS=    -g -w
all: run clean

run:  main.o lcf.o filz.o
    g++ $(CPPFLAGS) main.o lcf.o filz.o -o run

main.o: main.cpp
    g++ -c main.cpp

lcf.o: lcf.cpp
    g++ -c lcf.cpp

filz.o: filz.cpp
    g++ -c filz.cpp

clean:
    rm *.o

one more thing....

I ran this /usr/bin/ld --help | grep stack
-z execstack Mark executable as requiring executable stack
-z noexecstack Mark executable as not requiring executable stack
-z stacksize=SIZE Set size of stack segment
-z execstack Mark executable as requiring executable stack
-z noexecstack Mark executable as not requiring executable stack
-z stacksize=SIZE Set size of stack segment
-z execstack Mark executable as requiring executable stack
-z noexecstack Mark executable as not requiring executable stack
-z stacksize=SIZE Set size of stack segment
-z execstack Mark executable as requiring executable stack
-z noexecstack Mark executable as not requiring executable stack
-z stacksize=SIZE Set size of stack segment
-z execstack Mark executable as requiring executable stack
-z noexecstack Mark executable as not requiring executable stack
-z stacksize=SIZE Set size of stack segment
--stack <size> Set size of the initial stack
--stack <size> Set size of the initial stack



so I tried to add -z stacksize=8388608 in the CPPFLAGS , but still no good, cuz the linker chooses to ignore it after giving me a warning.


* - Only3 - Jun 14, 2015

try this http://stackoverflow.com/questions/18909395/how-do-i-increase-the-stack-size-when-compiling-with-clang-on-os-x


* - jfishy - Jun 14, 2015

What distro are you running? Is it a virtual machine?


* - Writz - Jun 15, 2015

(Jun 14, 2015 08:01 PM)jfishy Wrote:  What distro are you running? Is it a virtual machine?

yes it is, a virtual machine running lubuntu 14.01

(Jun 14, 2015 05:18 PM)Only3 Wrote:  try this http://stackoverflow.com/questions/18909395/how-do-i-increase-the-stack-size-when-compiling-with-clang-on-os-x

it didn't work, ld gives this error:

/usr/bin/ld: unrecognised -a option `ck_size'

The problem is kinda solved using this line..

> ulimit -s 32768 sets the stack size to 32M bytes