oom: kill duplicate OOM_DISABLE check
[sfrench/cifs-2.6.git] / scripts / recordmcount.pl
index ea6f6e3adaea342246e3fc5b933e32dbd84f0fed..0171060b5fd654e66434bc9f3ef3ee9064296d35 100755 (executable)
@@ -136,13 +136,14 @@ my %text_sections = (
      ".text.unlikely" => 1,
 );
 
-$objdump = "objdump" if ((length $objdump) == 0);
-$objcopy = "objcopy" if ((length $objcopy) == 0);
-$cc = "gcc" if ((length $cc) == 0);
-$ld = "ld" if ((length $ld) == 0);
-$nm = "nm" if ((length $nm) == 0);
-$rm = "rm" if ((length $rm) == 0);
-$mv = "mv" if ((length $mv) == 0);
+# Note: we are nice to C-programmers here, thus we skip the '||='-idiom.
+$objdump = 'objdump' if (!$objdump);
+$objcopy = 'objcopy' if (!$objcopy);
+$cc = 'gcc' if (!$cc);
+$ld = 'ld' if (!$ld);
+$nm = 'nm' if (!$nm);
+$rm = 'rm' if (!$rm);
+$mv = 'mv' if (!$mv);
 
 #print STDERR "running: $P '$arch' '$objdump' '$objcopy' '$cc' '$ld' " .
 #    "'$nm' '$rm' '$mv' '$inputfile'\n";
@@ -325,7 +326,7 @@ if ($arch eq "x86_64") {
     #                    14: R_MIPS_NONE *ABS*
     #   18:   00020021        nop
     if ($is_module eq "0") {
-           $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
+           $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_26\\s+_mcount\$";
     } else {
            $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$";
     }
@@ -432,14 +433,14 @@ sub update_funcs
 
     # Loop through all the mcount caller offsets and print a reference
     # to the caller based from the ref_func.
-    for (my $i=0; $i <= $#offsets; $i++) {
-       if (!$opened) {
-           open(FILE, ">$mcount_s") || die "can't create $mcount_s\n";
-           $opened = 1;
-           print FILE "\t.section $mcount_section,\"a\",$section_type\n";
-           print FILE "\t.align $alignment\n" if (defined($alignment));
-       }
-       printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset;
+    if (!$opened) {
+       open(FILE, ">$mcount_s") || die "can't create $mcount_s\n";
+       $opened = 1;
+       print FILE "\t.section $mcount_section,\"a\",$section_type\n";
+       print FILE "\t.align $alignment\n" if (defined($alignment));
+    }
+    foreach my $cur_offset (@offsets) {
+       printf FILE "\t%s %s + %d\n", $type, $ref_func, $cur_offset - $offset;
     }
 }
 
@@ -476,11 +477,7 @@ while (<IN>) {
        $read_headers = 0;
 
        # Only record text sections that we know are safe
-       if (defined($text_sections{$1})) {
-           $read_function = 1;
-       } else {
-           $read_function = 0;
-       }
+       $read_function = defined($text_sections{$1});
        # print out any recorded offsets
        update_funcs();
 
@@ -514,7 +511,7 @@ while (<IN>) {
     }
     # is this a call site to mcount? If so, record it to print later
     if ($text_found && /$mcount_regex/) {
-       $offsets[$#offsets + 1] = hex $1;
+       push(@offsets, hex $1);
     }
 }