Is there a way (using gcc) to set the stack size of a shared library ?
I build a .so that contain a single function that uses a big buffer as local variable.
Something like that:
void foo ( void )
{
int table [1000000] ; // 4 millions bytes table !
...
}
I added the option -Wl,-z,stack-size=4100000
but it has no effet (not even an error message).
By the way, this lib is meant to be invoked from java code (using JNA).
Since I didn't find any post about this peculiar question, I'm afraid it's not possible...
No, this is not possible - functions from shared library work in the context of thread which calls them and that thread will either be a main application thread (which started in main
) or a thread created with Pthreads (which will have stack allocated at thread creation time in pthread_create
).
-Wl,-z,stack-size
flag is only applicable to applications, not libraries, and sets the size of main thread's stack.