Skip to content

Commit 4eee806

Browse files
committed
Merge 'aslr' into HEAD
Address Space Layout Randomization (ASLR) allows executables' memory layout to change at random between runs, and therefore offers a quite decent protection against many attacks. We enable ASLR because MSYS2's C compiler offers support for ASLR, and whatever performance impact it has is neglible, according to https://insights.sei.cmu.edu/cert/2014/02/differences-between-aslr-on-windows-and-linux.html This merges the part of #612 that does not break Git ;-) This fixes #608 Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 3cf2464 + 9346389 commit 4eee806

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

config.mak.uname

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,19 @@ else
545545
ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
546546
# MSys2
547547
prefix = /usr/
548+
# Enable DEP
549+
BASIC_LDFLAGS += -Wl,--nxcompat
550+
# Enable ASLR (unless debugging)
551+
ifneq (,$(findstring -O,$(CFLAGS)))
552+
BASIC_LDFLAGS += -Wl,--dynamicbase
553+
endif
548554
ifeq (MINGW32,$(MSYSTEM))
549555
prefix = /mingw32
556+
BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup
550557
endif
551558
ifeq (MINGW64,$(MSYSTEM))
552559
prefix = /mingw64
560+
BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
553561
else
554562
COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
555563
BASIC_LDFLAGS += -Wl,--large-address-aware

0 commit comments

Comments
 (0)