diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.build | 13 | ||||
-rw-r--r-- | scripts/Makefile.lib | 14 | ||||
-rw-r--r-- | scripts/bin_size | 10 | ||||
-rw-r--r-- | scripts/gcc-x86_32-has-stack-protector.sh | 8 | ||||
-rw-r--r-- | scripts/gcc-x86_64-has-stack-protector.sh | 6 | ||||
-rw-r--r-- | scripts/gen_initramfs_list.sh | 18 | ||||
-rw-r--r-- | scripts/headers_check.pl | 2 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 5 | ||||
-rwxr-xr-x | scripts/recordmcount.pl | 37 |
9 files changed, 92 insertions, 21 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index c7de8b39fcf1..39a9642927d3 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -112,13 +112,13 @@ endif | |||
112 | # --------------------------------------------------------------------------- | 112 | # --------------------------------------------------------------------------- |
113 | 113 | ||
114 | # Default is built-in, unless we know otherwise | 114 | # Default is built-in, unless we know otherwise |
115 | modkern_cflags := $(CFLAGS_KERNEL) | 115 | modkern_cflags = $(if $(part-of-module), $(CFLAGS_MODULE), $(CFLAGS_KERNEL)) |
116 | quiet_modtag := $(empty) $(empty) | 116 | quiet_modtag := $(empty) $(empty) |
117 | 117 | ||
118 | $(real-objs-m) : modkern_cflags := $(CFLAGS_MODULE) | 118 | $(real-objs-m) : part-of-module := y |
119 | $(real-objs-m:.o=.i) : modkern_cflags := $(CFLAGS_MODULE) | 119 | $(real-objs-m:.o=.i) : part-of-module := y |
120 | $(real-objs-m:.o=.s) : modkern_cflags := $(CFLAGS_MODULE) | 120 | $(real-objs-m:.o=.s) : part-of-module := y |
121 | $(real-objs-m:.o=.lst): modkern_cflags := $(CFLAGS_MODULE) | 121 | $(real-objs-m:.o=.lst): part-of-module := y |
122 | 122 | ||
123 | $(real-objs-m) : quiet_modtag := [M] | 123 | $(real-objs-m) : quiet_modtag := [M] |
124 | $(real-objs-m:.o=.i) : quiet_modtag := [M] | 124 | $(real-objs-m:.o=.i) : quiet_modtag := [M] |
@@ -205,7 +205,8 @@ endif | |||
205 | ifdef CONFIG_FTRACE_MCOUNT_RECORD | 205 | ifdef CONFIG_FTRACE_MCOUNT_RECORD |
206 | cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ | 206 | cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ |
207 | "$(if $(CONFIG_64BIT),64,32)" \ | 207 | "$(if $(CONFIG_64BIT),64,32)" \ |
208 | "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" "$(@)"; | 208 | "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ |
209 | "$(if $(part-of-module),1,0)" "$(@)"; | ||
209 | endif | 210 | endif |
210 | 211 | ||
211 | define rule_cc_o_c | 212 | define rule_cc_o_c |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index e06365775bdf..3b949a354470 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -186,3 +186,17 @@ quiet_cmd_gzip = GZIP $@ | |||
186 | cmd_gzip = gzip -f -9 < $< > $@ | 186 | cmd_gzip = gzip -f -9 < $< > $@ |
187 | 187 | ||
188 | 188 | ||
189 | # Bzip2 | ||
190 | # --------------------------------------------------------------------------- | ||
191 | |||
192 | # Bzip2 does not include size in file... so we have to fake that | ||
193 | size_append=$(CONFIG_SHELL) $(srctree)/scripts/bin_size | ||
194 | |||
195 | quiet_cmd_bzip2 = BZIP2 $@ | ||
196 | cmd_bzip2 = (bzip2 -9 < $< && $(size_append) $<) > $@ || (rm -f $@ ; false) | ||
197 | |||
198 | # Lzma | ||
199 | # --------------------------------------------------------------------------- | ||
200 | |||
201 | quiet_cmd_lzma = LZMA $@ | ||
202 | cmd_lzma = (lzma -9 -c $< && $(size_append) $<) >$@ || (rm -f $@ ; false) | ||
diff --git a/scripts/bin_size b/scripts/bin_size new file mode 100644 index 000000000000..43e1b360cee6 --- /dev/null +++ b/scripts/bin_size | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if [ $# = 0 ] ; then | ||
4 | echo Usage: $0 file | ||
5 | fi | ||
6 | |||
7 | size_dec=`stat -c "%s" $1` | ||
8 | size_hex_echo_string=`printf "%08x" $size_dec | | ||
9 | sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g'` | ||
10 | /bin/echo -ne $size_hex_echo_string | ||
diff --git a/scripts/gcc-x86_32-has-stack-protector.sh b/scripts/gcc-x86_32-has-stack-protector.sh new file mode 100644 index 000000000000..29493dc4528d --- /dev/null +++ b/scripts/gcc-x86_32-has-stack-protector.sh | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -xc -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" | ||
4 | if [ "$?" -eq "0" ] ; then | ||
5 | echo y | ||
6 | else | ||
7 | echo n | ||
8 | fi | ||
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh index 325c0a1b03b6..afaec618b395 100644 --- a/scripts/gcc-x86_64-has-stack-protector.sh +++ b/scripts/gcc-x86_64-has-stack-protector.sh | |||
@@ -1,6 +1,8 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | echo "int foo(void) { char X[200]; return 3; }" | $1 -S -xc -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs" | 3 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -xc -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs" |
4 | if [ "$?" -eq "0" ] ; then | 4 | if [ "$?" -eq "0" ] ; then |
5 | echo $2 | 5 | echo y |
6 | else | ||
7 | echo n | ||
6 | fi | 8 | fi |
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh index 5f3415f28736..3eea8f15131b 100644 --- a/scripts/gen_initramfs_list.sh +++ b/scripts/gen_initramfs_list.sh | |||
@@ -5,7 +5,7 @@ | |||
5 | # Released under the terms of the GNU GPL | 5 | # Released under the terms of the GNU GPL |
6 | # | 6 | # |
7 | # Generate a cpio packed initramfs. It uses gen_init_cpio to generate | 7 | # Generate a cpio packed initramfs. It uses gen_init_cpio to generate |
8 | # the cpio archive, and gzip to pack it. | 8 | # the cpio archive, and then compresses it. |
9 | # The script may also be used to generate the inputfile used for gen_init_cpio | 9 | # The script may also be used to generate the inputfile used for gen_init_cpio |
10 | # This script assumes that gen_init_cpio is located in usr/ directory | 10 | # This script assumes that gen_init_cpio is located in usr/ directory |
11 | 11 | ||
@@ -16,8 +16,8 @@ usage() { | |||
16 | cat << EOF | 16 | cat << EOF |
17 | Usage: | 17 | Usage: |
18 | $0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ... | 18 | $0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ... |
19 | -o <file> Create gzipped initramfs file named <file> using | 19 | -o <file> Create compressed initramfs file named <file> using |
20 | gen_init_cpio and gzip | 20 | gen_init_cpio and compressor depending on the extension |
21 | -u <uid> User ID to map to user ID 0 (root). | 21 | -u <uid> User ID to map to user ID 0 (root). |
22 | <uid> is only meaningful if <cpio_source> is a | 22 | <uid> is only meaningful if <cpio_source> is a |
23 | directory. "squash" forces all files to uid 0. | 23 | directory. "squash" forces all files to uid 0. |
@@ -225,6 +225,7 @@ cpio_list= | |||
225 | output="/dev/stdout" | 225 | output="/dev/stdout" |
226 | output_file="" | 226 | output_file="" |
227 | is_cpio_compressed= | 227 | is_cpio_compressed= |
228 | compr="gzip -9 -f" | ||
228 | 229 | ||
229 | arg="$1" | 230 | arg="$1" |
230 | case "$arg" in | 231 | case "$arg" in |
@@ -233,11 +234,15 @@ case "$arg" in | |||
233 | echo "deps_initramfs := \\" | 234 | echo "deps_initramfs := \\" |
234 | shift | 235 | shift |
235 | ;; | 236 | ;; |
236 | "-o") # generate gzipped cpio image named $1 | 237 | "-o") # generate compressed cpio image named $1 |
237 | shift | 238 | shift |
238 | output_file="$1" | 239 | output_file="$1" |
239 | cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)" | 240 | cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)" |
240 | output=${cpio_list} | 241 | output=${cpio_list} |
242 | echo "$output_file" | grep -q "\.gz$" && compr="gzip -9 -f" | ||
243 | echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f" | ||
244 | echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f" | ||
245 | echo "$output_file" | grep -q "\.cpio$" && compr="cat" | ||
241 | shift | 246 | shift |
242 | ;; | 247 | ;; |
243 | esac | 248 | esac |
@@ -274,7 +279,7 @@ while [ $# -gt 0 ]; do | |||
274 | esac | 279 | esac |
275 | done | 280 | done |
276 | 281 | ||
277 | # If output_file is set we will generate cpio archive and gzip it | 282 | # If output_file is set we will generate cpio archive and compress it |
278 | # we are carefull to delete tmp files | 283 | # we are carefull to delete tmp files |
279 | if [ ! -z ${output_file} ]; then | 284 | if [ ! -z ${output_file} ]; then |
280 | if [ -z ${cpio_file} ]; then | 285 | if [ -z ${cpio_file} ]; then |
@@ -287,7 +292,8 @@ if [ ! -z ${output_file} ]; then | |||
287 | if [ "${is_cpio_compressed}" = "compressed" ]; then | 292 | if [ "${is_cpio_compressed}" = "compressed" ]; then |
288 | cat ${cpio_tfile} > ${output_file} | 293 | cat ${cpio_tfile} > ${output_file} |
289 | else | 294 | else |
290 | cat ${cpio_tfile} | gzip -f -9 - > ${output_file} | 295 | (cat ${cpio_tfile} | ${compr} - > ${output_file}) \ |
296 | || (rm -f ${output_file} ; false) | ||
291 | fi | 297 | fi |
292 | [ -z ${cpio_file} ] && rm ${cpio_tfile} | 298 | [ -z ${cpio_file} ] && rm ${cpio_tfile} |
293 | fi | 299 | fi |
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl index db30fac3083e..56f90a480899 100644 --- a/scripts/headers_check.pl +++ b/scripts/headers_check.pl | |||
@@ -38,7 +38,7 @@ foreach my $file (@files) { | |||
38 | &check_asm_types(); | 38 | &check_asm_types(); |
39 | &check_sizetypes(); | 39 | &check_sizetypes(); |
40 | &check_prototypes(); | 40 | &check_prototypes(); |
41 | &check_config(); | 41 | # Dropped for now. Too much noise &check_config(); |
42 | } | 42 | } |
43 | close FH; | 43 | close FH; |
44 | } | 44 | } |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 88921611b22e..7e62303133dc 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -415,8 +415,9 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
415 | const char *secstrings | 415 | const char *secstrings |
416 | = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; | 416 | = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; |
417 | const char *secname; | 417 | const char *secname; |
418 | int nobits = sechdrs[i].sh_type == SHT_NOBITS; | ||
418 | 419 | ||
419 | if (sechdrs[i].sh_offset > info->size) { | 420 | if (!nobits && sechdrs[i].sh_offset > info->size) { |
420 | fatal("%s is truncated. sechdrs[i].sh_offset=%lu > " | 421 | fatal("%s is truncated. sechdrs[i].sh_offset=%lu > " |
421 | "sizeof(*hrd)=%zu\n", filename, | 422 | "sizeof(*hrd)=%zu\n", filename, |
422 | (unsigned long)sechdrs[i].sh_offset, | 423 | (unsigned long)sechdrs[i].sh_offset, |
@@ -425,6 +426,8 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
425 | } | 426 | } |
426 | secname = secstrings + sechdrs[i].sh_name; | 427 | secname = secstrings + sechdrs[i].sh_name; |
427 | if (strcmp(secname, ".modinfo") == 0) { | 428 | if (strcmp(secname, ".modinfo") == 0) { |
429 | if (nobits) | ||
430 | fatal("%s has NOBITS .modinfo\n", filename); | ||
428 | info->modinfo = (void *)hdr + sechdrs[i].sh_offset; | 431 | info->modinfo = (void *)hdr + sechdrs[i].sh_offset; |
429 | info->modinfo_len = sechdrs[i].sh_size; | 432 | info->modinfo_len = sechdrs[i].sh_size; |
430 | } else if (strcmp(secname, "__ksymtab") == 0) | 433 | } else if (strcmp(secname, "__ksymtab") == 0) |
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index fe831412bea9..409596eca124 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl | |||
@@ -100,14 +100,19 @@ $P =~ s@.*/@@g; | |||
100 | 100 | ||
101 | my $V = '0.1'; | 101 | my $V = '0.1'; |
102 | 102 | ||
103 | if ($#ARGV < 6) { | 103 | if ($#ARGV < 7) { |
104 | print "usage: $P arch objdump objcopy cc ld nm rm mv inputfile\n"; | 104 | print "usage: $P arch bits objdump objcopy cc ld nm rm mv is_module inputfile\n"; |
105 | print "version: $V\n"; | 105 | print "version: $V\n"; |
106 | exit(1); | 106 | exit(1); |
107 | } | 107 | } |
108 | 108 | ||
109 | my ($arch, $bits, $objdump, $objcopy, $cc, | 109 | my ($arch, $bits, $objdump, $objcopy, $cc, |
110 | $ld, $nm, $rm, $mv, $inputfile) = @ARGV; | 110 | $ld, $nm, $rm, $mv, $is_module, $inputfile) = @ARGV; |
111 | |||
112 | # This file refers to mcount and shouldn't be ftraced, so lets' ignore it | ||
113 | if ($inputfile eq "kernel/trace/ftrace.o") { | ||
114 | exit(0); | ||
115 | } | ||
111 | 116 | ||
112 | # Acceptable sections to record. | 117 | # Acceptable sections to record. |
113 | my %text_sections = ( | 118 | my %text_sections = ( |
@@ -201,6 +206,13 @@ if ($arch eq "x86_64") { | |||
201 | $alignment = 2; | 206 | $alignment = 2; |
202 | $section_type = '%progbits'; | 207 | $section_type = '%progbits'; |
203 | 208 | ||
209 | } elsif ($arch eq "ia64") { | ||
210 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; | ||
211 | $type = "data8"; | ||
212 | |||
213 | if ($is_module eq "0") { | ||
214 | $cc .= " -mconstant-gp"; | ||
215 | } | ||
204 | } else { | 216 | } else { |
205 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; | 217 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; |
206 | } | 218 | } |
@@ -263,7 +275,6 @@ if (!$found_version) { | |||
263 | "\tDisabling local function references.\n"; | 275 | "\tDisabling local function references.\n"; |
264 | } | 276 | } |
265 | 277 | ||
266 | |||
267 | # | 278 | # |
268 | # Step 1: find all the local (static functions) and weak symbols. | 279 | # Step 1: find all the local (static functions) and weak symbols. |
269 | # 't' is local, 'w/W' is weak (we never use a weak function) | 280 | # 't' is local, 'w/W' is weak (we never use a weak function) |
@@ -331,13 +342,16 @@ sub update_funcs | |||
331 | # | 342 | # |
332 | # Step 2: find the sections and mcount call sites | 343 | # Step 2: find the sections and mcount call sites |
333 | # | 344 | # |
334 | open(IN, "$objdump -dr $inputfile|") || die "error running $objdump"; | 345 | open(IN, "$objdump -hdr $inputfile|") || die "error running $objdump"; |
335 | 346 | ||
336 | my $text; | 347 | my $text; |
337 | 348 | ||
349 | my $read_headers = 1; | ||
350 | |||
338 | while (<IN>) { | 351 | while (<IN>) { |
339 | # is it a section? | 352 | # is it a section? |
340 | if (/$section_regex/) { | 353 | if (/$section_regex/) { |
354 | $read_headers = 0; | ||
341 | 355 | ||
342 | # Only record text sections that we know are safe | 356 | # Only record text sections that we know are safe |
343 | if (defined($text_sections{$1})) { | 357 | if (defined($text_sections{$1})) { |
@@ -371,6 +385,19 @@ while (<IN>) { | |||
371 | $ref_func = $text; | 385 | $ref_func = $text; |
372 | } | 386 | } |
373 | } | 387 | } |
388 | } elsif ($read_headers && /$mcount_section/) { | ||
389 | # | ||
390 | # Somehow the make process can execute this script on an | ||
391 | # object twice. If it does, we would duplicate the mcount | ||
392 | # section and it will cause the function tracer self test | ||
393 | # to fail. Check if the mcount section exists, and if it does, | ||
394 | # warn and exit. | ||
395 | # | ||
396 | print STDERR "ERROR: $mcount_section already in $inputfile\n" . | ||
397 | "\tThis may be an indication that your build is corrupted.\n" . | ||
398 | "\tDelete $inputfile and try again. If the same object file\n" . | ||
399 | "\tstill causes an issue, then disable CONFIG_DYNAMIC_FTRACE.\n"; | ||
400 | exit(-1); | ||
374 | } | 401 | } |
375 | 402 | ||
376 | # is this a call site to mcount? If so, record it to print later | 403 | # is this a call site to mcount? If so, record it to print later |