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