Skip to content

Commit f42bee7

Browse files
committed
Merge branch 'id/windows-dep-aslr'
Allow DEP and ASLR for Windows build to for security hardening. * id/windows-dep-aslr: mingw: enable DEP and ASLR mingw: do not let ld strip relocations
2 parents d66da83 + ce6a158 commit f42bee7

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
@@ -576,13 +576,21 @@ else
576576
ifneq ($(shell expr "$(uname_R)" : '1\.'),2)
577577
# MSys2
578578
prefix = /usr/
579+
# Enable DEP
580+
BASIC_LDFLAGS += -Wl,--nxcompat
581+
# Enable ASLR (unless debugging)
582+
ifneq (,$(findstring -O,$(filter-out -O0 -Og,$(CFLAGS))))
583+
BASIC_LDFLAGS += -Wl,--dynamicbase
584+
endif
579585
ifeq (MINGW32,$(MSYSTEM))
580586
prefix = /mingw32
581587
HOST_CPU = i686
588+
BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup
582589
endif
583590
ifeq (MINGW64,$(MSYSTEM))
584591
prefix = /mingw64
585592
HOST_CPU = x86_64
593+
BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
586594
else
587595
COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
588596
BASIC_LDFLAGS += -Wl,--large-address-aware

0 commit comments

Comments
 (0)