man ld
has the following to say about -z lazy
:
...tell the dynamic linker to defer function call resolution to the point when the function is called ... Lazy binding is the default.
On the other hand, gcc --verbose main.c
passes -z now -z relro
to ld for a main.c with an empty main()
$ gcc --verbose main.cUsing built-in specs.COLLECT_GCC=gcc[...]Thread model: posixgcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) [...]COLLECT_GCC_OPTIONS='-v''-mtune=generic''-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/7/collect2 [...] -pie -z now -z relro [...]
I see this in Ubuntu 18.04 and 19.04 with default installations of gcc.
So -z lazy
might be the default for ld, but where/why does gcc change that to -z now -z relro
?