History

Merge commit v3.13-rc1 into kbuild/misc

Michal Marek committed 12 years ago

Commit 37e2c2a2 parents 1c8ddae 6ce4eac9752 files · +401738 −201627Browse files

Showing the changes to scripts (22 of 9752 files). Show all

Unified · Split

22 files
  1. scripts/Makefile.modpost +3 −1
  2. scripts/asn1_compiler.c +2 −0
  3. scripts/bloat-o-meter +4 −3
  4. scripts/checkpatch.pl +121 −50
  5. scripts/docproc.c +9 −5
  6. scripts/gen_initramfs_list.sh +18 −6
  7. scripts/kallsyms.c +17 −1
  8. scripts/kconfig/expr.h +1 −1
  9. scripts/kconfig/mconf.c +29 −31
  10. scripts/kconfig/menu.c +6 −5
  11. scripts/kconfig/qconf.cc +5 −0
  12. scripts/kconfig/qconf.h +1 −0
  13. scripts/kconfig/symbol.c +1 −1
  14. scripts/kconfig/zconf.l +0 −1
  15. scripts/kernel-doc +6 −0
  16. scripts/link-vmlinux.sh +2 −0
  17. scripts/mod/modpost.c +25 −12
  18. scripts/mod/sumversion.c +1 −1
  19. scripts/package/Makefile +3 −1
  20. scripts/recordmcount.pl +2 −2
  21. scripts/sortextable.c +24 −0
  22. scripts/sortextable.h +23 −3
