Commit 306dcf47d28aaf9aedfafb17a602768584cfc0f2

Authored by Li Hong
Committed by Steven Rostedt
1 parent db24c7dcf4

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>

Showing 1 changed file with 9 additions and 7 deletions Side-by-side Diff

scripts/recordmcount.pl
... ... @@ -92,7 +92,7 @@
92 92 #
93 93 # Here are the steps we take:
94 94 #
95   -# 1) Record all the local symbols by using 'nm'
  95 +# 1) Record all the local and weak symbols by using 'nm'
96 96 # 2) Use objdump to find all the call site offsets and sections for
97 97 # mcount.
98 98 # 3) Compile the list into its own object.
... ... @@ -152,7 +152,8 @@
152 152 my %convert; # List of local functions used that needs conversion
153 153  
154 154 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)
156 157 my $section_regex; # Find the start of a section
157 158 my $function_regex; # Find the name of a function
158 159 # (return offset and func name)
... ... @@ -197,7 +198,8 @@
197 198 # We base the defaults off of i386, the other archs may
198 199 # feel free to change them in the below if statements.
199 200 #
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+)";
201 203 $section_regex = "Disassembly of section\\s+(\\S+):";
202 204 $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
203 205 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$";
... ... @@ -246,7 +248,7 @@
246 248 $cc .= " -m32";
247 249  
248 250 } 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+)";
250 252 $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:";
251 253 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
252 254  
253 255  
254 256  
... ... @@ -322,13 +324,13 @@
322 324  
323 325 #
324 326 # 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
326 328 #
327 329 open (IN, "$nm $inputfile|") || die "error running $nm";
328 330 while (<IN>) {
329   - if (/$nm_regex/) {
  331 + if (/$local_regex/) {
330 332 $locals{$1} = 1;
331   - } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) {
  333 + } elsif (/$weak_regex/) {
332 334 $weak{$2} = $1;
333 335 }
334 336 }