Skip to content

Commit 306dcf4

Browse files
swanlirostedt
authored andcommitted
tracing: Add regex for weak functions in recordmcount.pl
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>
1 parent db24c7d commit 306dcf4

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

‎scripts/recordmcount.pl‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
#
9393
# Here are the steps we take:
9494
#
95-
# 1) Record all the local symbols by using 'nm'
95+
# 1) Record all the local and weak symbols by using 'nm'
9696
# 2) Use objdump to find all the call site offsets and sections for
9797
# mcount.
9898
# 3) Compile the list into its own object.
@@ -152,7 +152,8 @@
152152
my %convert; # List of local functions used that needs conversion
153153

154154
my $type;
155-
my $nm_regex; # Find the local functions (return function)
155+
my $local_regex; # Match a local function (return function)
156+
my $weak_regex; # Match a weak function (return function)
156157
my $section_regex; # Find the start of a section
157158
my $function_regex; # Find the name of a function
158159
# (return offset and func name)
@@ -197,7 +198,8 @@ sub check_objcopy
197198
# We base the defaults off of i386, the other archs may
198199
# feel free to change them in the below if statements.
199200
#
200-
$nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
201+
$local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
202+
$weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)";
201203
$section_regex = "Disassembly of section\\s+(\\S+):";
202204
$function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
203205
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$";
@@ -246,7 +248,7 @@ sub check_objcopy
246248
$cc .= " -m32";
247249

248250
} elsif ($arch eq "powerpc") {
249-
$nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
251+
$local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
250252
$function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:";
251253
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
252254

@@ -322,13 +324,13 @@ sub check_objcopy
322324

323325
#
324326
# Step 1: find all the local (static functions) and weak symbols.
325-
# 't' is local, 'w/W' is weak (we never use a weak function)
327+
# 't' is local, 'w/W' is weak
326328
#
327329
open (IN, "$nm $inputfile|") || die "error running $nm";
328330
while (<IN>) {
329-
if (/$nm_regex/) {
331+
if (/$local_regex/) {
330332
$locals{$1} = 1;
331-
} elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) {
333+
} elsif (/$weak_regex/) {
332334
$weak{$2} = $1;
333335
}
334336
}

0 commit comments

Comments
 (0)