diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Makefile.build | 81 | ||||
| -rw-r--r-- | scripts/Makefile.extrawarn | 1 | ||||
| -rw-r--r-- | scripts/Makefile.ubsan | 4 | ||||
| -rwxr-xr-x | scripts/bloat-o-meter | 3 | ||||
| -rwxr-xr-x | scripts/gcc-x86_64-has-stack-protector.sh | 2 |
5 files changed, 84 insertions, 7 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index de46ab03f063..7675d11ee65e 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
| @@ -159,7 +159,8 @@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< | |||
| 159 | $(obj)/%.i: $(src)/%.c FORCE | 159 | $(obj)/%.i: $(src)/%.c FORCE |
| 160 | $(call if_changed_dep,cpp_i_c) | 160 | $(call if_changed_dep,cpp_i_c) |
| 161 | 161 | ||
| 162 | cmd_gensymtypes = \ | 162 | # These mirror gensymtypes_S and co below, keep them in synch. |
| 163 | cmd_gensymtypes_c = \ | ||
| 163 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ | 164 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ |
| 164 | $(GENKSYMS) $(if $(1), -T $(2)) \ | 165 | $(GENKSYMS) $(if $(1), -T $(2)) \ |
| 165 | $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ | 166 | $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ |
| @@ -169,7 +170,7 @@ cmd_gensymtypes = \ | |||
| 169 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ | 170 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ |
| 170 | cmd_cc_symtypes_c = \ | 171 | cmd_cc_symtypes_c = \ |
| 171 | set -e; \ | 172 | set -e; \ |
| 172 | $(call cmd_gensymtypes,true,$@) >/dev/null; \ | 173 | $(call cmd_gensymtypes_c,true,$@) >/dev/null; \ |
| 173 | test -s $@ || rm -f $@ | 174 | test -s $@ || rm -f $@ |
| 174 | 175 | ||
| 175 | $(obj)/%.symtypes : $(src)/%.c FORCE | 176 | $(obj)/%.symtypes : $(src)/%.c FORCE |
| @@ -198,9 +199,10 @@ else | |||
| 198 | # the actual value of the checksum generated by genksyms | 199 | # the actual value of the checksum generated by genksyms |
| 199 | 200 | ||
| 200 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< | 201 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< |
| 201 | cmd_modversions = \ | 202 | |
| 203 | cmd_modversions_c = \ | ||
| 202 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ | 204 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ |
| 203 | $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ | 205 | $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ |
| 204 | > $(@D)/.tmp_$(@F:.o=.ver); \ | 206 | > $(@D)/.tmp_$(@F:.o=.ver); \ |
| 205 | \ | 207 | \ |
| 206 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ | 208 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ |
| @@ -268,13 +270,14 @@ endif # CONFIG_STACK_VALIDATION | |||
| 268 | define rule_cc_o_c | 270 | define rule_cc_o_c |
| 269 | $(call echo-cmd,checksrc) $(cmd_checksrc) \ | 271 | $(call echo-cmd,checksrc) $(cmd_checksrc) \ |
| 270 | $(call cmd_and_fixdep,cc_o_c) \ | 272 | $(call cmd_and_fixdep,cc_o_c) \ |
| 271 | $(cmd_modversions) \ | 273 | $(cmd_modversions_c) \ |
| 272 | $(cmd_objtool) \ | 274 | $(cmd_objtool) \ |
| 273 | $(call echo-cmd,record_mcount) $(cmd_record_mcount) | 275 | $(call echo-cmd,record_mcount) $(cmd_record_mcount) |
| 274 | endef | 276 | endef |
| 275 | 277 | ||
| 276 | define rule_as_o_S | 278 | define rule_as_o_S |
| 277 | $(call cmd_and_fixdep,as_o_S) \ | 279 | $(call cmd_and_fixdep,as_o_S) \ |
| 280 | $(cmd_modversions_S) \ | ||
| 278 | $(cmd_objtool) | 281 | $(cmd_objtool) |
| 279 | endef | 282 | endef |
| 280 | 283 | ||
| @@ -314,6 +317,39 @@ modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) | |||
| 314 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) | 317 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
| 315 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) | 318 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
| 316 | 319 | ||
| 320 | # .S file exports must have their C prototypes defined in asm/asm-prototypes.h | ||
| 321 | # or a file that it includes, in order to get versioned symbols. We build a | ||
| 322 | # dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from | ||
| 323 | # the .S file (with trailing ';'), and run genksyms on that, to extract vers. | ||
| 324 | # | ||
| 325 | # This is convoluted. The .S file must first be preprocessed to run guards and | ||
| 326 | # expand names, then the resulting exports must be constructed into plain | ||
| 327 | # EXPORT_SYMBOL(symbol); to build our dummy C file, and that gets preprocessed | ||
| 328 | # to make the genksyms input. | ||
| 329 | # | ||
| 330 | # These mirror gensymtypes_c and co above, keep them in synch. | ||
| 331 | cmd_gensymtypes_S = \ | ||
| 332 | (echo "\#include <linux/kernel.h>" ; \ | ||
| 333 | echo "\#include <asm/asm-prototypes.h>" ; \ | ||
| 334 | $(CPP) $(a_flags) $< | \ | ||
| 335 | grep "\<___EXPORT_SYMBOL\>" | \ | ||
| 336 | sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \ | ||
| 337 | $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ | ||
| 338 | $(GENKSYMS) $(if $(1), -T $(2)) \ | ||
| 339 | $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ | ||
| 340 | $(if $(KBUILD_PRESERVE),-p) \ | ||
| 341 | -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) | ||
| 342 | |||
| 343 | quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ | ||
| 344 | cmd_cc_symtypes_S = \ | ||
| 345 | set -e; \ | ||
| 346 | $(call cmd_gensymtypes_S,true,$@) >/dev/null; \ | ||
| 347 | test -s $@ || rm -f $@ | ||
| 348 | |||
| 349 | $(obj)/%.symtypes : $(src)/%.S FORCE | ||
| 350 | $(call cmd,cc_symtypes_S) | ||
| 351 | |||
| 352 | |||
| 317 | quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@ | 353 | quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@ |
| 318 | cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $< | 354 | cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $< |
| 319 | 355 | ||
| @@ -321,7 +357,37 @@ $(obj)/%.s: $(src)/%.S FORCE | |||
| 321 | $(call if_changed_dep,cpp_s_S) | 357 | $(call if_changed_dep,cpp_s_S) |
| 322 | 358 | ||
| 323 | quiet_cmd_as_o_S = AS $(quiet_modtag) $@ | 359 | quiet_cmd_as_o_S = AS $(quiet_modtag) $@ |
| 324 | cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< | 360 | |
| 361 | ifndef CONFIG_MODVERSIONS | ||
| 362 | cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< | ||
| 363 | |||
| 364 | else | ||
| 365 | |||
| 366 | ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h) | ||
| 367 | |||
| 368 | ifeq ($(ASM_PROTOTYPES),) | ||
| 369 | cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< | ||
| 370 | |||
| 371 | else | ||
| 372 | |||
| 373 | # versioning matches the C process described above, with difference that | ||
| 374 | # we parse asm-prototypes.h C header to get function definitions. | ||
| 375 | |||
| 376 | cmd_as_o_S = $(CC) $(a_flags) -c -o $(@D)/.tmp_$(@F) $< | ||
| 377 | |||
| 378 | cmd_modversions_S = \ | ||
| 379 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ | ||
| 380 | $(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ | ||
| 381 | > $(@D)/.tmp_$(@F:.o=.ver); \ | ||
| 382 | \ | ||
| 383 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ | ||
| 384 | -T $(@D)/.tmp_$(@F:.o=.ver); \ | ||
| 385 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ | ||
| 386 | else \ | ||
| 387 | mv -f $(@D)/.tmp_$(@F) $@; \ | ||
| 388 | fi; | ||
| 389 | endif | ||
| 390 | endif | ||
| 325 | 391 | ||
| 326 | $(obj)/%.o: $(src)/%.S $(objtool_obj) FORCE | 392 | $(obj)/%.o: $(src)/%.S $(objtool_obj) FORCE |
| 327 | $(call if_changed_rule,as_o_S) | 393 | $(call if_changed_rule,as_o_S) |
| @@ -430,6 +496,9 @@ cmd_export_list = $(OBJDUMP) -h $< | \ | |||
| 430 | 496 | ||
| 431 | $(obj)/lib-ksyms.o: $(lib-target) FORCE | 497 | $(obj)/lib-ksyms.o: $(lib-target) FORCE |
| 432 | $(call if_changed,export_list) | 498 | $(call if_changed,export_list) |
| 499 | |||
| 500 | targets += $(obj)/lib-ksyms.o | ||
| 501 | |||
| 433 | endif | 502 | endif |
| 434 | 503 | ||
| 435 | # | 504 | # |
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 53449a6ff6aa..7c321a603b07 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn | |||
| @@ -36,6 +36,7 @@ warning-2 += -Wshadow | |||
| 36 | warning-2 += $(call cc-option, -Wlogical-op) | 36 | warning-2 += $(call cc-option, -Wlogical-op) |
| 37 | warning-2 += $(call cc-option, -Wmissing-field-initializers) | 37 | warning-2 += $(call cc-option, -Wmissing-field-initializers) |
| 38 | warning-2 += $(call cc-option, -Wsign-compare) | 38 | warning-2 += $(call cc-option, -Wsign-compare) |
| 39 | warning-2 += $(call cc-option, -Wmaybe-uninitialized) | ||
| 39 | 40 | ||
| 40 | warning-3 := -Wbad-function-cast | 41 | warning-3 := -Wbad-function-cast |
| 41 | warning-3 += -Wcast-qual | 42 | warning-3 += -Wcast-qual |
diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan index dd779c40c8e6..3b1b13818d59 100644 --- a/scripts/Makefile.ubsan +++ b/scripts/Makefile.ubsan | |||
| @@ -17,4 +17,8 @@ endif | |||
| 17 | ifdef CONFIG_UBSAN_NULL | 17 | ifdef CONFIG_UBSAN_NULL |
| 18 | CFLAGS_UBSAN += $(call cc-option, -fsanitize=null) | 18 | CFLAGS_UBSAN += $(call cc-option, -fsanitize=null) |
| 19 | endif | 19 | endif |
| 20 | |||
| 21 | # -fsanitize=* options makes GCC less smart than usual and | ||
| 22 | # increase number of 'maybe-uninitialized false-positives | ||
| 23 | CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized) | ||
| 20 | endif | 24 | endif |
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index 19f5adfd877d..d9ff038c1b28 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter | |||
| @@ -8,6 +8,9 @@ | |||
| 8 | # of the GNU General Public License, incorporated herein by reference. | 8 | # of the GNU General Public License, incorporated herein by reference. |
| 9 | 9 | ||
| 10 | import sys, os, re | 10 | import sys, os, re |
| 11 | from signal import signal, SIGPIPE, SIG_DFL | ||
| 12 | |||
| 13 | signal(SIGPIPE, SIG_DFL) | ||
| 11 | 14 | ||
| 12 | if len(sys.argv) != 3: | 15 | if len(sys.argv) != 3: |
| 13 | sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0]) | 16 | sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0]) |
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh index 973e8c141567..17867e723a51 100755 --- a/scripts/gcc-x86_64-has-stack-protector.sh +++ b/scripts/gcc-x86_64-has-stack-protector.sh | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs" | 3 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs" |
| 4 | if [ "$?" -eq "0" ] ; then | 4 | if [ "$?" -eq "0" ] ; then |
| 5 | echo y | 5 | echo y |
| 6 | else | 6 | else |
