I have wrote a c program on a Linux computer which displays main
function address.
ASLR seems to be enabled because address is not the same if a launch the program several times.
I have tried to debug this program with gdb. When the program is run through gdb, the main function's address is the same.
So it seems gdb is able to disable ASLR. How gdb does that ?
On Linux, this is done using the personality library call. The GDB code that does this can be found here.
On MacOS, this is done using a flag set in the posix_spawnattr_t
passed to posix_spawn, the code that does this can be found here.