A non exhaustive list of gcc compiler options.
$ gcc myprog.c -o myprog -Wall -Wextra -pedantic -std=c11 [...]
---------------------------------------------------------------------------------------------------------------- | |
Kaiwan N Billimoria, kaiwanTECH : opensource GitHub repos for source code | |
---------------------------------------------------------------------------------------------------------------- | |
<<------- My book repos ------->> | |
Linux Kernel Programming, 2E (2nd Edition) | |
- A comprehensive guide to kernel internals, writing kernel modules, and kernel synchronization | |
Packt, Feb 2024 | |
https://github.com/PacktPublishing/Linux-Kernel-Programming_2E |
Source material: | |
http://security.stackexchange.com/questions/24444/what-is-the-most-hardened-set-of-options-for-gcc-compiling-c-c | |
https://wiki.gentoo.org/wiki/Hardened_Gentoo | |
https://wiki.debian.org/Hardening | |
================================================================================================================> | |
GCC Security related flags and options: | |
CFLAGS="-fPIE -fstack-protector-all -D_FORTIFY_SOURCE=2" | |
LDFLAGS="-Wl,-z,now -Wl,-z,relro" |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 4x mutex op, 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 2K bytes over 1 Gbps network 20,000 ns | |
Read 1 MB sequentially from memory 250,000 ns |