Skip to content

Commit

Permalink
tracing: Add regex for weak functions in recordmcount.pl
Browse files Browse the repository at this point in the history
Add a variable to contain the regex needed to find weak functions
in the 'nm' output. This will allow other archs to easily override it.

Also rename the regex variable $nm_regex to $local_regex to be more
descriptive.

Signed-off-by: Li Hong <lihong.hi@gmail.com>
LKML-Reference: <20091028050619.GF30758@uhli>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Li Hong authored and Steven Rostedt committed Oct 29, 2009
1 parent db24c7d commit 306dcf4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions scripts/recordmcount.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -152,7 +152,8 @@
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)
Expand Down Expand Up @@ -197,7 +198,8 @@ sub check_objcopy
# 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\$";
Expand Down Expand Up @@ -246,7 +248,7 @@ sub check_objcopy
$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\$";

Expand Down Expand Up @@ -322,13 +324,13 @@ sub 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;
}
}
Expand Down

0 comments on commit 306dcf4

Please sign in to comment.