0001
0002
0003 $(obj)/randomize_layout_plugin.so: $(obj)/randomize_layout_seed.h
0004 quiet_cmd_create_randomize_layout_seed = SEEDHDR $@
0005 cmd_create_randomize_layout_seed = \
0006 SEED=$$(cat $(filter-out FORCE,$^) </dev/null); \
0007 echo '/*' > $@; \
0008 echo ' * This file is automatically generated. Keep it private.' >> $@; \
0009 echo ' * Exposing this value will expose the layout of randomized structures.' >> $@; \
0010 echo ' */' >> $@; \
0011 echo "const char *randstruct_seed = \"$$SEED\";" >> $@
0012 $(obj)/randomize_layout_seed.h: $(objtree)/scripts/basic/randstruct.seed FORCE
0013 $(call if_changed,create_randomize_layout_seed)
0014 targets += randomize_layout_seed.h
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 always-y += $(GCC_PLUGIN)
0026
0027 GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)
0028
0029 plugin_cxxflags = -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
0030 -include $(srctree)/include/linux/compiler-version.h \
0031 -DPLUGIN_VERSION=$(call stringify,$(KERNELVERSION)) \
0032 -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \
0033 -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \
0034 -ggdb -Wno-narrowing -Wno-unused-variable \
0035 -Wno-format-diag
0036
0037 plugin_ldflags = -shared
0038
0039 plugin-single := $(foreach m, $(GCC_PLUGIN), $(if $($(m:%.so=%-objs)),,$(m)))
0040 plugin-multi := $(filter-out $(plugin-single), $(GCC_PLUGIN))
0041 plugin-objs := $(sort $(foreach m, $(plugin-multi), $($(m:%.so=%-objs))))
0042
0043 targets += $(plugin-single) $(plugin-multi) $(plugin-objs)
0044 clean-files += *.so
0045
0046 plugin-single := $(addprefix $(obj)/, $(plugin-single))
0047 plugin-multi := $(addprefix $(obj)/, $(plugin-multi))
0048 plugin-objs := $(addprefix $(obj)/, $(plugin-objs))
0049
0050 quiet_cmd_plugin_cxx_so_c = HOSTCXX $@
0051 cmd_plugin_cxx_so_c = $(HOSTCXX) $(plugin_cxxflags) $(plugin_ldflags) -o $@ $<
0052
0053 $(plugin-single): $(obj)/%.so: $(src)/%.c FORCE
0054 $(call if_changed_dep,plugin_cxx_so_c)
0055
0056 quiet_cmd_plugin_ld_so_o = HOSTLD $@
0057 cmd_plugin_ld_so_o = $(HOSTCXX) $(plugin_ldflags) -o $@ \
0058 $(addprefix $(obj)/, $($(target-stem)-objs))
0059
0060 $(plugin-multi): FORCE
0061 $(call if_changed,plugin_ld_so_o)
0062 $(foreach m, $(notdir $(plugin-multi)), $(eval $(obj)/$m: $(addprefix $(obj)/, $($(m:%.so=%-objs)))))
0063
0064 quiet_cmd_plugin_cxx_o_c = HOSTCXX $@
0065 cmd_plugin_cxx_o_c = $(HOSTCXX) $(plugin_cxxflags) -c -o $@ $<
0066
0067 $(plugin-objs): $(obj)/%.o: $(src)/%.c FORCE
0068 $(call if_changed_dep,plugin_cxx_o_c)