Search notes:

gcc -fstack-protector

The protected c function

This simple function will be compiled with and without stack protection:
void g(char*);

void f() {

   char x[10];
   g(x);

}
Github repository about-gcc, path: /options/f/stack/protector/func.c

The Makefile

This Makefile produces three assembly files from the c function, one without stack protection, one compiled with -fstack-protector and one compiled with -fstack-protector-strong:
all: no-protection.S  stack-protector.S stack-protector-strong.S

no-protection.S: func.c
	gcc -S -masm=intel $< -o $@

stack-protector.S: func.c
	gcc -S -masm=intel $< -o $@ -fstack-protector

stack-protector-strong.S: func.c
	gcc -S -masm=intel $< -o $@ -fstack-protector-strong
Github repository about-gcc, path: /options/f/stack/protector/Makefile

Produced difference

When compiled with -fstack-protector or -fstack-protector-strong, the compiler inserted the following code before the call to g:
sub	rsp, 32
mov	rax, QWORD PTR fs:40
mov	QWORD PTR -8[rbp], rax
xor	eax, eax
lea	rax, -18[rbp]
and this code after the call:
mov	rax, QWORD PTR -8[rbp]
sub	rax, QWORD PTR fs:40
je	.L2
call	__stack_chk_fail@PLT
L2:
I was unable to detect a difference between compiling with -fstack-protector and -fstack-protector-strong.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:51 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(51): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(66): id_of(Object(PDO), 'uri', '/notes/developm...') #2 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758206668, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #3 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/GCC/options/f/stack/protector(80): insert_webrequest() #4 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 51