Skip to content

Disable control flow integrity for instruction dispatch #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ endif

# For tail-call elimination, we need a specific set of build flags applied.
# FIXME: On macOS + Apple Silicon, -fno-stack-protector might have a negative impact.
$(OUT)/emulate.o: CFLAGS += -fomit-frame-pointer -fno-stack-check -fno-stack-protector
$(OUT)/emulate.o: CFLAGS += $(CFLAGS_NO_CET) -fomit-frame-pointer -fno-stack-check -fno-stack-protector

# Clear the .DEFAULT_GOAL special variable, so that the following turns
# to the first target after .DEFAULT_GOAL is not set.
Expand Down
9 changes: 9 additions & 0 deletions mk/toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ else
endif
endif

CFLAGS_NO_CET :=
processor := $(shell uname -m)
ifeq ($(processor),$(filter $(processor),i386 x86_64))
# GCC and Clang can generate support code for Intel's Control-flow
# Enforcement Technology (CET) through this compiler flag:
# -fcf-protection=[full]
CFLAGS_NO_CET := -fcf-protection=none
endif

# As of Xcode 15, linker warnings are emitted if duplicate '-l' options are
# present. Until such linkopts can be deduped by the build system, we disable
# these warnings.
Expand Down
2 changes: 1 addition & 1 deletion src/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ enum {
};

#if RV32_HAS(GDBSTUB)
#define RVOP_NO_NEXT(ir) (ir->tailcall || rv->debug_mode)
#define RVOP_NO_NEXT(ir) (ir->tailcall | rv->debug_mode)
#else
#define RVOP_NO_NEXT(ir) (ir->tailcall)
#endif
Expand Down