aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/Makefile.lib14
-rw-r--r--scripts/binoffset.c163
-rwxr-xr-xscripts/checkpatch.pl2
-rwxr-xr-xscripts/extract-ikconfig127
-rwxr-xr-xscripts/get_maintainer.pl88
-rw-r--r--scripts/markup_oops.pl4
-rw-r--r--scripts/mod/file2alias.c2
-rwxr-xr-xscripts/recordmcount.pl2
9 files changed, 117 insertions, 286 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 52cab46ae35a..c5d5db54c009 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -6,5 +6,4 @@ kallsyms
6pnmtologo 6pnmtologo
7bin2c 7bin2c
8unifdef 8unifdef
9binoffset
10ihex2fw 9ihex2fw
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index cd815ac2a50b..f9bdf264473d 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -219,8 +219,13 @@ for F in $1; do \
219 fsize=$$(stat -c "%s" $$F); \ 219 fsize=$$(stat -c "%s" $$F); \
220 dec_size=$$(expr $$dec_size + $$fsize); \ 220 dec_size=$$(expr $$dec_size + $$fsize); \
221done; \ 221done; \
222printf "%08x" $$dec_size | \ 222printf "%08x\n" $$dec_size | \
223 sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g' \ 223 sed 's/\(..\)/\1 /g' | { \
224 read ch0 ch1 ch2 ch3; \
225 for ch in $$ch3 $$ch2 $$ch1 $$ch0; do \
226 printf '%s%03o' '\\' $$((0x$$ch)); \
227 done; \
228 } \
224) 229)
225 230
226quiet_cmd_bzip2 = BZIP2 $@ 231quiet_cmd_bzip2 = BZIP2 $@
@@ -235,3 +240,8 @@ quiet_cmd_lzma = LZMA $@
235cmd_lzma = (cat $(filter-out FORCE,$^) | \ 240cmd_lzma = (cat $(filter-out FORCE,$^) | \
236 lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ 241 lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
237 (rm -f $@ ; false) 242 (rm -f $@ ; false)
243
244quiet_cmd_lzo = LZO $@
245cmd_lzo = (cat $(filter-out FORCE,$^) | \
246 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
247 (rm -f $@ ; false)
diff --git a/scripts/binoffset.c b/scripts/binoffset.c
deleted file mode 100644
index 1a2e39b8e3e5..000000000000
--- a/scripts/binoffset.c
+++ /dev/null
@@ -1,163 +0,0 @@
1/***************************************************************************
2 * binoffset.c
3 * (C) 2002 Randy Dunlap <rdunlap@xenotime.net>
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19# binoffset.c:
20# - searches a (binary) file for a specified (binary) pattern
21# - returns the offset of the located pattern or ~0 if not found
22# - exits with exit status 0 normally or non-0 if pattern is not found
23# or any other error occurs.
24
25****************************************************************/
26
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <errno.h>
31#include <unistd.h>
32#include <fcntl.h>
33#include <sys/types.h>
34#include <sys/stat.h>
35#include <sys/mman.h>
36
37#define VERSION "0.1"
38#define BUF_SIZE (16 * 1024)
39#define PAT_SIZE 100
40
41char *progname;
42char *inputname;
43int inputfd;
44unsigned int bix; /* buf index */
45unsigned char patterns [PAT_SIZE] = {0}; /* byte-sized pattern array */
46int pat_len; /* actual number of pattern bytes */
47unsigned char *madr; /* mmap address */
48size_t filesize;
49int num_matches = 0;
50off_t firstloc = 0;
51
52void usage (void)
53{
54 fprintf (stderr, "%s ver. %s\n", progname, VERSION);
55 fprintf (stderr, "usage: %s filename pattern_bytes\n",
56 progname);
57 fprintf (stderr, " [prints location of pattern_bytes in file]\n");
58 exit (1);
59}
60
61void get_pattern (int pat_count, char *pats [])
62{
63 int ix, err, tmp;
64
65#ifdef DEBUG
66 fprintf (stderr,"get_pattern: count = %d\n", pat_count);
67 for (ix = 0; ix < pat_count; ix++)
68 fprintf (stderr, " pat # %d: [%s]\n", ix, pats[ix]);
69#endif
70
71 for (ix = 0; ix < pat_count; ix++) {
72 tmp = 0;
73 err = sscanf (pats[ix], "%5i", &tmp);
74 if (err != 1 || tmp > 0xff) {
75 fprintf (stderr, "pattern or value error in pattern # %d [%s]\n",
76 ix, pats[ix]);
77 usage ();
78 }
79 patterns [ix] = tmp;
80 }
81 pat_len = pat_count;
82}
83
84void search_pattern (void)
85{
86 for (bix = 0; bix < filesize; bix++) {
87 if (madr[bix] == patterns[0]) {
88 if (memcmp (&madr[bix], patterns, pat_len) == 0) {
89 if (num_matches == 0)
90 firstloc = bix;
91 num_matches++;
92 }
93 }
94 }
95}
96
97#ifdef NOTDEF
98size_t get_filesize (int fd)
99{
100 off_t end_off = lseek (fd, 0, SEEK_END);
101 lseek (fd, 0, SEEK_SET);
102 return (size_t) end_off;
103}
104#endif
105
106size_t get_filesize (int fd)
107{
108 int err;
109 struct stat stat;
110
111 err = fstat (fd, &stat);
112 fprintf (stderr, "filesize: %ld\n", err < 0 ? (long)err : stat.st_size);
113 if (err < 0)
114 return err;
115 return (size_t) stat.st_size;
116}
117
118int main (int argc, char *argv [])
119{
120 progname = argv[0];
121
122 if (argc < 3)
123 usage ();
124
125 get_pattern (argc - 2, argv + 2);
126
127 inputname = argv[1];
128
129 inputfd = open (inputname, O_RDONLY);
130 if (inputfd == -1) {
131 fprintf (stderr, "%s: cannot open '%s'\n",
132 progname, inputname);
133 exit (3);
134 }
135
136 filesize = get_filesize (inputfd);
137
138 madr = mmap (0, filesize, PROT_READ, MAP_PRIVATE, inputfd, 0);
139 if (madr == MAP_FAILED) {
140 fprintf (stderr, "mmap error = %d\n", errno);
141 close (inputfd);
142 exit (4);
143 }
144
145 search_pattern ();
146
147 if (munmap (madr, filesize))
148 fprintf (stderr, "munmap error = %d\n", errno);
149
150 if (close (inputfd))
151 fprintf (stderr, "%s: error %d closing '%s'\n",
152 progname, errno, inputname);
153
154 fprintf (stderr, "number of pattern matches = %d\n", num_matches);
155 if (num_matches == 0)
156 firstloc = ~0;
157 printf ("%ld\n", firstloc);
158 fprintf (stderr, "%ld\n", firstloc);
159
160 exit (num_matches ? 0 : 2);
161}
162
163/* end binoffset.c */
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bc4114f1ab30..3257d3d96767 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1,5 +1,5 @@
1#!/usr/bin/perl -w 1#!/usr/bin/perl -w
2# (c) 2001, Dave Jones. <davej@redhat.com> (the file handling bit) 2# (c) 2001, Dave Jones. (the file handling bit)
3# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit) 3# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
4# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite) 4# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite)
5# (c) 2008,2009, Andy Whitcroft <apw@canonical.com> 5# (c) 2008,2009, Andy Whitcroft <apw@canonical.com>
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index de233ff43c1c..37f30d36c944 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -1,92 +1,53 @@
1#!/bin/sh 1#!/bin/sh
2# extracts .config info from a [b]zImage file 2# ----------------------------------------------------------------------
3# uses: binoffset (new), dd, zcat, strings, grep 3# extract-ikconfig - Extract the .config file from a kernel image
4# $arg1 is [b]zImage filename 4#
5 5# This will only work when the kernel was compiled with CONFIG_IKCONFIG.
6binoffset="./scripts/binoffset" 6#
7test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1 7# The obscure use of the "tr" filter is to work around older versions of
8 8# "grep" that report the byte offset of the line instead of the pattern.
9IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54" 9#
10IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44" 10# (c) 2009, Dick Streefland <dick@streefland.net>
11dump_config() { 11# Licensed under the terms of the GNU General Public License.
12 file="$1" 12# ----------------------------------------------------------------------
13 13
14 start=`$binoffset $file $IKCFG_ST 2>/dev/null` 14gz1='\037\213\010'
15 [ "$?" != "0" ] && start="-1" 15gz2='01'
16 if [ "$start" -eq "-1" ]; then 16cf1='IKCFG_ST\037\213\010'
17 return 17cf2='0123456789'
18 fi 18
19 end=`$binoffset $file $IKCFG_ED 2>/dev/null` 19dump_config()
20 [ "$?" != "0" ] && end="-1"
21 if [ "$end" -eq "-1" ]; then
22 return
23 fi
24
25 start=`expr $start + 8`
26 size=`expr $end - $start`
27
28 dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
29
30 clean_up
31 exit 0
32}
33
34
35usage()
36{
37 echo " usage: extract-ikconfig [b]zImage_filename"
38}
39
40clean_up()
41{ 20{
42 if [ "$TMPFILE" != "" ]; then 21 if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"`
43 rm -f $TMPFILE 22 then
23 pos=${pos%%:*}
24 tail -c+$(($pos+8)) "$1" | zcat -q
25 exit 0
44 fi 26 fi
45} 27}
46 28
47if [ $# -lt 1 ] 29# Check invocation:
30me=${0##*/}
31img=$1
32if [ $# -ne 1 -o ! -s "$img" ]
48then 33then
49 usage 34 echo "Usage: $me <kernel-image>" >&2
50 exit 1 35 exit 2
51fi 36fi
52 37
53TMPFILE=`mktemp -t ikconfig-XXXXXX` || exit 1 38# Initial attempt for uncompressed images or objects:
54image="$1" 39dump_config "$img"
55 40
56# vmlinux: Attempt to dump the configuration from the file directly 41# That didn't work, so decompress and try again:
57dump_config "$image" 42tmp=/tmp/ikconfig$$
58 43trap "rm -f $tmp" 0
59GZHDR1="0x1f 0x8b 0x08 0x00" 44for pos in `tr "$gz1\n$gz2" "\n$gz2=" < "$img" | grep -abo "^$gz2"`
60GZHDR2="0x1f 0x8b 0x08 0x08" 45do
61 46 pos=${pos%%:*}
62ELFHDR="0x7f 0x45 0x4c 0x46" 47 tail -c+$pos "$img" | zcat 2> /dev/null > $tmp
63 48 dump_config $tmp
64# vmlinux.gz: Check for a compressed images 49done
65off=`$binoffset "$image" $GZHDR1 2>/dev/null` 50
66[ "$?" != "0" ] && off="-1" 51# Bail out:
67if [ "$off" -eq "-1" ]; then 52echo "$me: Cannot find kernel config." >&2
68 off=`$binoffset "$image" $GZHDR2 2>/dev/null`
69 [ "$?" != "0" ] && off="-1"
70fi
71if [ "$off" -eq "0" ]; then
72 zcat <"$image" >"$TMPFILE"
73 dump_config "$TMPFILE"
74elif [ "$off" -ne "-1" ]; then
75 (dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \
76 zcat >"$TMPFILE"
77 dump_config "$TMPFILE"
78
79# check if this is simply an ELF file
80else
81 off=`$binoffset "$image" $ELFHDR 2>/dev/null`
82 [ "$?" != "0" ] && off="-1"
83 if [ "$off" -eq "0" ]; then
84 dump_config "$image"
85 fi
86fi
87
88echo "ERROR: Unable to extract kernel configuration information."
89echo " This kernel image may not have the config info."
90
91clean_up
92exit 1 53exit 1
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 445e8845f0a4..2f3230db7ffb 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -74,8 +74,8 @@ my %VCS_cmds;
74my %VCS_cmds_git = ( 74my %VCS_cmds_git = (
75 "execute_cmd" => \&git_execute_cmd, 75 "execute_cmd" => \&git_execute_cmd,
76 "available" => '(which("git") ne "") && (-d ".git")', 76 "available" => '(which("git") ne "") && (-d ".git")',
77 "find_signers_cmd" => "git log --since=\$email_git_since -- \$file", 77 "find_signers_cmd" => "git log --no-color --since=\$email_git_since -- \$file",
78 "find_commit_signers_cmd" => "git log -1 \$commit", 78 "find_commit_signers_cmd" => "git log --no-color -1 \$commit",
79 "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file", 79 "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file",
80 "blame_file_cmd" => "git blame -l \$file", 80 "blame_file_cmd" => "git blame -l \$file",
81 "commit_pattern" => "^commit [0-9a-f]{40,40}", 81 "commit_pattern" => "^commit [0-9a-f]{40,40}",
@@ -296,46 +296,56 @@ my @status = ();
296 296
297foreach my $file (@files) { 297foreach my $file (@files) {
298 298
299#Do not match excluded file patterns 299 my %hash;
300 300 my $tvi = find_first_section();
301 my $exclude = 0; 301 while ($tvi < @typevalue) {
302 foreach my $line (@typevalue) { 302 my $start = find_starting_index($tvi);
303 if ($line =~ m/^(\C):\s*(.*)/) { 303 my $end = find_ending_index($tvi);
304 my $type = $1; 304 my $exclude = 0;
305 my $value = $2; 305 my $i;
306 if ($type eq 'X') { 306
307 if (file_match_pattern($file, $value)) { 307 #Do not match excluded file patterns
308 $exclude = 1;
309 last;
310 }
311 }
312 }
313 }
314 308
315 if (!$exclude) { 309 for ($i = $start; $i < $end; $i++) {
316 my $tvi = 0; 310 my $line = $typevalue[$i];
317 my %hash;
318 foreach my $line (@typevalue) {
319 if ($line =~ m/^(\C):\s*(.*)/) { 311 if ($line =~ m/^(\C):\s*(.*)/) {
320 my $type = $1; 312 my $type = $1;
321 my $value = $2; 313 my $value = $2;
322 if ($type eq 'F') { 314 if ($type eq 'X') {
323 if (file_match_pattern($file, $value)) { 315 if (file_match_pattern($file, $value)) {
324 my $value_pd = ($value =~ tr@/@@); 316 $exclude = 1;
325 my $file_pd = ($file =~ tr@/@@);
326 $value_pd++ if (substr($value,-1,1) ne "/");
327 if ($pattern_depth == 0 ||
328 (($file_pd - $value_pd) < $pattern_depth)) {
329 $hash{$tvi} = $value_pd;
330 }
331 } 317 }
332 } 318 }
333 } 319 }
334 $tvi++;
335 } 320 }
336 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { 321
337 add_categories($line); 322 if (!$exclude) {
323 for ($i = $start; $i < $end; $i++) {
324 my $line = $typevalue[$i];
325 if ($line =~ m/^(\C):\s*(.*)/) {
326 my $type = $1;
327 my $value = $2;
328 if ($type eq 'F') {
329 if (file_match_pattern($file, $value)) {
330 my $value_pd = ($value =~ tr@/@@);
331 my $file_pd = ($file =~ tr@/@@);
332 $value_pd++ if (substr($value,-1,1) ne "/");
333 if ($pattern_depth == 0 ||
334 (($file_pd - $value_pd) < $pattern_depth)) {
335 $hash{$tvi} = $value_pd;
336 }
337 }
338 }
339 }
340 }
338 } 341 }
342
343 $tvi += ($end - $start);
344
345 }
346
347 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
348 add_categories($line);
339 } 349 }
340 350
341 if ($email && $email_git) { 351 if ($email && $email_git) {
@@ -570,6 +580,20 @@ sub format_email {
570 return $formatted_email; 580 return $formatted_email;
571} 581}
572 582
583sub find_first_section {
584 my $index = 0;
585
586 while ($index < @typevalue) {
587 my $tv = $typevalue[$index];
588 if (($tv =~ m/^(\C):\s*(.*)/)) {
589 last;
590 }
591 $index++;
592 }
593
594 return $index;
595}
596
573sub find_starting_index { 597sub find_starting_index {
574 my ($index) = @_; 598 my ($index) = @_;
575 599
diff --git a/scripts/markup_oops.pl b/scripts/markup_oops.pl
index 5f0fcb712e29..e950f9cde019 100644
--- a/scripts/markup_oops.pl
+++ b/scripts/markup_oops.pl
@@ -154,11 +154,11 @@ while (<STDIN>) {
154 if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) { 154 if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) {
155 $target = $1; 155 $target = $1;
156 } 156 }
157 if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) { 157 if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/0x[a-f0-9]/) {
158 $function = $1; 158 $function = $1;
159 $func_offset = $2; 159 $func_offset = $2;
160 } 160 }
161 if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) { 161 if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/0x[a-f0-9]/) {
162 $function = $1; 162 $function = $1;
163 $func_offset = $2; 163 $func_offset = $2;
164 } 164 }
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 6f426afbc522..220213e603db 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -804,7 +804,7 @@ static inline int sym_is(const char *symbol, const char *name)
804 match = strstr(symbol, name); 804 match = strstr(symbol, name);
805 if (!match) 805 if (!match)
806 return 0; 806 return 0;
807 return match[strlen(symbol)] == '\0'; 807 return match[strlen(name)] == '\0';
808} 808}
809 809
810static void do_table(void *symval, unsigned long size, 810static void do_table(void *symval, unsigned long size,
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 92f09fe9639e..ea6f6e3adaea 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -194,7 +194,7 @@ sub check_objcopy
194 } 194 }
195} 195}
196 196
197if ($arch eq "x86") { 197if ($arch =~ /(x86(_64)?)|(i386)/) {
198 if ($bits == 64) { 198 if ($bits == 64) {
199 $arch = "x86_64"; 199 $arch = "x86_64";
200 } else { 200 } else {