aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl166
-rw-r--r--scripts/docproc.c14
-rw-r--r--scripts/gen_initramfs_list.sh24
-rwxr-xr-xscripts/kernel-doc6
-rw-r--r--scripts/mod/modpost.c15
-rw-r--r--scripts/package/Makefile4
-rw-r--r--scripts/sortextable.c24
-rw-r--r--scripts/sortextable.h26
8 files changed, 208 insertions, 71 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 66cad506b8a2..61090e0ff613 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -241,8 +241,11 @@ our $Sparse = qr{
241 __ref| 241 __ref|
242 __rcu 242 __rcu
243 }x; 243 }x;
244 244our $InitAttributePrefix = qr{__(?:mem|cpu|dev|net_|)};
245our $InitAttribute = qr{__(?:mem|cpu|dev|net_|)(?:initdata|initconst|init\b)}; 245our $InitAttributeData = qr{$InitAttributePrefix(?:initdata\b)};
246our $InitAttributeConst = qr{$InitAttributePrefix(?:initconst\b)};
247our $InitAttributeInit = qr{$InitAttributePrefix(?:init\b)};
248our $InitAttribute = qr{$InitAttributeData|$InitAttributeConst|$InitAttributeInit};
246 249
247# Notes to $Attribute: 250# Notes to $Attribute:
248# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check 251# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
@@ -323,7 +326,8 @@ our $logFunctions = qr{(?x:
323 (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)| 326 (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
324 WARN(?:_RATELIMIT|_ONCE|)| 327 WARN(?:_RATELIMIT|_ONCE|)|
325 panic| 328 panic|
326 MODULE_[A-Z_]+ 329 MODULE_[A-Z_]+|
330 seq_vprintf|seq_printf|seq_puts
327)}; 331)};
328 332
329our $signature_tags = qr{(?xi: 333our $signature_tags = qr{(?xi:
@@ -442,8 +446,9 @@ sub seed_camelcase_file {
442 next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/); 446 next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/);
443 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) { 447 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
444 $camelcase{$1} = 1; 448 $camelcase{$1} = 1;
445 } 449 } elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
446 elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*\(/) { 450 $camelcase{$1} = 1;
451 } elsif ($line =~ /^\s*(?:union|struct|enum)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[;\{]/) {
447 $camelcase{$1} = 1; 452 $camelcase{$1} = 1;
448 } 453 }
449 } 454 }
@@ -1512,6 +1517,14 @@ sub rtrim {
1512 return $string; 1517 return $string;
1513} 1518}
1514 1519
1520sub string_find_replace {
1521 my ($string, $find, $replace) = @_;
1522
1523 $string =~ s/$find/$replace/g;
1524
1525 return $string;
1526}
1527
1515sub tabify { 1528sub tabify {
1516 my ($leading) = @_; 1529 my ($leading) = @_;
1517 1530
@@ -1612,6 +1625,8 @@ sub process {
1612 my @setup_docs = (); 1625 my @setup_docs = ();
1613 my $setup_docs = 0; 1626 my $setup_docs = 0;
1614 1627
1628 my $camelcase_file_seeded = 0;
1629
1615 sanitise_line_reset(); 1630 sanitise_line_reset();
1616 my $line; 1631 my $line;
1617 foreach my $rawline (@rawlines) { 1632 foreach my $rawline (@rawlines) {
@@ -1754,11 +1769,11 @@ sub process {
1754 # extract the filename as it passes 1769 # extract the filename as it passes
1755 if ($line =~ /^diff --git.*?(\S+)$/) { 1770 if ($line =~ /^diff --git.*?(\S+)$/) {
1756 $realfile = $1; 1771 $realfile = $1;
1757 $realfile =~ s@^([^/]*)/@@; 1772 $realfile =~ s@^([^/]*)/@@ if (!$file);
1758 $in_commit_log = 0; 1773 $in_commit_log = 0;
1759 } elsif ($line =~ /^\+\+\+\s+(\S+)/) { 1774 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
1760 $realfile = $1; 1775 $realfile = $1;
1761 $realfile =~ s@^([^/]*)/@@; 1776 $realfile =~ s@^([^/]*)/@@ if (!$file);
1762 $in_commit_log = 0; 1777 $in_commit_log = 0;
1763 1778
1764 $p1_prefix = $1; 1779 $p1_prefix = $1;
@@ -1947,6 +1962,18 @@ sub process {
1947 $rpt_cleaners = 1; 1962 $rpt_cleaners = 1;
1948 } 1963 }
1949 1964
1965# Check for FSF mailing addresses.
1966 if ($rawline =~ /You should have received a copy/ ||
1967 $rawline =~ /write to the Free Software/ ||
1968 $rawline =~ /59 Temple Place/ ||
1969 $rawline =~ /51 Franklin Street/) {
1970 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1971 my $msg_type = \&ERROR;
1972 $msg_type = \&CHK if ($file);
1973 &{$msg_type}("FSF_MAILING_ADDRESS",
1974 "Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL.\n" . $herevet)
1975 }
1976
1950# check for Kconfig help text having a real description 1977# check for Kconfig help text having a real description
1951# Only applies when adding the entry originally, after that we do not have 1978# Only applies when adding the entry originally, after that we do not have
1952# sufficient context to determine whether it is indeed long enough. 1979# sufficient context to determine whether it is indeed long enough.
@@ -2838,7 +2865,7 @@ sub process {
2838 \+=|-=|\*=|\/=|%=|\^=|\|=|&=| 2865 \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
2839 =>|->|<<|>>|<|>|=|!|~| 2866 =>|->|<<|>>|<|>|=|!|~|
2840 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%| 2867 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
2841 \?|: 2868 \?:|\?|:
2842 }x; 2869 }x;
2843 my @elements = split(/($ops|;)/, $opline); 2870 my @elements = split(/($ops|;)/, $opline);
2844 2871
@@ -3061,15 +3088,13 @@ sub process {
3061 $ok = 1; 3088 $ok = 1;
3062 } 3089 }
3063 3090
3064 # Ignore ?: 3091 # messages are ERROR, but ?: are CHK
3065 if (($opv eq ':O' && $ca =~ /\?$/) ||
3066 ($op eq '?' && $cc =~ /^:/)) {
3067 $ok = 1;
3068 }
3069
3070 if ($ok == 0) { 3092 if ($ok == 0) {
3071 if (ERROR("SPACING", 3093 my $msg_type = \&ERROR;
3072 "spaces required around that '$op' $at\n" . $hereptr)) { 3094 $msg_type = \&CHK if (($op eq '?:' || $op eq '?' || $op eq ':') && $ctx =~ /VxV/);
3095
3096 if (&{$msg_type}("SPACING",
3097 "spaces required around that '$op' $at\n" . $hereptr)) {
3073 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; 3098 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
3074 if (defined $fix_elements[$n + 2]) { 3099 if (defined $fix_elements[$n + 2]) {
3075 $fix_elements[$n + 2] =~ s/^\s+//; 3100 $fix_elements[$n + 2] =~ s/^\s+//;
@@ -3208,21 +3233,10 @@ sub process {
3208 } 3233 }
3209 3234
3210# Return is not a function. 3235# Return is not a function.
3211 if (defined($stat) && $stat =~ /^.\s*return(\s*)(\(.*);/s) { 3236 if (defined($stat) && $stat =~ /^.\s*return(\s*)\(/s) {
3212 my $spacing = $1; 3237 my $spacing = $1;
3213 my $value = $2; 3238 if ($^V && $^V ge 5.10.0 &&
3214 3239 $stat =~ /^.\s*return\s*$balanced_parens\s*;\s*$/) {
3215 # Flatten any parentheses
3216 $value =~ s/\(/ \(/g;
3217 $value =~ s/\)/\) /g;
3218 while ($value =~ s/\[[^\[\]]*\]/1/ ||
3219 $value !~ /(?:$Ident|-?$Constant)\s*
3220 $Compare\s*
3221 (?:$Ident|-?$Constant)/x &&
3222 $value =~ s/\([^\(\)]*\)/1/) {
3223 }
3224#print "value<$value>\n";
3225 if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) {
3226 ERROR("RETURN_PARENTHESES", 3240 ERROR("RETURN_PARENTHESES",
3227 "return is not a function, parentheses are not required\n" . $herecurr); 3241 "return is not a function, parentheses are not required\n" . $herecurr);
3228 3242
@@ -3231,6 +3245,7 @@ sub process {
3231 "space required before the open parenthesis '('\n" . $herecurr); 3245 "space required before the open parenthesis '('\n" . $herecurr);
3232 } 3246 }
3233 } 3247 }
3248
3234# Return of what appears to be an errno should normally be -'ve 3249# Return of what appears to be an errno should normally be -'ve
3235 if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) { 3250 if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
3236 my $name = $1; 3251 my $name = $1;
@@ -3396,7 +3411,13 @@ sub process {
3396 while ($var =~ m{($Ident)}g) { 3411 while ($var =~ m{($Ident)}g) {
3397 my $word = $1; 3412 my $word = $1;
3398 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/); 3413 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
3399 seed_camelcase_includes() if ($check); 3414 if ($check) {
3415 seed_camelcase_includes();
3416 if (!$file && !$camelcase_file_seeded) {
3417 seed_camelcase_file($realfile);
3418 $camelcase_file_seeded = 1;
3419 }
3420 }
3400 if (!defined $camelcase{$word}) { 3421 if (!defined $camelcase{$word}) {
3401 $camelcase{$word} = 1; 3422 $camelcase{$word} = 1;
3402 CHK("CAMELCASE", 3423 CHK("CAMELCASE",
@@ -3725,14 +3746,6 @@ sub process {
3725 } 3746 }
3726 } 3747 }
3727 3748
3728sub string_find_replace {
3729 my ($string, $find, $replace) = @_;
3730
3731 $string =~ s/$find/$replace/g;
3732
3733 return $string;
3734}
3735
3736# check for bad placement of section $InitAttribute (e.g.: __initdata) 3749# check for bad placement of section $InitAttribute (e.g.: __initdata)
3737 if ($line =~ /(\b$InitAttribute\b)/) { 3750 if ($line =~ /(\b$InitAttribute\b)/) {
3738 my $attr = $1; 3751 my $attr = $1;
@@ -3751,6 +3764,35 @@ sub string_find_replace {
3751 } 3764 }
3752 } 3765 }
3753 3766
3767# check for $InitAttributeData (ie: __initdata) with const
3768 if ($line =~ /\bconst\b/ && $line =~ /($InitAttributeData)/) {
3769 my $attr = $1;
3770 $attr =~ /($InitAttributePrefix)(.*)/;
3771 my $attr_prefix = $1;
3772 my $attr_type = $2;
3773 if (ERROR("INIT_ATTRIBUTE",
3774 "Use of const init definition must use ${attr_prefix}initconst\n" . $herecurr) &&
3775 $fix) {
3776 $fixed[$linenr - 1] =~
3777 s/$InitAttributeData/${attr_prefix}initconst/;
3778 }
3779 }
3780
3781# check for $InitAttributeConst (ie: __initconst) without const
3782 if ($line !~ /\bconst\b/ && $line =~ /($InitAttributeConst)/) {
3783 my $attr = $1;
3784 if (ERROR("INIT_ATTRIBUTE",
3785 "Use of $attr requires a separate use of const\n" . $herecurr) &&
3786 $fix) {
3787 my $lead = $fixed[$linenr - 1] =~
3788 /(^\+\s*(?:static\s+))/;
3789 $lead = rtrim($1);
3790 $lead = "$lead " if ($lead !~ /^\+$/);
3791 $lead = "${lead}const ";
3792 $fixed[$linenr - 1] =~ s/(^\+\s*(?:static\s+))/$lead/;
3793 }
3794 }
3795
3754# prefer usleep_range over udelay 3796# prefer usleep_range over udelay
3755 if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) { 3797 if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
3756 # ignore udelay's < 10, however 3798 # ignore udelay's < 10, however
@@ -3810,8 +3852,8 @@ sub string_find_replace {
3810# check for memory barriers without a comment. 3852# check for memory barriers without a comment.
3811 if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) { 3853 if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) {
3812 if (!ctx_has_comment($first_line, $linenr)) { 3854 if (!ctx_has_comment($first_line, $linenr)) {
3813 CHK("MEMORY_BARRIER", 3855 WARN("MEMORY_BARRIER",
3814 "memory barrier without comment\n" . $herecurr); 3856 "memory barrier without comment\n" . $herecurr);
3815 } 3857 }
3816 } 3858 }
3817# check of hardware specific defines 3859# check of hardware specific defines
@@ -3835,7 +3877,8 @@ sub string_find_replace {
3835 } 3877 }
3836 3878
3837# Check for __inline__ and __inline, prefer inline 3879# Check for __inline__ and __inline, prefer inline
3838 if ($line =~ /\b(__inline__|__inline)\b/) { 3880 if ($realfile !~ m@\binclude/uapi/@ &&
3881 $line =~ /\b(__inline__|__inline)\b/) {
3839 if (WARN("INLINE", 3882 if (WARN("INLINE",
3840 "plain inline is preferred over $1\n" . $herecurr) && 3883 "plain inline is preferred over $1\n" . $herecurr) &&
3841 $fix) { 3884 $fix) {
@@ -3845,19 +3888,22 @@ sub string_find_replace {
3845 } 3888 }
3846 3889
3847# Check for __attribute__ packed, prefer __packed 3890# Check for __attribute__ packed, prefer __packed
3848 if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) { 3891 if ($realfile !~ m@\binclude/uapi/@ &&
3892 $line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) {
3849 WARN("PREFER_PACKED", 3893 WARN("PREFER_PACKED",
3850 "__packed is preferred over __attribute__((packed))\n" . $herecurr); 3894 "__packed is preferred over __attribute__((packed))\n" . $herecurr);
3851 } 3895 }
3852 3896
3853# Check for __attribute__ aligned, prefer __aligned 3897# Check for __attribute__ aligned, prefer __aligned
3854 if ($line =~ /\b__attribute__\s*\(\s*\(.*aligned/) { 3898 if ($realfile !~ m@\binclude/uapi/@ &&
3899 $line =~ /\b__attribute__\s*\(\s*\(.*aligned/) {
3855 WARN("PREFER_ALIGNED", 3900 WARN("PREFER_ALIGNED",
3856 "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); 3901 "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
3857 } 3902 }
3858 3903
3859# Check for __attribute__ format(printf, prefer __printf 3904# Check for __attribute__ format(printf, prefer __printf
3860 if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) { 3905 if ($realfile !~ m@\binclude/uapi/@ &&
3906 $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
3861 if (WARN("PREFER_PRINTF", 3907 if (WARN("PREFER_PRINTF",
3862 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) && 3908 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) &&
3863 $fix) { 3909 $fix) {
@@ -3867,7 +3913,8 @@ sub string_find_replace {
3867 } 3913 }
3868 3914
3869# Check for __attribute__ format(scanf, prefer __scanf 3915# Check for __attribute__ format(scanf, prefer __scanf
3870 if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) { 3916 if ($realfile !~ m@\binclude/uapi/@ &&
3917 $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) {
3871 if (WARN("PREFER_SCANF", 3918 if (WARN("PREFER_SCANF",
3872 "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) && 3919 "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) &&
3873 $fix) { 3920 $fix) {
@@ -3903,9 +3950,9 @@ sub string_find_replace {
3903 } 3950 }
3904 3951
3905# check for seq_printf uses that could be seq_puts 3952# check for seq_printf uses that could be seq_puts
3906 if ($line =~ /\bseq_printf\s*\(/) { 3953 if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) {
3907 my $fmt = get_quoted_string($line, $rawline); 3954 my $fmt = get_quoted_string($line, $rawline);
3908 if ($fmt !~ /[^\\]\%/) { 3955 if ($fmt ne "" && $fmt !~ /[^\\]\%/) {
3909 if (WARN("PREFER_SEQ_PUTS", 3956 if (WARN("PREFER_SEQ_PUTS",
3910 "Prefer seq_puts to seq_printf\n" . $herecurr) && 3957 "Prefer seq_puts to seq_printf\n" . $herecurr) &&
3911 $fix) { 3958 $fix) {
@@ -3972,6 +4019,23 @@ sub string_find_replace {
3972 } 4019 }
3973 } 4020 }
3974 4021
4022# check for naked sscanf
4023 if ($^V && $^V ge 5.10.0 &&
4024 defined $stat &&
4025 $stat =~ /\bsscanf\b/ &&
4026 ($stat !~ /$Ident\s*=\s*sscanf\s*$balanced_parens/ &&
4027 $stat !~ /\bsscanf\s*$balanced_parens\s*(?:$Compare)/ &&
4028 $stat !~ /(?:$Compare)\s*\bsscanf\s*$balanced_parens/)) {
4029 my $lc = $stat =~ tr@\n@@;
4030 $lc = $lc + $linenr;
4031 my $stat_real = raw_line($linenr, 0);
4032 for (my $count = $linenr + 1; $count <= $lc; $count++) {
4033 $stat_real = $stat_real . "\n" . raw_line($count, 0);
4034 }
4035 WARN("NAKED_SSCANF",
4036 "unchecked sscanf return value\n" . "$here\n$stat_real\n");
4037 }
4038
3975# check for new externs in .h files. 4039# check for new externs in .h files.
3976 if ($realfile =~ /\.h$/ && 4040 if ($realfile =~ /\.h$/ &&
3977 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) { 4041 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
@@ -4190,6 +4254,12 @@ sub string_find_replace {
4190 "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); 4254 "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
4191 } 4255 }
4192 4256
4257# Use of __ARCH_HAS_<FOO> or ARCH_HAVE_<BAR> is wrong.
4258 if ($line =~ /\+\s*#\s*define\s+((?:__)?ARCH_(?:HAS|HAVE)\w*)\b/) {
4259 ERROR("DEFINE_ARCH_HAS",
4260 "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr);
4261 }
4262
4193# check for %L{u,d,i} in strings 4263# check for %L{u,d,i} in strings
4194 my $string; 4264 my $string;
4195 while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) { 4265 while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
diff --git a/scripts/docproc.c b/scripts/docproc.c
index 4cfdc1797eb8..2b69eaf5b646 100644
--- a/scripts/docproc.c
+++ b/scripts/docproc.c
@@ -72,6 +72,7 @@ FILELINE * docsection;
72#define FUNCTION "-function" 72#define FUNCTION "-function"
73#define NOFUNCTION "-nofunction" 73#define NOFUNCTION "-nofunction"
74#define NODOCSECTIONS "-no-doc-sections" 74#define NODOCSECTIONS "-no-doc-sections"
75#define SHOWNOTFOUND "-show-not-found"
75 76
76static char *srctree, *kernsrctree; 77static char *srctree, *kernsrctree;
77 78
@@ -294,6 +295,7 @@ static void singfunc(char * filename, char * line)
294 int startofsym = 1; 295 int startofsym = 1;
295 vec[idx++] = KERNELDOC; 296 vec[idx++] = KERNELDOC;
296 vec[idx++] = DOCBOOK; 297 vec[idx++] = DOCBOOK;
298 vec[idx++] = SHOWNOTFOUND;
297 299
298 /* Split line up in individual parameters preceded by FUNCTION */ 300 /* Split line up in individual parameters preceded by FUNCTION */
299 for (i=0; line[i]; i++) { 301 for (i=0; line[i]; i++) {
@@ -325,7 +327,8 @@ static void singfunc(char * filename, char * line)
325 */ 327 */
326static void docsect(char *filename, char *line) 328static void docsect(char *filename, char *line)
327{ 329{
328 char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */ 330 /* kerneldoc -docbook -show-not-found -function "section" file NULL */
331 char *vec[7];
329 char *s; 332 char *s;
330 333
331 for (s = line; *s; s++) 334 for (s = line; *s; s++)
@@ -341,10 +344,11 @@ static void docsect(char *filename, char *line)
341 344
342 vec[0] = KERNELDOC; 345 vec[0] = KERNELDOC;
343 vec[1] = DOCBOOK; 346 vec[1] = DOCBOOK;
344 vec[2] = FUNCTION; 347 vec[2] = SHOWNOTFOUND;
345 vec[3] = line; 348 vec[3] = FUNCTION;
346 vec[4] = filename; 349 vec[4] = line;
347 vec[5] = NULL; 350 vec[5] = filename;
351 vec[6] = NULL;
348 exec_kernel_doc(vec); 352 exec_kernel_doc(vec);
349} 353}
350 354
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index b482f162a18a..ef474098d9f1 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -240,12 +240,24 @@ case "$arg" in
240 output_file="$1" 240 output_file="$1"
241 cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)" 241 cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)"
242 output=${cpio_list} 242 output=${cpio_list}
243 echo "$output_file" | grep -q "\.gz$" && compr="gzip -n -9 -f" 243 echo "$output_file" | grep -q "\.gz$" \
244 echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f" 244 && [ -x "`which gzip 2> /dev/null`" ] \
245 echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f" 245 && compr="gzip -n -9 -f"
246 echo "$output_file" | grep -q "\.xz$" && \ 246 echo "$output_file" | grep -q "\.bz2$" \
247 compr="xz --check=crc32 --lzma2=dict=1MiB" 247 && [ -x "`which bzip2 2> /dev/null`" ] \
248 echo "$output_file" | grep -q "\.lzo$" && compr="lzop -9 -f" 248 && compr="bzip2 -9 -f"
249 echo "$output_file" | grep -q "\.lzma$" \
250 && [ -x "`which lzma 2> /dev/null`" ] \
251 && compr="lzma -9 -f"
252 echo "$output_file" | grep -q "\.xz$" \
253 && [ -x "`which xz 2> /dev/null`" ] \
254 && compr="xz --check=crc32 --lzma2=dict=1MiB"
255 echo "$output_file" | grep -q "\.lzo$" \
256 && [ -x "`which lzop 2> /dev/null`" ] \
257 && compr="lzop -9 -f"
258 echo "$output_file" | grep -q "\.lz4$" \
259 && [ -x "`which lz4 2> /dev/null`" ] \
260 && compr="lz4 -9 -f"
249 echo "$output_file" | grep -q "\.cpio$" && compr="cat" 261 echo "$output_file" | grep -q "\.cpio$" && compr="cat"
250 shift 262 shift
251 ;; 263 ;;
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 4305b2f2ec5e..dbd3e1ebbdad 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -257,6 +257,7 @@ my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
257 'July', 'August', 'September', 'October', 257 'July', 'August', 'September', 'October',
258 'November', 'December')[(localtime)[4]] . 258 'November', 'December')[(localtime)[4]] .
259 " " . ((localtime)[5]+1900); 259 " " . ((localtime)[5]+1900);
260my $show_not_found = 0;
260 261
261# Essentially these are globals. 262# Essentially these are globals.
262# They probably want to be tidied up, made more localised or something. 263# They probably want to be tidied up, made more localised or something.
@@ -369,6 +370,8 @@ while ($ARGV[0] =~ m/^-(.*)/) {
369 usage(); 370 usage();
370 } elsif ($cmd eq '-no-doc-sections') { 371 } elsif ($cmd eq '-no-doc-sections') {
371 $no_doc_sections = 1; 372 $no_doc_sections = 1;
373 } elsif ($cmd eq '-show-not-found') {
374 $show_not_found = 1;
372 } 375 }
373} 376}
374 377
@@ -2536,6 +2539,9 @@ sub process_file($) {
2536 } 2539 }
2537 if ($initial_section_counter == $section_counter) { 2540 if ($initial_section_counter == $section_counter) {
2538 print STDERR "Warning(${file}): no structured comments found\n"; 2541 print STDERR "Warning(${file}): no structured comments found\n";
2542 if (($function_only == 1) && ($show_not_found == 1)) {
2543 print STDERR " Was looking for '$_'.\n" for keys %function_table;
2544 }
2539 if ($output_mode eq "xml") { 2545 if ($output_mode eq "xml") {
2540 # The template wants at least one RefEntry here; make one. 2546 # The template wants at least one RefEntry here; make one.
2541 print "<refentry>\n"; 2547 print "<refentry>\n";
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 8247979e8f64..bfcea5d3b27d 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -599,18 +599,17 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
599 else 599 else
600 export = export_from_sec(info, get_secindex(info, sym)); 600 export = export_from_sec(info, get_secindex(info, sym));
601 601
602 /* CRC'd symbol */
603 if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
604 crc = (unsigned int) sym->st_value;
605 sym_update_crc(symname + strlen(CRC_PFX), mod, crc,
606 export);
607 }
608
602 switch (sym->st_shndx) { 609 switch (sym->st_shndx) {
603 case SHN_COMMON: 610 case SHN_COMMON:
604 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); 611 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
605 break; 612 break;
606 case SHN_ABS:
607 /* CRC'd symbol */
608 if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
609 crc = (unsigned int) sym->st_value;
610 sym_update_crc(symname + strlen(CRC_PFX), mod, crc,
611 export);
612 }
613 break;
614 case SHN_UNDEF: 613 case SHN_UNDEF:
615 /* undefined symbol */ 614 /* undefined symbol */
616 if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL && 615 if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL &&
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index a4f31c900fa6..c5d473393816 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -115,7 +115,9 @@ git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \
115 -o $(perf-tar).tar; \ 115 -o $(perf-tar).tar; \
116mkdir -p $(perf-tar); \ 116mkdir -p $(perf-tar); \
117git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \ 117git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
118tar rf $(perf-tar).tar $(perf-tar)/HEAD; \ 118(cd $(srctree)/tools/perf; \
119util/PERF-VERSION-GEN ../../$(perf-tar)/ 2>/dev/null); \
120tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
119rm -r $(perf-tar); \ 121rm -r $(perf-tar); \
120$(if $(findstring tar-src,$@),, \ 122$(if $(findstring tar-src,$@),, \
121$(if $(findstring bz2,$@),bzip2, \ 123$(if $(findstring bz2,$@),bzip2, \
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index 7c2310c5b996..5f7a8b663cb9 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -152,6 +152,30 @@ static void (*w2)(uint16_t, uint16_t *);
152 152
153typedef void (*table_sort_t)(char *, int); 153typedef void (*table_sort_t)(char *, int);
154 154
155/*
156 * Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of
157 * the way to -256..-1, to avoid conflicting with real section
158 * indices.
159 */
160#define SPECIAL(i) ((i) - (SHN_HIRESERVE + 1))
161
162static inline int is_shndx_special(unsigned int i)
163{
164 return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE;
165}
166
167/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
168static inline unsigned int get_secindex(unsigned int shndx,
169 unsigned int sym_offs,
170 const Elf32_Word *symtab_shndx_start)
171{
172 if (is_shndx_special(shndx))
173 return SPECIAL(shndx);
174 if (shndx != SHN_XINDEX)
175 return shndx;
176 return r(&symtab_shndx_start[sym_offs]);
177}
178
155/* 32 bit and 64 bit are very similar */ 179/* 32 bit and 64 bit are very similar */
156#include "sortextable.h" 180#include "sortextable.h"
157#define SORTEXTABLE_64 181#define SORTEXTABLE_64
diff --git a/scripts/sortextable.h b/scripts/sortextable.h
index f5eb43d42926..8fac3fd697a6 100644
--- a/scripts/sortextable.h
+++ b/scripts/sortextable.h
@@ -98,6 +98,8 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
98 Elf_Shdr *symtab_sec = NULL; 98 Elf_Shdr *symtab_sec = NULL;
99 Elf_Shdr *extab_sec = NULL; 99 Elf_Shdr *extab_sec = NULL;
100 Elf_Sym *sym; 100 Elf_Sym *sym;
101 const Elf_Sym *symtab;
102 Elf32_Word *symtab_shndx_start = NULL;
101 Elf_Sym *sort_needed_sym; 103 Elf_Sym *sort_needed_sym;
102 Elf_Shdr *sort_needed_sec; 104 Elf_Shdr *sort_needed_sec;
103 Elf_Rel *relocs = NULL; 105 Elf_Rel *relocs = NULL;
@@ -109,11 +111,22 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
109 int extab_index = 0; 111 int extab_index = 0;
110 int i; 112 int i;
111 int idx; 113 int idx;
114 unsigned int num_sections;
115 unsigned int secindex_strings;
112 116
113 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff)); 117 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
114 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx); 118
119 num_sections = r2(&ehdr->e_shnum);
120 if (num_sections == SHN_UNDEF)
121 num_sections = _r(&shdr[0].sh_size);
122
123 secindex_strings = r2(&ehdr->e_shstrndx);
124 if (secindex_strings == SHN_XINDEX)
125 secindex_strings = r(&shdr[0].sh_link);
126
127 shstrtab_sec = shdr + secindex_strings;
115 secstrtab = (const char *)ehdr + _r(&shstrtab_sec->sh_offset); 128 secstrtab = (const char *)ehdr + _r(&shstrtab_sec->sh_offset);
116 for (i = 0; i < r2(&ehdr->e_shnum); i++) { 129 for (i = 0; i < num_sections; i++) {
117 idx = r(&shdr[i].sh_name); 130 idx = r(&shdr[i].sh_name);
118 if (strcmp(secstrtab + idx, "__ex_table") == 0) { 131 if (strcmp(secstrtab + idx, "__ex_table") == 0) {
119 extab_sec = shdr + i; 132 extab_sec = shdr + i;
@@ -129,6 +142,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
129 symtab_sec = shdr + i; 142 symtab_sec = shdr + i;
130 if (strcmp(secstrtab + idx, ".strtab") == 0) 143 if (strcmp(secstrtab + idx, ".strtab") == 0)
131 strtab_sec = shdr + i; 144 strtab_sec = shdr + i;
145 if (r(&shdr[i].sh_type) == SHT_SYMTAB_SHNDX)
146 symtab_shndx_start = (Elf32_Word *)(
147 (const char *)ehdr + _r(&shdr[i].sh_offset));
132 } 148 }
133 if (strtab_sec == NULL) { 149 if (strtab_sec == NULL) {
134 fprintf(stderr, "no .strtab in file: %s\n", fname); 150 fprintf(stderr, "no .strtab in file: %s\n", fname);
@@ -138,6 +154,8 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
138 fprintf(stderr, "no .symtab in file: %s\n", fname); 154 fprintf(stderr, "no .symtab in file: %s\n", fname);
139 fail_file(); 155 fail_file();
140 } 156 }
157 symtab = (const Elf_Sym *)((const char *)ehdr +
158 _r(&symtab_sec->sh_offset));
141 if (extab_sec == NULL) { 159 if (extab_sec == NULL) {
142 fprintf(stderr, "no __ex_table in file: %s\n", fname); 160 fprintf(stderr, "no __ex_table in file: %s\n", fname);
143 fail_file(); 161 fail_file();
@@ -176,7 +194,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
176 fname); 194 fname);
177 fail_file(); 195 fail_file();
178 } 196 }
179 sort_needed_sec = &shdr[r2(&sort_needed_sym->st_shndx)]; 197 sort_needed_sec = &shdr[get_secindex(r2(&sym->st_shndx),
198 sort_needed_sym - symtab,
199 symtab_shndx_start)];
180 sort_done_location = (void *)ehdr + 200 sort_done_location = (void *)ehdr +
181 _r(&sort_needed_sec->sh_offset) + 201 _r(&sort_needed_sec->sh_offset) +
182 _r(&sort_needed_sym->st_value) - 202 _r(&sort_needed_sym->st_value) -