Skip to content

Commit e813e14

Browse files
Philip KaufmannPieter Wuille
authored andcommitted
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
1 parent e21a778 commit e813e14

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

bitcoin-qt.pro

Lines changed: 2 additions & 4 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -33,13 +33,11 @@ contains(RELEASE, 1) {
33
}
33
}
34
}
34
}
35

35

36-
!win32 {
36+
# on Windows: use static linking
37+
win32:QMAKE_LFLAGS *= -static
37
# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
38
# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
38
QMAKE_CXXFLAGS *= -fstack-protector-all
39
QMAKE_CXXFLAGS *= -fstack-protector-all
39
QMAKE_LFLAGS *= -fstack-protector-all
40
QMAKE_LFLAGS *= -fstack-protector-all
40-
# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
41-
# This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
42-
}
43
# for extra security (see: https://wiki.debian.org/Hardening)
41
# for extra security (see: https://wiki.debian.org/Hardening)
44
QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now
42
QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now
45
# for extra security on Windows: enable ASLR and DEP via GCC linker flags
43
# for extra security on Windows: enable ASLR and DEP via GCC linker flags

src/makefile.linux-mingw

Lines changed: 2 additions & 2 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -32,8 +32,8 @@ LIBS= \
32

32

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

37

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

39

src/makefile.mingw

Lines changed: 2 additions & 2 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -43,8 +43,8 @@ LIBS= \
43

43

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

48

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

50

0 commit comments

Comments
 (0)