sysfs: Nicely indent sysfs_symlink_inode_operations
[safe/jmp/linux-2.6] / scripts / recordmcount.pl
index 02c8055..f0d1445 100755 (executable)
@@ -92,7 +92,7 @@
 #
 # Here are the steps we take:
 #
-# 1) Record all the local symbols by using 'nm'
+# 1) Record all the local and weak symbols by using 'nm'
 # 2) Use objdump to find all the call site offsets and sections for
 #    mcount.
 # 3) Compile the list into its own object.
@@ -152,7 +152,8 @@ my %weak;           # List of weak functions
 my %convert;           # List of local functions used that needs conversion
 
 my $type;
-my $nm_regex;          # Find the local functions (return function)
+my $local_regex;       # Match a local function (return function)
+my $weak_regex;        # Match a weak function (return function)
 my $section_regex;     # Find the start of a section
 my $function_regex;    # Find the name of a function
                        #    (return offset and func name)
@@ -161,6 +162,11 @@ my $alignment;             # The .align value to use for $mcount_section
 my $section_type;      # Section header plus possible alignment command
 my $can_use_local = 0;         # If we can use local function references
 
+# Shut up recordmcount if user has older objcopy
+my $quiet_recordmcount = ".tmp_quiet_recordmcount";
+my $print_warning = 1;
+$print_warning = 0 if ( -f $quiet_recordmcount);
+
 ##
 # check_objcopy - whether objcopy supports --globalize-symbols
 #
@@ -178,10 +184,13 @@ sub check_objcopy
     }
     close (IN);
 
-    if (!$can_use_local) {
+    if (!$can_use_local && $print_warning) {
        print STDERR "WARNING: could not find objcopy version or version " .
            "is less than 2.17.\n" .
-           "\tLocal function references is disabled.\n";
+           "\tLocal function references are disabled.\n";
+       open (QUIET, ">$quiet_recordmcount");
+       printf QUIET "Disables the warning from recordmcount.pl\n";
+       close QUIET;
     }
 }
 
@@ -197,7 +206,8 @@ if ($arch eq "x86") {
 # We base the defaults off of i386, the other archs may
 # feel free to change them in the below if statements.
 #
-$nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
+$local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
+$weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)";
 $section_regex = "Disassembly of section\\s+(\\S+):";
 $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$";
@@ -246,7 +256,7 @@ if ($arch eq "x86_64") {
     $cc .= " -m32";
 
 } elsif ($arch eq "powerpc") {
-    $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
+    $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
     $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:";
     $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
 
@@ -322,13 +332,13 @@ check_objcopy();
 
 #
 # Step 1: find all the local (static functions) and weak symbols.
-#        't' is local, 'w/W' is weak (we never use a weak function)
+#         't' is local, 'w/W' is weak
 #
 open (IN, "$nm $inputfile|") || die "error running $nm";
 while (<IN>) {
-    if (/$nm_regex/) {
+    if (/$local_regex/) {
        $locals{$1} = 1;
-    } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) {
+    } elsif (/$weak_regex/) {
        $weak{$2} = $1;
     }
 }
@@ -346,19 +356,13 @@ my $offset = 0;           # offset of ref_func to section beginning
 #
 sub update_funcs
 {
-    return if ($#offsets < 0);
-
-    defined($ref_func) || die "No function to reference";
+    return unless ($ref_func and @offsets);
 
-    # A section only had a weak function, to represent it.
-    # Unfortunately, a weak function may be overwritten by another
-    # function of the same name, making all these offsets incorrect.
-    # To be safe, we simply print a warning and bail.
+    # Sanity check on weak function. A weak function may be overwritten by
+    # another function of the same name, making all these offsets incorrect.
     if (defined $weak{$ref_func}) {
-       print STDERR
-           "$inputfile: WARNING: referencing weak function" .
+       die "$inputfile: ERROR: referencing weak function" .
            " $ref_func for mcount\n";
-       return;
     }
 
     # is this function static? If so, note this fact.
@@ -423,7 +427,7 @@ while (<IN>) {
            $read_function = 0;
        }
        # print out any recorded offsets
-       update_funcs() if (defined($ref_func));
+       update_funcs();
 
        # reset all markers and arrays
        $text_found = 0;
@@ -460,7 +464,7 @@ while (<IN>) {
 }
 
 # dump out anymore offsets that may have been found
-update_funcs() if (defined($ref_func));
+update_funcs();
 
 # If we did not find any mcount callers, we are done (do nothing).
 if (!$opened) {