Skip to content

Commit

Permalink
Windows-only: expand GCC Stack-Smashing Protector usage
Browse files Browse the repository at this point in the history
- 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
Philip Kaufmann authored and Pieter Wuille committed Jan 18, 2013
1 parent e21a778 commit e813e14
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions bitcoin-qt.pro
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 # for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
QMAKE_CXXFLAGS *= -fstack-protector-all QMAKE_CXXFLAGS *= -fstack-protector-all
QMAKE_LFLAGS *= -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) # for extra security (see: https://wiki.debian.org/Hardening)
QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now 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 # for extra security on Windows: enable ASLR and DEP via GCC linker flags
Expand Down
4 changes: 2 additions & 2 deletions src/makefile.linux-mingw
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ LIBS= \


DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g DEBUGFLAGS=-g
CFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) CFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector -fstack-protector-all $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -static-libgcc -static-libstdc++ LDFLAGS=-static -fstack-protector-all -Wl,--dynamicbase -Wl,--nxcompat -static-libgcc -static-libstdc++


TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)


Expand Down
4 changes: 2 additions & 2 deletions src/makefile.mingw
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ LIBS= \


DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g -ggdb DEBUGFLAGS=-g -ggdb
CFLAGS=-mthreads -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector -fstack-protector-all $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat LDFLAGS=-static -fstack-protector-all -Wl,--dynamicbase -Wl,--nxcompat


TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)


Expand Down

0 comments on commit e813e14

Please sign in to comment.