GNU ld linker: stack-size=value has no effect

322 Views Asked by At

I want to compile a C program and specify at compile time the stack size (below is a sample code).

#include <stdio.h>
#include <sys/resource.h>
static struct rlimit Rl;
int main() {
getrlimit(RLIMIT_STACK,&Rl);
printf("%lu %lu\n",Rl.rlim_cur,Rl.rlim_max);
return 0;
}

I compiled it with the following command

gcc Source.c -Wl,-z,stack-size=value -o program

I tried a lot of values but the program displays the same information: 8388608 4294967295

If I use the ulimit command (ulimit -s 4096) the program displays: 4194304 4194304 (4096 Kb)

But then I must close and reopen the window, otherwise other commands will not work.

Is there any other solution to set the stack size before launching the program ?

I currently use gcc (Ubuntu 7.5.0-3ubuntu1~16.04) 7.5.0

0

There are 0 best solutions below