My question is based on this tiny stkaddr.cpp program:
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("&argc = %p\n", &argc);
}
Using Visual Studio 2019, I know that I can use linker option /DYNAMICBASE:NO to have invariant(constant) local variable address across each run. May be we call it "no ASLR".
With /DYNAMICBASE:NO, each run of the exe we see the same address for &argc.
Then I'd like to ask how can I achieve this for a gcc compiled Linux program.
On Ubuntu Linux 20.04, with gcc 9.4.0, I tried -no-pie, but no effect.


echo 0 > /proc/sys/kernel/randomize_va_spacemakes&argcconstant, even not compiling with-no-pie. Then I'm wondering must we do that system-wide? I hope it should be at least user-wide, or better, session-wide.&stkadris what you should use for the stack address. Don't assume it's constant across executions, whether ASLR is enabled or not.