Skip to content

Commit ef23e3c

Browse files
kuqin12mergify[bot]
authored andcommitted
BaseTools: Enable control flow guard for Windows builds
Certain environments require Control Flow Guard (CFG) to be enabled at build time as part of their security hardening requirements. This change adds the necessary compiler and linker flags to enable CFG support. Signed-off-by: Kun Qin <[email protected]>
1 parent 4e0376c commit ef23e3c

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

BaseTools/Source/C/Makefiles/ms.app

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ APPLICATION = $(BIN_PATH)\$(APPNAME).exe
1010
all: $(APPLICATION)
1111

1212
$(APPLICATION) : $(OBJECTS)
13-
-@if not exist $(BIN_PATH) mkdir $(BIN_PATH)
14-
$(LD) /nologo /debug /OPT:REF /OPT:ICF=10 /incremental:no /nodefaultlib:libc.lib /out:$@ $(LIBS) $**
13+
-@if not exist $(BIN_PATH) mkdir $(BIN_PATH)
14+
$(LD) /nologo /debug /DYNAMICBASE /guard:cf /OPT:REF /OPT:ICF=10 /incremental:no /nodefaultlib:libc.lib /out:$@ $(LIBS) $**
1515

1616
$(OBJECTS) : $(SOURCE_PATH)\Include\Common\BuildVersion.h
1717

1818
.PHONY:clean
1919
.PHONY:cleanall
2020

2121
clean:
22-
del /f /q $(OBJECTS) *.pdb > nul
22+
del /f /q $(OBJECTS) *.pdb > nul
2323

2424
cleanall:
25-
del /f /q $(OBJECTS) $(APPLICATION) *.pdb $(BIN_PATH)\$(APPNAME).pdb > nul
25+
del /f /q $(OBJECTS) $(APPLICATION) *.pdb $(BIN_PATH)\$(APPNAME).pdb > nul
2626

2727
!INCLUDE $(SOURCE_PATH)\Makefiles\ms.rule
2828

BaseTools/Source/C/Makefiles/ms.common

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ LINKER = $(LD)
8787
INC = $(INC) -I . -I $(SOURCE_PATH)\Include -I $(ARCH_INCLUDE) -I $(SOURCE_PATH)\Common
8888
INC = $(INC) -I $(EDK2_PATH)\MdePkg\Include
8989

90-
CFLAGS = $(CFLAGS) /nologo /Z7 /c /O2 /MT /W4 /WX /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE
91-
CPPFLAGS = $(CPPFLAGS) /EHsc /nologo /Z7 /c /O2 /MT /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE
90+
CFLAGS = $(CFLAGS) /nologo /Z7 /c /O2 /MT /W4 /WX /guard:cf /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE
91+
CPPFLAGS = $(CPPFLAGS) /EHsc /nologo /Z7 /c /O2 /MT /guard:cf /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE

0 commit comments

Comments
 (0)