scripts/Makefile.modpost+3−1
@@ -79,9 +79,11 @@ modpost = scripts/mod/modpost \ · 78 unmodified lines
7979 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
8080 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
8181
82+MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS)))
83+
8284 # We can go over command line length here, so be careful.
8385 quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
84− cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) -s -T -
86+ cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) $(MODPOST_OPT) -s -T -
8587
8688 PHONY += __modpost
8789 __modpost: $(modules:.ko=.o) FORCE
scripts/asn1_compiler.c+2−0
@@ -1353,6 +1353,8 @@ static void render_out_of_line_list(FILE *out) · 1352 unmodified lines
13531353 render_opcode(out, "ASN1_OP_END_SET_OF%s,\n", act);
13541354 render_opcode(out, "_jump_target(%u),\n", entry);
13551355 break;
1356+ default:
1357+ break;
13561358 }
13571359 if (e->action)
13581360 render_opcode(out, "_action(ACT_%s),\n",
scripts/bloat-o-meter+4−3
@@ -19,9 +19,10 @@ def getsizes(file): · 18 unmodified lines
1919 size, type, name = l[:-1].split()
2020 if type in "tTdDbBrR":
2121 # strip generated symbols
22− if name[:6] == "__mod_": continue
23− # function names begin with '.' on 64-bit powerpc
24− if "." in name[1:]: name = "static." + name.split(".")[0]
22+ if name.startswith("__mod_"): continue
23+ if name == "linux_banner": continue
24+ # statics and some other optimizations adds random .NUMBER
25+ name = re.sub(r'\.[0-9]+', '', name)
2526 sym[name] = sym.get(name, 0) + int(size, 16)
2627 return sym
2728
scripts/checkpatch.pl+121−50
@@ -241,8 +241,11 @@ our $Sparse = qr{ · 240 unmodified lines
241241 __ref|
242242 __rcu
243243 }x;
244−
245−our $InitAttribute = qr{__(?:mem|cpu|dev|net_|)(?:initdata|initconst|init\b)};
244+our $InitAttributePrefix = qr{__(?:mem|cpu|dev|net_|)};
245+our $InitAttributeData = qr{$InitAttributePrefix(?:initdata\b)};
246+our $InitAttributeConst = qr{$InitAttributePrefix(?:initconst\b)};
247+our $InitAttributeInit = qr{$InitAttributePrefix(?:init\b)};
248+our $InitAttribute = qr{$InitAttributeData|$InitAttributeConst|$InitAttributeInit};
246249
247250 # Notes to $Attribute:
248251 # We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
@@ -323,7 +326,8 @@ our $logFunctions = qr{(?x: · 74 unmodified lines
323326 (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
324327 WARN(?:_RATELIMIT|_ONCE|)|
325328 panic|
326− MODULE_[A-Z_]+
329+ MODULE_[A-Z_]+|
330+ seq_vprintf|seq_printf|seq_puts
327331 )};
328332
329333 our $signature_tags = qr{(?xi:
@@ -442,8 +446,9 @@ sub seed_camelcase_file { · 112 unmodified lines
442446 next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/);
443447 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
444448 $camelcase{$1} = 1;
445− }
446− elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*\(/) {
449+ } 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*[;\{]/) {
447452 $camelcase{$1} = 1;
448453 }
449454 }
@@ -1512,6 +1517,14 @@ sub rtrim { · 1062 unmodified lines
15121517 return $string;
15131518 }
15141519
1520+sub string_find_replace {
1521+ my ($string, $find, $replace) = @_;
1522+
1523+ $string =~ s/$find/$replace/g;
1524+
1525+ return $string;
1526+}
1527+
15151528 sub tabify {
15161529 my ($leading) = @_;
15171530
@@ -1612,6 +1625,8 @@ sub process { · 94 unmodified lines
16121625 my @setup_docs = ();
16131626 my $setup_docs = 0;
16141627
1628+ my $camelcase_file_seeded = 0;
1629+
16151630 sanitise_line_reset();
16161631 my $line;
16171632 foreach my $rawline (@rawlines) {
@@ -1754,11 +1769,11 @@ sub process { · 136 unmodified lines
17541769 # extract the filename as it passes
17551770 if ($line =~ /^diff --git.*?(\S+)$/) {
17561771 $realfile = $1;
1757− $realfile =~ s@^([^/]*)/@@;
1772+ $realfile =~ s@^([^/]*)/@@ if (!$file);
17581773 $in_commit_log = 0;
17591774 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
17601775 $realfile = $1;
1761− $realfile =~ s@^([^/]*)/@@;
1776+ $realfile =~ s@^([^/]*)/@@ if (!$file);
17621777 $in_commit_log = 0;
17631778
17641779 $p1_prefix = $1;
@@ -1947,6 +1962,18 @@ sub process { · 182 unmodified lines
19471962 $rpt_cleaners = 1;
19481963 }
19491964
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+
19501977 # check for Kconfig help text having a real description
19511978 # Only applies when adding the entry originally, after that we do not have
19521979 # sufficient context to determine whether it is indeed long enough.
@@ -2838,7 +2865,7 @@ sub process { · 885 unmodified lines
28382865 \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
28392866 =>|->|<<|>>|<|>|=|!|~|
28402867 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
2841− \?|:
2868+ \?:|\?|:
28422869 }x;
28432870 my @elements = split(/($ops|;)/, $opline);
28442871
@@ -3061,15 +3088,13 @@ sub process { · 216 unmodified lines
30613088 $ok = 1;
30623089 }
30633090
3064− # Ignore ?:
3065− if (($opv eq ':O' && $ca =~ /\?$/) ||
3066− ($op eq '?' && $cc =~ /^:/)) {
3067− $ok = 1;
3068− }
3069−
3091+ # messages are ERROR, but ?: are CHK
30703092 if ($ok == 0) {
3071− if (ERROR("SPACING",
3072− "spaces required around that '$op' $at\n" . $hereptr)) {
3093+ my $msg_type = \&ERROR;
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)) {
30733098 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
30743099 if (defined $fix_elements[$n + 2]) {
30753100 $fix_elements[$n + 2] =~ s/^\s+//;
@@ -3208,21 +3233,10 @@ sub process { · 132 unmodified lines
32083233 }
32093234
32103235 # Return is not a function.
3211− if (defined($stat) && $stat =~ /^.\s*return(\s*)(\(.*);/s) {
3236+ if (defined($stat) && $stat =~ /^.\s*return(\s*)\(/s) {
32123237 my $spacing = $1;
3213− my $value = $2;
3214−
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*$/) {
3238+ if ($^V && $^V ge 5.10.0 &&
3239+ $stat =~ /^.\s*return\s*$balanced_parens\s*;\s*$/) {
32263240 ERROR("RETURN_PARENTHESES",
32273241 "return is not a function, parentheses are not required\n" . $herecurr);
32283242
@@ -3231,6 +3245,7 @@ sub process { · 2 unmodified lines
32313245 "space required before the open parenthesis '('\n" . $herecurr);
32323246 }
32333247 }
3248+
32343249 # Return of what appears to be an errno should normally be -'ve
32353250 if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
32363251 my $name = $1;
@@ -3274,6 +3289,7 @@ sub process { · 37 unmodified lines
32743289 }
32753290 }
32763291 if (!defined $suppress_whiletrailers{$linenr} &&
3292+ defined($stat) && defined($cond) &&
32773293 $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) {
32783294 my ($s, $c) = ($stat, $cond);
32793295
@@ -3396,7 +3412,13 @@ sub process { · 116 unmodified lines
33963412 while ($var =~ m{($Ident)}g) {
33973413 my $word = $1;
33983414 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
3399− seed_camelcase_includes() if ($check);
3415+ if ($check) {
3416+ seed_camelcase_includes();
3417+ if (!$file && !$camelcase_file_seeded) {
3418+ seed_camelcase_file($realfile);
3419+ $camelcase_file_seeded = 1;
3420+ }
3421+ }
34003422 if (!defined $camelcase{$word}) {
34013423 $camelcase{$word} = 1;
34023424 CHK("CAMELCASE",
@@ -3725,14 +3747,6 @@ sub process { · 322 unmodified lines
37253747 }
37263748 }
37273749
3728−sub string_find_replace {
3729− my ($string, $find, $replace) = @_;
3730−
3731− $string =~ s/$find/$replace/g;
3732−
3733− return $string;
3734−}
3735−
37363750 # check for bad placement of section $InitAttribute (e.g.: __initdata)
37373751 if ($line =~ /(\b$InitAttribute\b)/) {
37383752 my $attr = $1;
@@ -3751,6 +3765,35 @@ sub string_find_replace { · 12 unmodified lines
37513765 }
37523766 }
37533767
3768+# check for $InitAttributeData (ie: __initdata) with const
3769+ if ($line =~ /\bconst\b/ && $line =~ /($InitAttributeData)/) {
3770+ my $attr = $1;
3771+ $attr =~ /($InitAttributePrefix)(.*)/;
3772+ my $attr_prefix = $1;
3773+ my $attr_type = $2;
3774+ if (ERROR("INIT_ATTRIBUTE",
3775+ "Use of const init definition must use ${attr_prefix}initconst\n" . $herecurr) &&
3776+ $fix) {
3777+ $fixed[$linenr - 1] =~
3778+ s/$InitAttributeData/${attr_prefix}initconst/;
3779+ }
3780+ }
3781+
3782+# check for $InitAttributeConst (ie: __initconst) without const
3783+ if ($line !~ /\bconst\b/ && $line =~ /($InitAttributeConst)/) {
3784+ my $attr = $1;
3785+ if (ERROR("INIT_ATTRIBUTE",
3786+ "Use of $attr requires a separate use of const\n" . $herecurr) &&
3787+ $fix) {
3788+ my $lead = $fixed[$linenr - 1] =~
3789+ /(^\+\s*(?:static\s+))/;
3790+ $lead = rtrim($1);
3791+ $lead = "$lead " if ($lead !~ /^\+$/);
3792+ $lead = "${lead}const ";
3793+ $fixed[$linenr - 1] =~ s/(^\+\s*(?:static\s+))/$lead/;
3794+ }
3795+ }
3796+
37543797 # prefer usleep_range over udelay
37553798 if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
37563799 # ignore udelay's < 10, however
@@ -3810,8 +3853,8 @@ sub string_find_replace { · 53 unmodified lines
38103853 # check for memory barriers without a comment.
38113854 if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) {
38123855 if (!ctx_has_comment($first_line, $linenr)) {
3813− CHK("MEMORY_BARRIER",
3814− "memory barrier without comment\n" . $herecurr);
3856+ WARN("MEMORY_BARRIER",
3857+ "memory barrier without comment\n" . $herecurr);
38153858 }
38163859 }
38173860 # check of hardware specific defines
@@ -3835,7 +3878,8 @@ sub string_find_replace { · 17 unmodified lines
38353878 }
38363879
38373880 # Check for __inline__ and __inline, prefer inline
3838− if ($line =~ /\b(__inline__|__inline)\b/) {
3881+ if ($realfile !~ m@\binclude/uapi/@ &&
3882+ $line =~ /\b(__inline__|__inline)\b/) {
38393883 if (WARN("INLINE",
38403884 "plain inline is preferred over $1\n" . $herecurr) &&
38413885 $fix) {
@@ -3845,19 +3889,22 @@ sub string_find_replace { · 3 unmodified lines
38453889 }
38463890
38473891 # Check for __attribute__ packed, prefer __packed
3848− if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) {
3892+ if ($realfile !~ m@\binclude/uapi/@ &&
3893+ $line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) {
38493894 WARN("PREFER_PACKED",
38503895 "__packed is preferred over __attribute__((packed))\n" . $herecurr);
38513896 }
38523897
38533898 # Check for __attribute__ aligned, prefer __aligned
3854− if ($line =~ /\b__attribute__\s*\(\s*\(.*aligned/) {
3899+ if ($realfile !~ m@\binclude/uapi/@ &&
3900+ $line =~ /\b__attribute__\s*\(\s*\(.*aligned/) {
38553901 WARN("PREFER_ALIGNED",
38563902 "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
38573903 }
38583904
38593905 # Check for __attribute__ format(printf, prefer __printf
3860− if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
3906+ if ($realfile !~ m@\binclude/uapi/@ &&
3907+ $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
38613908 if (WARN("PREFER_PRINTF",
38623909 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) &&
38633910 $fix) {
@@ -3867,7 +3914,8 @@ sub string_find_replace { · 3 unmodified lines
38673914 }
38683915
38693916 # Check for __attribute__ format(scanf, prefer __scanf
3870− if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) {
3917+ if ($realfile !~ m@\binclude/uapi/@ &&
3918+ $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) {
38713919 if (WARN("PREFER_SCANF",
38723920 "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) &&
38733921 $fix) {
@@ -3903,9 +3951,9 @@ sub string_find_replace { · 29 unmodified lines
39033951 }
39043952
39053953 # check for seq_printf uses that could be seq_puts
3906− if ($line =~ /\bseq_printf\s*\(/) {
3954+ if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) {
39073955 my $fmt = get_quoted_string($line, $rawline);
3908− if ($fmt !~ /[^\\]\%/) {
3956+ if ($fmt ne "" && $fmt !~ /[^\\]\%/) {
39093957 if (WARN("PREFER_SEQ_PUTS",
39103958 "Prefer seq_puts to seq_printf\n" . $herecurr) &&
39113959 $fix) {
@@ -3972,11 +4020,28 @@ sub string_find_replace { · 60 unmodified lines
39724020 }
39734021 }
39744022
4023+# check for naked sscanf
4024+ if ($^V && $^V ge 5.10.0 &&
4025+ defined $stat &&
4026+ $stat =~ /\bsscanf\b/ &&
4027+ ($stat !~ /$Ident\s*=\s*sscanf\s*$balanced_parens/ &&
4028+ $stat !~ /\bsscanf\s*$balanced_parens\s*(?:$Compare)/ &&
4029+ $stat !~ /(?:$Compare)\s*\bsscanf\s*$balanced_parens/)) {
4030+ my $lc = $stat =~ tr@\n@@;
4031+ $lc = $lc + $linenr;
4032+ my $stat_real = raw_line($linenr, 0);
4033+ for (my $count = $linenr + 1; $count <= $lc; $count++) {
4034+ $stat_real = $stat_real . "\n" . raw_line($count, 0);
4035+ }
4036+ WARN("NAKED_SSCANF",
4037+ "unchecked sscanf return value\n" . "$here\n$stat_real\n");
4038+ }
4039+
39754040 # check for new externs in .h files.
39764041 if ($realfile =~ /\.h$/ &&
39774042 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
3978− if (WARN("AVOID_EXTERNS",
3979− "extern prototypes should be avoided in .h files\n" . $herecurr) &&
4043+ if (CHK("AVOID_EXTERNS",
4044+ "extern prototypes should be avoided in .h files\n" . $herecurr) &&
39804045 $fix) {
39814046 $fixed[$linenr - 1] =~ s/(.*)\bextern\b\s*(.*)/$1$2/;
39824047 }
@@ -4190,6 +4255,12 @@ sub string_find_replace { · 207 unmodified lines
41904255 "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
41914256 }
41924257
4258+# Use of __ARCH_HAS_<FOO> or ARCH_HAVE_<BAR> is wrong.
4259+ if ($line =~ /\+\s*#\s*define\s+((?:__)?ARCH_(?:HAS|HAVE)\w*)\b/) {
4260+ ERROR("DEFINE_ARCH_HAS",
4261+ "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr);
4262+ }
4263+
41934264 # check for %L{u,d,i} in strings
41944265 my $string;
41954266 while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
scripts/docproc.c+9−5
@@ -72,6 +72,7 @@ FILELINE * docsection; · 71 unmodified lines
7272 #define FUNCTION "-function"
7373 #define NOFUNCTION "-nofunction"
7474 #define NODOCSECTIONS "-no-doc-sections"
75+#define SHOWNOTFOUND "-show-not-found"
7576
7677 static char *srctree, *kernsrctree;
7778
@@ -294,6 +295,7 @@ static void singfunc(char * filename, char * line) · 216 unmodified lines
294295 int startofsym = 1;
295296 vec[idx++] = KERNELDOC;
296297 vec[idx++] = DOCBOOK;
298+ vec[idx++] = SHOWNOTFOUND;
297299
298300 /* Split line up in individual parameters preceded by FUNCTION */
299301 for (i=0; line[i]; i++) {
@@ -325,7 +327,8 @@ static void singfunc(char * filename, char * line) · 25 unmodified lines
325327 */
326328 static void docsect(char *filename, char *line)
327329 {
328− char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */
330+ /* kerneldoc -docbook -show-not-found -function "section" file NULL */
331+ char *vec[7];
329332 char *s;
330333
331334 for (s = line; *s; s++)
@@ -341,10 +344,11 @@ static void docsect(char *filename, char *line) · 9 unmodified lines
341344
342345 vec[0] = KERNELDOC;
343346 vec[1] = DOCBOOK;
344− vec[2] = FUNCTION;
345− vec[3] = line;
346− vec[4] = filename;
347− vec[5] = NULL;
347+ vec[2] = SHOWNOTFOUND;
348+ vec[3] = FUNCTION;
349+ vec[4] = line;
350+ vec[5] = filename;
351+ vec[6] = NULL;
348352 exec_kernel_doc(vec);
349353 }
350354
scripts/gen_initramfs_list.sh+18−6
@@ -240,12 +240,24 @@ case "$arg" in · 239 unmodified lines
240240 output_file="$1"
241241 cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)"
242242 output=${cpio_list}
243− echo "$output_file" | grep -q "\.gz$" && compr="gzip -n -9 -f"
244− echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f"
245− echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f"
246− echo "$output_file" | grep -q "\.xz$" && \
247− compr="xz --check=crc32 --lzma2=dict=1MiB"
248− echo "$output_file" | grep -q "\.lzo$" && compr="lzop -9 -f"
243+ echo "$output_file" | grep -q "\.gz$" \
244+ && [ -x "`which gzip 2> /dev/null`" ] \
245+ && compr="gzip -n -9 -f"
246+ echo "$output_file" | grep -q "\.bz2$" \
247+ && [ -x "`which bzip2 2> /dev/null`" ] \
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"
249261 echo "$output_file" | grep -q "\.cpio$" && compr="cat"
250262 shift
251263 ;;
scripts/kallsyms.c+17−1
@@ -55,6 +55,7 @@ static struct sym_entry *table; · 54 unmodified lines
5555 static unsigned int table_size, table_cnt;
5656 static int all_symbols = 0;
5757 static char symbol_prefix_char = '\0';
58+static unsigned long long kernel_start_addr = 0;
5859
5960 int token_profit[0x10000];
6061
@@ -65,7 +66,10 @@ unsigned char best_table_len[256]; · 4 unmodified lines
6566
6667 static void usage(void)
6768 {
68− fprintf(stderr, "Usage: kallsyms [--all-symbols] [--symbol-prefix=<prefix char>] < in.map > out.S\n");
69+ fprintf(stderr, "Usage: kallsyms [--all-symbols] "
70+ "[--symbol-prefix=<prefix char>] "
71+ "[--page-offset=<CONFIG_PAGE_OFFSET>] "
72+ "< in.map > out.S\n");
6973 exit(1);
7074 }
7175
@@ -111,6 +115,12 @@ static int read_symbol(FILE *in, struct sym_entry *s) · 39 unmodified lines
111115 fprintf(stderr, "Read error or end of file.\n");
112116 return -1;
113117 }
118+ if (strlen(str) > KSYM_NAME_LEN) {
119+ fprintf(stderr, "Symbol %s too long for kallsyms (%zu vs %d).\n"
120+ "Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n",
121+ str, strlen(str), KSYM_NAME_LEN);
122+ return -1;
123+ }
114124
115125 sym = str;
116126 /* skip prefix char */
@@ -194,6 +204,9 @@ static int symbol_valid(struct sym_entry *s) · 77 unmodified lines
194204 int i;
195205 int offset = 1;
196206
207+ if (s->addr < kernel_start_addr)
208+ return 0;
209+
197210 /* skip prefix char */
198211 if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char)
199212 offset++;
@@ -646,6 +659,9 @@ int main(int argc, char **argv) · 446 unmodified lines
646659 if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\''))
647660 p++;
648661 symbol_prefix_char = *p;
662+ } else if (strncmp(argv[i], "--page-offset=", 14) == 0) {
663+ const char *p = &argv[i][14];
664+ kernel_start_addr = strtoull(p, NULL, 16);
649665 } else
650666 usage();
651667 }
scripts/kconfig/expr.h+1−1
@@ -93,7 +93,7 @@ struct symbol { · 92 unmodified lines
9393 #define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */
9494 #define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */
9595 #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
96−#define SYMBOL_WRITE 0x0200 /* ? */
96+#define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */
9797 #define SYMBOL_CHANGED 0x0400 /* ? */
9898 #define SYMBOL_AUTO 0x1000 /* value from environment variable */
9999 #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
scripts/kconfig/mconf.c+29−31
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525 static const char mconf_readme[] = N_(
2626 "Overview\n"
2727 "--------\n"
28−"This interface let you select features and parameters for the build.\n"
28+"This interface lets you select features and parameters for the build.\n"
2929 "Features can either be built-in, modularized, or ignored. Parameters\n"
3030 "must be entered in as decimal or hexadecimal numbers or text.\n"
3131 "\n"
@@ -39,15 +39,15 @@ static const char mconf_readme[] = N_( · 7 unmodified lines
3939 "\n"
4040 "To change any of these features, highlight it with the cursor\n"
4141 "keys and press <Y> to build it in, <M> to make it a module or\n"
42−"<N> to removed it. You may also press the <Space Bar> to cycle\n"
43−"through the available options (ie. Y->N->M->Y).\n"
42+"<N> to remove it. You may also press the <Space Bar> to cycle\n"
43+"through the available options (i.e. Y->N->M->Y).\n"
4444 "\n"
4545 "Some additional keyboard hints:\n"
4646 "\n"
4747 "Menus\n"
4848 "----------\n"
49−"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
50−" you wish to change or submenu wish to select and press <Enter>.\n"
49+"o Use the Up/Down arrow keys (cursor keys) to highlight the item you\n"
50+" wish to change or the submenu you wish to select and press <Enter>.\n"
5151 " Submenus are designated by \"--->\", empty ones by \"----\".\n"
5252 "\n"
5353 " Shortcut: Press the option's highlighted letter (hotkey).\n"
@@ -65,7 +65,7 @@ static const char mconf_readme[] = N_( · 11 unmodified lines
6565 " there is a delayed response which you may find annoying.\n"
6666 "\n"
6767 " Also, the <TAB> and cursor keys will cycle between <Select>,\n"
68−" <Exit> and <Help>.\n"
68+" <Exit>, <Help>, <Save>, and <Load>.\n"
6969 "\n"
7070 "o To get help with an item, use the cursor keys to highlight <Help>\n"
7171 " and press <ENTER>.\n"
@@ -105,7 +105,7 @@ static const char mconf_readme[] = N_( · 33 unmodified lines
105105 "Text Box (Help Window)\n"
106106 "--------\n"
107107 "o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
108−" keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for \n"
108+" keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for\n"
109109 " those who are familiar with less and lynx.\n"
110110 "\n"
111111 "o Press <E>, <X>, <q>, <Enter> or <Esc><Esc> to exit.\n"
@@ -117,23 +117,21 @@ static const char mconf_readme[] = N_( · 5 unmodified lines
117117 "those who, for various reasons, find it necessary to switch\n"
118118 "between different configurations.\n"
119119 "\n"
120−"At the end of the main menu you will find two options. One is\n"
121−"for saving the current configuration to a file of your choosing.\n"
122−"The other option is for loading a previously saved alternate\n"
123−"configuration.\n"
120+"The <Save> button will let you save the current configuration to\n"
121+"a file of your choosing. Use the <Load> button to load a previously\n"
122+"saved alternate configuration.\n"
124123 "\n"
125−"Even if you don't use alternate configuration files, but you\n"
126−"find during a Menuconfig session that you have completely messed\n"
127−"up your settings, you may use the \"Load Alternate...\" option to\n"
128−"restore your previously saved settings from \".config\" without\n"
129−"restarting Menuconfig.\n"
124+"Even if you don't use alternate configuration files, but you find\n"
125+"during a Menuconfig session that you have completely messed up your\n"
126+"settings, you may use the <Load> button to restore your previously\n"
127+"saved settings from \".config\" without restarting Menuconfig.\n"
130128 "\n"
131129 "Other information\n"
132130 "-----------------\n"
133−"If you use Menuconfig in an XTERM window make sure you have your\n"
134−"$TERM variable set to point to a xterm definition which supports color.\n"
135−"Otherwise, Menuconfig will look rather bad. Menuconfig will not\n"
136−"display correctly in a RXVT window because rxvt displays only one\n"
131+"If you use Menuconfig in an XTERM window, make sure you have your\n"
132+"$TERM variable set to point to an xterm definition which supports\n"
133+"color. Otherwise, Menuconfig will look rather bad. Menuconfig will\n"
134+"not display correctly in an RXVT window because rxvt displays only one\n"
137135 "intensity of color, bright.\n"
138136 "\n"
139137 "Menuconfig will display larger menus on screens or xterms which are\n"
@@ -148,8 +146,8 @@ static const char mconf_readme[] = N_( · 8 unmodified lines
148146 "\n"
149147 "Optional personality available\n"
150148 "------------------------------\n"
151−"If you prefer to have all of the options listed in a single menu, rather\n"
152−"than the default multimenu hierarchy, run the menuconfig with\n"
149+"If you prefer to have all of the options listed in a single menu,\n"
150+"rather than the default multimenu hierarchy, run the menuconfig with\n"
153151 "MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
154152 "\n"
155153 "make MENUCONFIG_MODE=single_menu menuconfig\n"
@@ -172,7 +170,7 @@ static const char mconf_readme[] = N_( · 16 unmodified lines
172170 " mono => selects colors suitable for monochrome displays\n"
173171 " blackbg => selects a color scheme with black background\n"
174172 " classic => theme with blue background. The classic look\n"
175−" bluetitle => a LCD friendly version of classic. (default)\n"
173+" bluetitle => an LCD friendly version of classic. (default)\n"
176174 "\n"),
177175 menu_instructions[] = N_(
178176 "Arrow keys navigate the menu. "
@@ -238,24 +236,24 @@ search_help[] = N_( · 59 unmodified lines
238236 "Symbol: FOO [=m]\n"
239237 "Type : tristate\n"
240238 "Prompt: Foo bus is used to drive the bar HW\n"
241− " Defined at drivers/pci/Kconfig:47\n"
242− " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
243239 " Location:\n"
244240 " -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
245241 " -> PCI support (PCI [=y])\n"
246242 "(1) -> PCI access mode (<choice> [=y])\n"
243+ " Defined at drivers/pci/Kconfig:47\n"
244+ " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
247245 " Selects: LIBCRC32\n"
248− " Selected by: BAR\n"
246+ " Selected by: BAR [=n]\n"
249247 "-----------------------------------------------------------------\n"
250248 "o The line 'Type:' shows the type of the configuration option for\n"
251249 " this symbol (boolean, tristate, string, ...)\n"
252250 "o The line 'Prompt:' shows the text used in the menu structure for\n"
253251 " this symbol\n"
254− "o The 'Defined at' line tell at what file / line number the symbol\n"
252+ "o The 'Defined at' line tells at what file / line number the symbol\n"
255253 " is defined\n"
256− "o The 'Depends on:' line tell what symbols needs to be defined for\n"
254+ "o The 'Depends on:' line tells what symbols need to be defined for\n"
257255 " this symbol to be visible in the menu (selectable)\n"
258− "o The 'Location:' lines tell where in the menu structure this symbol\n"
256+ "o The 'Location:' lines tells where in the menu structure this symbol\n"
259257 " is located\n"
260258 " A location followed by a [=y] indicates that this is a\n"
261259 " selectable menu item - and the current value is displayed inside\n"
@@ -263,9 +261,9 @@ search_help[] = N_( · 1 unmodified line
263261 " Press the key in the (#) prefix to jump directly to that\n"
264262 " location. You will be returned to the current search results\n"
265263 " after exiting this new menu.\n"
266− "o The 'Selects:' line tell what symbol will be automatically\n"
264+ "o The 'Selects:' line tells what symbols will be automatically\n"
267265 " selected if this symbol is selected (y or m)\n"
268− "o The 'Selected by' line tell what symbol has selected this symbol\n"
266+ "o The 'Selected by' line tells what symbol has selected this symbol\n"
269267 "\n"
270268 "Only relevant lines are shown.\n"
271269 "\n\n"
scripts/kconfig/menu.c+6−5
@@ -119,9 +119,10 @@ void menu_set_type(int type) · 118 unmodified lines
119119 sym->type = type;
120120 return;
121121 }
122− menu_warn(current_entry, "type of '%s' redefined from '%s' to '%s'",
123− sym->name ? sym->name : "<choice>",
124− sym_type_name(sym->type), sym_type_name(type));
122+ menu_warn(current_entry,
123+ "ignoring type redefinition of '%s' from '%s' to '%s'",
124+ sym->name ? sym->name : "<choice>",
125+ sym_type_name(sym->type), sym_type_name(type));
125126 }
126127
127128 struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
@@ -583,7 +584,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop, · 455 unmodified lines
583584 for (j = 4; --i >= 0; j += 2) {
584585 menu = submenu[i];
585586 if (head && location && menu == location)
586− jump->offset = r->len - 1;
587+ jump->offset = strlen(r->s);
587588 str_printf(r, "%*c-> %s", j, ' ',
588589 _(menu_get_prompt(menu)));
589590 if (menu->sym) {
@@ -597,7 +598,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop, · 7 unmodified lines
597598 }
598599
599600 /*
600− * get peoperty of type P_SYMBOL
601+ * get property of type P_SYMBOL
601602 */
602603 static struct property *get_symbol_prop(struct symbol *sym)
603604 {
scripts/kconfig/qconf.cc+5−0
@@ -69,6 +69,11 @@ static inline QString qgettext(const QString& str) · 68 unmodified lines
6969 return QString::fromLocal8Bit(gettext(str.latin1()));
7070 }
7171
72+ConfigSettings::ConfigSettings()
73+ : QSettings("kernel.org", "qconf")
74+{
75+}
76+
7277 /**
7378 * Reads a list of integer values from the application settings.
7479 */
scripts/kconfig/qconf.h+1−0
@@ -32,6 +32,7 @@ class ConfigMainWindow; · 31 unmodified lines
3232
3333 class ConfigSettings : public QSettings {
3434 public:
35+ ConfigSettings();
3536 Q3ValueList<int> readSizes(const QString& key, bool *ok);
3637 bool writeSizes(const QString& key, const Q3ValueList<int>& value);
3738 };
scripts/kconfig/symbol.c+1−1
@@ -1047,7 +1047,7 @@ sym_re_search_free: · 1046 unmodified lines
10471047 * When we check for recursive dependencies we use a stack to save
10481048 * current state so we can print out relevant info to user.
10491049 * The entries are located on the call stack so no need to free memory.
1050− * Note inser() remove() must always match to properly clear the stack.
1050+ * Note insert() remove() must always match to properly clear the stack.
10511051 */
10521052 static struct dep_stack {
10531053 struct dep_stack *prev, *next;
scripts/kconfig/zconf.l+0−1
@@ -68,7 +68,6 @@ static void alloc_string(const char *str, int size) · 67 unmodified lines
6868 }
6969 %}
7070
71−ws [ \n\t]
7271 n [A-Za-z0-9_]
7372
7473 %%
scripts/kernel-doc+6−0
@@ -257,6 +257,7 @@ my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', · 256 unmodified lines
257257 'July', 'August', 'September', 'October',
258258 'November', 'December')[(localtime)[4]] .
259259 " " . ((localtime)[5]+1900);
260+my $show_not_found = 0;
260261
261262 # Essentially these are globals.
262263 # They probably want to be tidied up, made more localised or something.
@@ -369,6 +370,8 @@ while ($ARGV[0] =~ m/^-(.*)/) { · 106 unmodified lines
369370 usage();
370371 } elsif ($cmd eq '-no-doc-sections') {
371372 $no_doc_sections = 1;
373+ } elsif ($cmd eq '-show-not-found') {
374+ $show_not_found = 1;
372375 }
373376 }
374377
@@ -2535,6 +2538,9 @@ sub process_file($) { · 2160 unmodified lines
25352538 }
25362539 if ($initial_section_counter == $section_counter) {
25372540 print STDERR "Warning(${file}): no structured comments found\n";
2541+ if (($function_only == 1) && ($show_not_found == 1)) {
2542+ print STDERR " Was looking for '$_'.\n" for keys %function_table;
2543+ }
25382544 if ($output_mode eq "xml") {
25392545 # The template wants at least one RefEntry here; make one.
25402546 print "<refentry>\n";
scripts/link-vmlinux.sh+2−0
@@ -82,6 +82,8 @@ kallsyms() · 81 unmodified lines
8282 kallsymopt="${kallsymopt} --all-symbols"
8383 fi
8484
85+ kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
86+
8587 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
8688 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
8789
scripts/mod/modpost.c+25−12
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 #include <string.h>
1818 #include <limits.h>
1919 #include <stdbool.h>
20+#include <errno.h>
2021 #include "modpost.h"
2122 #include "../../include/generated/autoconf.h"
2223 #include "../../include/linux/license.h"
@@ -37,6 +38,8 @@ static int warn_unresolved = 0; · 14 unmodified lines
3738 /* How a symbol is exported */
3839 static int sec_mismatch_count = 0;
3940 static int sec_mismatch_verbose = 1;
41+/* ignore missing files */
42+static int ignore_missing_files;
4043
4144 enum export {
4245 export_plain, export_unused, export_gpl,
@@ -161,7 +164,7 @@ struct symbol { · 118 unmodified lines
161164 unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */
162165 unsigned int kernel:1; /* 1 if symbol is from kernel
163166 * (only for external modules) **/
164− unsigned int preloaded:1; /* 1 if symbol from Module.symvers */
167+ unsigned int preloaded:1; /* 1 if symbol from Module.symvers, or crc */
165168 enum export export; /* Type of export */
166169 char name[0];
167170 };
@@ -329,8 +332,11 @@ static void sym_update_crc(const char *name, struct module *mod, · 161 unmodified lines
329332 {
330333 struct symbol *s = find_symbol(name);
331334
332− if (!s)
335+ if (!s) {
333336 s = new_symbol(name, mod, export);
337+ /* Don't complain when we find it later. */
338+ s->preloaded = 1;
339+ }
334340 s->crc = crc;
335341 s->crc_valid = 1;
336342 }
@@ -407,6 +413,11 @@ static int parse_elf(struct elf_info *info, const char *filename) · 70 unmodified lines
407413
408414 hdr = grab_file(filename, &info->size);
409415 if (!hdr) {
416+ if (ignore_missing_files) {
417+ fprintf(stderr, "%s: %s (ignored)\n", filename,
418+ strerror(errno));
419+ return 0;
420+ }
410421 perror(filename);
411422 exit(1);
412423 }
@@ -599,18 +610,17 @@ static void handle_modversions(struct module *mod, struct elf_info *info, · 186 unmodified lines
599610 else
600611 export = export_from_sec(info, get_secindex(info, sym));
601612
613+ /* CRC'd symbol */
614+ if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
615+ crc = (unsigned int) sym->st_value;
616+ sym_update_crc(symname + strlen(CRC_PFX), mod, crc,
617+ export);
618+ }
619+
602620 switch (sym->st_shndx) {
603621 case SHN_COMMON:
604622 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
605623 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;
614624 case SHN_UNDEF:
615625 /* undefined symbol */
616626 if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL &&
@@ -1853,7 +1863,7 @@ static void add_header(struct buffer *b, struct module *mod) · 1236 unmodified lines
18531863 buf_printf(b, "\n");
18541864 buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
18551865 buf_printf(b, "\n");
1856− buf_printf(b, "struct module __this_module\n");
1866+ buf_printf(b, "__visible struct module __this_module\n");
18571867 buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
18581868 buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
18591869 if (mod->has_init)
@@ -2119,7 +2129,7 @@ int main(int argc, char **argv) · 259 unmodified lines
21192129 struct ext_sym_list *extsym_iter;
21202130 struct ext_sym_list *extsym_start = NULL;
21212131
2122− while ((opt = getopt(argc, argv, "i:I:e:msST:o:awM:K:")) != -1) {
2132+ while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:")) != -1) {
21232133 switch (opt) {
21242134 case 'i':
21252135 kernel_read = optarg;
@@ -2139,6 +2149,9 @@ int main(int argc, char **argv) · 13 unmodified lines
21392149 case 'm':
21402150 modversions = 1;
21412151 break;
2152+ case 'n':
2153+ ignore_missing_files = 1;
2154+ break;
21422155 case 'o':
21432156 dump_write = optarg;
21442157 break;
scripts/mod/sumversion.c+1−1
@@ -416,7 +416,7 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) · 415 unmodified lines
416416 basename = strrchr(modname, '/') + 1;
417417 else
418418 basename = modname;
419− sprintf(filelist, "%s/%.*s.mod", modverdir,
419+ snprintf(filelist, sizeof(filelist), "%s/%.*s.mod", modverdir,
420420 (int) strlen(basename) - 2, basename);
421421
422422 file = grab_file(filelist, &len);
scripts/package/Makefile+3−1
@@ -115,7 +115,9 @@ git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \ · 114 unmodified lines
115115 -o $(perf-tar).tar; \
116116 mkdir -p $(perf-tar); \
117117 git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
118−tar rf $(perf-tar).tar $(perf-tar)/HEAD; \
118+(cd $(srctree)/tools/perf; \
119+util/PERF-VERSION-GEN ../../$(perf-tar)/ 2>/dev/null); \
120+tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
119121 rm -r $(perf-tar); \
120122 $(if $(findstring tar-src,$@),, \
121123 $(if $(findstring bz2,$@),bzip2, \
scripts/recordmcount.pl+2−2
@@ -214,13 +214,13 @@ $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)"; · 213 unmodified lines
214214 $weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)";
215215 $section_regex = "Disassembly of section\\s+(\\S+):";
216216 $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
217−$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$";
217+$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s(mcount|__fentry__)\$";
218218 $section_type = '@progbits';
219219 $mcount_adjust = 0;
220220 $type = ".long";
221221
222222 if ($arch eq "x86_64") {
223− $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$";
223+ $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s(mcount|__fentry__)([+-]0x[0-9a-zA-Z]+)?\$";
224224 $type = ".quad";
225225 $alignment = 8;
226226 $mcount_adjust = -1;
scripts/sortextable.c+24−0
@@ -152,6 +152,30 @@ static void (*w2)(uint16_t, uint16_t *); · 151 unmodified lines
152152
153153 typedef void (*table_sort_t)(char *, int);
154154
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+
162+static 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" */
168+static 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+
155179 /* 32 bit and 64 bit are very similar */
156180 #include "sortextable.h"
157181 #define SORTEXTABLE_64
scripts/sortextable.h+23−3
@@ -98,6 +98,8 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort) · 97 unmodified lines
9898 Elf_Shdr *symtab_sec = NULL;
9999 Elf_Shdr *extab_sec = NULL;
100100 Elf_Sym *sym;
101+ const Elf_Sym *symtab;
102+ Elf32_Word *symtab_shndx_start = NULL;
101103 Elf_Sym *sort_needed_sym;
102104 Elf_Shdr *sort_needed_sec;
103105 Elf_Rel *relocs = NULL;
@@ -109,11 +111,22 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort) · 5 unmodified lines
109111 int extab_index = 0;
110112 int i;
111113 int idx;
114+ unsigned int num_sections;
115+ unsigned int secindex_strings;
112116
113117 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;
115128 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++) {
117130 idx = r(&shdr[i].sh_name);
118131 if (strcmp(secstrtab + idx, "__ex_table") == 0) {
119132 extab_sec = shdr + i;
@@ -129,6 +142,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort) · 9 unmodified lines
129142 symtab_sec = shdr + i;
130143 if (strcmp(secstrtab + idx, ".strtab") == 0)
131144 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));
132148 }
133149 if (strtab_sec == NULL) {
134150 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) · 3 unmodified lines
138154 fprintf(stderr, "no .symtab in file: %s\n", fname);
139155 fail_file();
140156 }
157+ symtab = (const Elf_Sym *)((const char *)ehdr +
158+ _r(&symtab_sec->sh_offset));
141159 if (extab_sec == NULL) {
142160 fprintf(stderr, "no __ex_table in file: %s\n", fname);
143161 fail_file();
@@ -176,7 +194,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort) · 32 unmodified lines
176194 fname);
177195 fail_file();
178196 }
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)];
180200 sort_done_location = (void *)ehdr +
181201 _r(&sort_needed_sec->sh_offset) +
182202 _r(&sort_needed_sym->st_value) -