Permalink
Browse files

Windows-only: expand GCC Stack-Smashing Protector usage

- enable -fstack-protector-all and static linking for Windows, which
  should result in a binary that is not dependent on libssp-0.dll
- add missing -Wstack-protector flag to CFLAGS in makefile.mingw and
  makefile.linux-mingw
- add a comment to these makefiles also
  • Loading branch information...
1 parent e21a778 commit e813e14f68a844c0c6c364aa66f9040f06e56bfe Philip Kaufmann committed with Pieter Wuille Jul 16, 2012
Showing with 6 additions and 8 deletions.
  1. +2 −4 bitcoin-qt.pro
  2. +2 −2 src/makefile.linux-mingw
  3. +2 −2 src/makefile.mingw
View
@@ -33,13 +33,11 @@ contains(RELEASE, 1) {
}
}
-!win32 {
+# on Windows: use static linking
+win32:QMAKE_LFLAGS *= -static
# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
QMAKE_CXXFLAGS *= -fstack-protector-all
QMAKE_LFLAGS *= -fstack-protector-all
-# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
-# This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
-}
# for extra security (see: https://wiki.debian.org/Hardening)
QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now
# for extra security on Windows: enable ASLR and DEP via GCC linker flags
View
@@ -32,8 +32,8 @@ LIBS= \
DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g
-CFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
-LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -static-libgcc -static-libstdc++
+CFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector -fstack-protector-all $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
+LDFLAGS=-static -fstack-protector-all -Wl,--dynamicbase -Wl,--nxcompat -static-libgcc -static-libstdc++
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
View
@@ -43,8 +43,8 @@ LIBS= \
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g -ggdb
-CFLAGS=-mthreads -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
-LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat
+CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector -fstack-protector-all $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
+LDFLAGS=-static -fstack-protector-all -Wl,--dynamicbase -Wl,--nxcompat
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)

0 comments on commit e813e14

Please sign in to comment.