Skip to content

Commit aad03f2

Browse files
committed
Enable PIE, High Entropy ASLR and add more warnings to Makefile
1 parent a028cb0 commit aad03f2

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ To build x86 exe run:
7979

8080
And for x86_64:
8181

82-
`make CPREFIX=x86_64-w64-mingw32- WINDIVERTHEADERS=/path/to/windivert/include WINDIVERTLIBS=/path/to/windivert/amd64`
82+
`make CPREFIX=x86_64-w64-mingw32- BIT64=1 WINDIVERTHEADERS=/path/to/windivert/include WINDIVERTLIBS=/path/to/windivert/amd64`
8383

8484
# How to install as Windows Service
8585

src/Makefile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,27 @@ endif
44

55
WINDIVERTHEADERS = ../../../include
66
WINDIVERTLIBS = ../../binary
7+
MINGWLIB = /usr/x86_64-w64-mingw32/lib/
78

89
TARGET = goodbyedpi.exe
10+
# Linking SSP does not work for some reason, the executable doesn't start.
11+
#LIBS = -L$(WINDIVERTLIBS) -Wl,-Bstatic -lssp -Wl,-Bdynamic -lWinDivert -lws2_32
912
LIBS = -L$(WINDIVERTLIBS) -lWinDivert -lws2_32
1013
CC = $(CPREFIX)gcc
1114
CCWINDRES = $(CPREFIX)windres
12-
CFLAGS = -Wall -Wextra -I$(WINDIVERTHEADERS) -L$(WINDIVERTLIBS) \
13-
-O2 -pie -fPIE -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2
14-
LDFLAGS = -Wl,-O1,--sort-common,--as-needed
15+
CFLAGS = -std=c99 -pie -fPIE -pipe -I$(WINDIVERTHEADERS) -L$(WINDIVERTLIBS) \
16+
-O2 -D_FORTIFY_SOURCE=2 \
17+
-Wall -Wextra -Wpedantic -Wformat=2 -Wshadow -Wstrict-aliasing=1 -Werror=format-security \
18+
-Wfloat-equal -Wcast-align -Wsign-conversion \
19+
#-fstack-protector-strong
20+
LDFLAGS = -Wl,-O1,-pie,--dynamicbase,--nxcompat,--sort-common,--as-needed \
21+
-Wl,--image-base,0x140000000 -Wl,--disable-auto-image-base
22+
23+
ifdef BIT64
24+
LDFLAGS += -Wl,--high-entropy-va -Wl,--pic-executable,-e,mainCRTStartup
25+
else
26+
LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup
27+
endif
1528

1629
.PHONY: default all clean
1730

0 commit comments

Comments
 (0)