aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.build
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Makefile.build')
-rw-r--r--scripts/Makefile.build55
1 files changed, 20 insertions, 35 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 5d900307de3e..c7de8b39fcf1 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -151,16 +151,16 @@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $<
151$(obj)/%.i: $(src)/%.c FORCE 151$(obj)/%.i: $(src)/%.c FORCE
152 $(call if_changed_dep,cc_i_c) 152 $(call if_changed_dep,cc_i_c)
153 153
154cmd_genksyms = \ 154cmd_gensymtypes = \
155 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ 155 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \
156 $(GENKSYMS) -T $@ -A -a $(ARCH) \ 156 $(GENKSYMS) -T $@ -a $(ARCH) \
157 $(if $(KBUILD_PRESERVE),-p) \ 157 $(if $(KBUILD_PRESERVE),-p) \
158 $(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null))) 158 $(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null)))
159 159
160quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ 160quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
161cmd_cc_symtypes_c = \ 161cmd_cc_symtypes_c = \
162 set -e; \ 162 set -e; \
163 $(call cmd_genksyms, true) >/dev/null; \ 163 $(call cmd_gensymtypes, true) >/dev/null; \
164 test -s $@ || rm -f $@ 164 test -s $@ || rm -f $@
165 165
166$(obj)/%.symtypes : $(src)/%.c FORCE 166$(obj)/%.symtypes : $(src)/%.c FORCE
@@ -177,38 +177,28 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
177 177
178else 178else
179# When module versioning is enabled the following steps are executed: 179# When module versioning is enabled the following steps are executed:
180# o compile a .tmp_<file>.s from <file>.c 180# o compile a .tmp_<file>.o from <file>.c
181# o if .tmp_<file>.s doesn't contain a __ksymtab version, i.e. does 181# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
182# not export symbols, we just assemble .tmp_<file>.s to <file>.o and 182# not export symbols, we just rename .tmp_<file>.o to <file>.o and
183# are done. 183# are done.
184# o otherwise, we calculate symbol versions using the good old 184# o otherwise, we calculate symbol versions using the good old
185# genksyms on the preprocessed source and postprocess them in a way 185# genksyms on the preprocessed source and postprocess them in a way
186# that they are usable as assembly source 186# that they are usable as a linker script
187# o assemble <file>.o from .tmp_<file>.s forcing inclusion of directives 187# o generate <file>.o from .tmp_<file>.o using the linker to
188# defining the actual values of __crc_*, followed by objcopy-ing them 188# replace the unresolved symbols __crc_exported_symbol with
189# to force these symbols to be local to permit stripping them later. 189# the actual value of the checksum generated by genksyms
190s_file = $(@D)/.tmp_$(@F:.o=.s)
191v_file = $(@D)/.tmp_$(@F:.o=.v)
192tmp_o_file = $(@D)/.tmp_$(@F)
193no_g_c_flags = $(filter-out -g%,$(c_flags))
194
195cmd_cc_o_c = $(CC) $(c_flags) -S -o $(s_file) $<
196 190
191cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
197cmd_modversions = \ 192cmd_modversions = \
198 if grep -q __ksymtab $(s_file); then \ 193 if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
199 if $(call cmd_genksyms, $(KBUILD_SYMTYPES)) > $(v_file) \ 194 $(call cmd_gensymtypes, $(KBUILD_SYMTYPES)) \
200 && $(CC) $(no_g_c_flags) -c -Wa,$(v_file) \ 195 > $(@D)/.tmp_$(@F:.o=.ver); \
201 -o $(tmp_o_file) $(s_file) \ 196 \
202 && $(OBJCOPY) -L '__crc_*' -L '___crc_*' -w \ 197 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
203 $(tmp_o_file) $@; \ 198 -T $(@D)/.tmp_$(@F:.o=.ver); \
204 then \ 199 rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
205 : ; \
206 else \
207 rm -f $@; exit 1; \
208 fi; \
209 else \ 200 else \
210 rm -f $(v_file); \ 201 mv -f $(@D)/.tmp_$(@F) $@; \
211 $(CC) $(no_g_c_flags) -c -o $@ $(s_file); \
212 fi; 202 fi;
213endif 203endif
214 204
@@ -225,12 +215,7 @@ define rule_cc_o_c
225 $(cmd_record_mcount) \ 215 $(cmd_record_mcount) \
226 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ 216 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
227 $(dot-target).tmp; \ 217 $(dot-target).tmp; \
228 if [ -r $(@D)/.tmp_$(@F:.o=.v) ]; then \ 218 rm -f $(depfile); \
229 echo >> $(dot-target).tmp; \
230 echo '$@: $(GENKSYMS)' >> $(dot-target).tmp; \
231 echo '$(GENKSYMS):: ;' >> $(dot-target).tmp; \
232 fi; \
233 rm -f $(depfile) $(@D)/.tmp_$(@F:.o=.?); \
234 mv -f $(dot-target).tmp $(dot-target).cmd 219 mv -f $(dot-target).tmp $(dot-target).cmd
235endef 220endef
236 221