retpoline: add indirect thunk support

for gcc version > 7.3, enable CONFIG_RETPOLINE

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Jason Chen CJ
2018-03-12 20:57:44 +08:00
committed by Jack Ren
parent c244e8b5a3
commit d14a7dbdd2
5 changed files with 75 additions and 2 deletions

View File

@@ -153,6 +153,19 @@ ifeq ($(PLATFORM),uefi)
C_SRCS += bsp/$(PLATFORM)/cmdline.c
endif
# retpoline support
ifeq (true, $(shell [ $(GCC_MAJOR) -eq 7 ] && [ $(GCC_MINOR) -ge 3 ] && echo true))
CFLAGS += -mindirect-branch=thunk-extern -mindirect-branch-register
CFLAGS += -DCONFIG_RETPOLINE
S_SRCS += arch/x86/retpoline-thunk.S
else
ifeq (true, $(shell [ $(GCC_MAJOR) -ge 8 ] && echo true))
CFLAGS += -mindirect-branch=thunk-extern -mindirect-branch-register
CFLAGS += -DCONFIG_RETPOLINE
S_SRCS += arch/x86/retpoline-thunk.S
endif
endif
C_OBJS := $(patsubst %.c,$(HV_OBJDIR)/%.o,$(C_SRCS))
ifeq ($(RELEASE),0)
C_OBJS += $(patsubst %.c,$(HV_OBJDIR)/%.o,$(D_SRCS))