Just a bit of warning about clang. By the default state the clang compiler
does not install stack cookie checks to its function calls.
Given a simple function that managers buffers:
a binary compiled with gcc (gccbin) and clang (clangbin) have been
Examining the binaries show that gcc places extra instructions in
to do a stack cookie check by default:
But clang does not by default:
In order for clang to emit stack cookies, it must be compiled with the -fstack-protector flag:
And as we can see from the disassembly, the stack cookie value (taken from fs:0x28 on intel 64 bit) is used as a stack cookie.
This may be relevant for people replacing gcc in their make scripts with clang (e.g. replacing CXX=gcc with CXX=clang). By default the stack cookie protection on gcc is built in, on clang it is not.