1 # SPDX-License-Identifier: GPL-2.0 1 # SPDX-License-Identifier: GPL-2.0 >> 2 GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin) 2 3 3 $(obj)/randomize_layout_plugin.so: $(obj)/rand !! 4 ifeq ($(PLUGINCC),$(HOSTCC)) 4 quiet_cmd_create_randomize_layout_seed = SEEDH !! 5 HOSTLIBS := hostlibs 5 cmd_create_randomize_layout_seed = \ !! 6 HOST_EXTRACFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu99 -ggdb 6 SEED=$$(cat $(filter-out FORCE,$^) </d !! 7 export HOST_EXTRACFLAGS 7 echo '/*' > $@; \ !! 8 else 8 echo ' * This file is automatically ge !! 9 HOSTLIBS := hostcxxlibs 9 echo ' * Exposing this value will expo !! 10 HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti 10 echo ' */' >> $@; \ !! 11 HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb 11 echo "const char *randstruct_seed = \" !! 12 HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable 12 $(obj)/randomize_layout_seed.h: $(objtree)/scr !! 13 export HOST_EXTRACXXFLAGS 13 $(call if_changed,create_randomize_lay !! 14 endif 14 targets += randomize_layout_seed.h !! 15 15 !! 16 ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN)) 16 # Build rules for plugins !! 17 GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN)) 17 # !! 18 endif 18 # No extra code is needed for single-file plug << 19 # For multi-file plugins, use *-objs syntax to << 20 # << 21 # If the plugin foo.so is compiled from foo.c << 22 # << 23 # foo-objs := foo.o foo2.o << 24 << 25 always-y += $(GCC_PLUGIN) << 26 << 27 GCC_PLUGINS_DIR = $(shell $(CC) -print-file-na << 28 << 29 plugin_cxxflags = -Wp,-MMD,$(depfile) $(KBUILD << 30 -include $(srctree)/include/ << 31 -DPLUGIN_VERSION=$(call stri << 32 -I $(GCC_PLUGINS_DIR)/includ << 33 -fno-rtti -fno-exceptions -f << 34 -ggdb -Wno-narrowing -Wno-un << 35 -Wno-format-diag << 36 << 37 plugin_ldflags = -shared << 38 << 39 plugin-single := $(foreach m, $(GCC_PLUGIN), << 40 plugin-multi := $(filter-out $(plugin-singl << 41 plugin-objs := $(sort $(foreach m, $(plugi << 42 << 43 targets += $(plugin-single) $(plugin-multi) $( << 44 clean-files += *.so << 45 19 46 plugin-single := $(addprefix $(obj)/, $(plug !! 20 export HOSTLIBS 47 plugin-multi := $(addprefix $(obj)/, $(plug << 48 plugin-objs := $(addprefix $(obj)/, $(plug << 49 21 50 quiet_cmd_plugin_cxx_so_c = HOSTCXX $@ !! 22 $(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h 51 cmd_plugin_cxx_so_c = $(HOSTCXX) $(plugi !! 23 quiet_cmd_create_randomize_layout_seed = GENSEED $@ 52 !! 24 cmd_create_randomize_layout_seed = \ 53 $(plugin-single): $(obj)/%.so: $(src)/%.c FORC !! 25 $(CONFIG_SHELL) $(srctree)/$(src)/gen-random-seed.sh $@ $(objtree)/include/generated/randomize_layout_hash.h 54 $(call if_changed_dep,plugin_cxx_so_c) !! 26 $(objtree)/$(obj)/randomize_layout_seed.h: FORCE >> 27 $(call if_changed,create_randomize_layout_seed) >> 28 targets = randomize_layout_seed.h randomize_layout_hash.h 55 29 56 quiet_cmd_plugin_ld_so_o = HOSTLD $@ !! 30 $(HOSTLIBS)-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p))) 57 cmd_plugin_ld_so_o = $(HOSTCXX) $(plugin !! 31 always := $($(HOSTLIBS)-y) 58 $(addprefix $(obj)/ << 59 32 60 $(plugin-multi): FORCE !! 33 $(foreach p,$($(HOSTLIBS)-y:%.so=%),$(eval $(p)-objs := $(p).o)) 61 $(call if_changed,plugin_ld_so_o) << 62 $(foreach m, $(notdir $(plugin-multi)), $(eval << 63 34 64 quiet_cmd_plugin_cxx_o_c = HOSTCXX $@ !! 35 subdir-y := $(GCC_PLUGIN_SUBDIR) 65 cmd_plugin_cxx_o_c = $(HOSTCXX) $(plugin !! 36 subdir- += $(GCC_PLUGIN_SUBDIR) 66 37 67 $(plugin-objs): $(obj)/%.o: $(src)/%.c FORCE !! 38 clean-files += *.so 68 $(call if_changed_dep,plugin_cxx_o_c) <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.