diff options
author | Li Hong <lihong.hi@gmail.com> | 2009-10-28 01:04:21 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-10-29 15:11:44 -0400 |
commit | 7b7edc27683e20624f4daf17c76041719184201c (patch) | |
tree | b57ffdec8159e506d28cf22a58cff44b1a82fb92 /scripts | |
parent | bdd3b052c63b2c19a0118937f500985c01a19956 (diff) |
tracing: Fix objcopy revision check in recordmcount.pl
The current logic to check objcopy's version is incorrect. This patch
fixes the algorithm and disables the use of local functions as a reference
if the objcopy version does not support static to global conversions.
Also remove some usused variables.
Signed-off-by: Li Hong <lihong.hi@gmail.com>
LKML-Reference: <20091028050421.GD30758@uhli>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/recordmcount.pl | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index b80e5d04416b..d6199fc4870a 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl | |||
@@ -159,6 +159,31 @@ my $function_regex; # Find the name of a function | |||
159 | my $mcount_regex; # Find the call site to mcount (return offset) | 159 | my $mcount_regex; # Find the call site to mcount (return offset) |
160 | my $alignment; # The .align value to use for $mcount_section | 160 | my $alignment; # The .align value to use for $mcount_section |
161 | my $section_type; # Section header plus possible alignment command | 161 | my $section_type; # Section header plus possible alignment command |
162 | my $can_use_local = 0; # If we can use local function references | ||
163 | |||
164 | ## | ||
165 | # check_objcopy - whether objcopy supports --globalize-symbols | ||
166 | # | ||
167 | # --globalize-symbols came out in 2.17, we must test the version | ||
168 | # of objcopy, and if it is less than 2.17, then we can not | ||
169 | # record local functions. | ||
170 | sub check_objcopy | ||
171 | { | ||
172 | open (IN, "$objcopy --version |") or die "error running $objcopy"; | ||
173 | while (<IN>) { | ||
174 | if (/objcopy.*\s(\d+)\.(\d+)/) { | ||
175 | $can_use_local = 1 if ($1 > 2 || ($1 == 2 && $2 >= 17)); | ||
176 | last; | ||
177 | } | ||
178 | } | ||
179 | close (IN); | ||
180 | |||
181 | if (!$can_use_local) { | ||
182 | print STDERR "WARNING: could not find objcopy version or version " . | ||
183 | "is less than 2.17.\n" . | ||
184 | "\tLocal function references is disabled.\n"; | ||
185 | } | ||
186 | } | ||
162 | 187 | ||
163 | if ($arch eq "x86") { | 188 | if ($arch eq "x86") { |
164 | if ($bits == 64) { | 189 | if ($bits == 64) { |
@@ -293,34 +318,7 @@ if ($filename =~ m,^(.*)(\.\S),) { | |||
293 | my $mcount_s = $dirname . "/.tmp_mc_" . $prefix . ".s"; | 318 | my $mcount_s = $dirname . "/.tmp_mc_" . $prefix . ".s"; |
294 | my $mcount_o = $dirname . "/.tmp_mc_" . $prefix . ".o"; | 319 | my $mcount_o = $dirname . "/.tmp_mc_" . $prefix . ".o"; |
295 | 320 | ||
296 | # | 321 | check_objcopy(); |
297 | # --globalize-symbols came out in 2.17, we must test the version | ||
298 | # of objcopy, and if it is less than 2.17, then we can not | ||
299 | # record local functions. | ||
300 | my $use_locals = 01; | ||
301 | my $local_warn_once = 0; | ||
302 | my $found_version = 0; | ||
303 | |||
304 | open (IN, "$objcopy --version |") || die "error running $objcopy"; | ||
305 | while (<IN>) { | ||
306 | if (/objcopy.*\s(\d+)\.(\d+)/) { | ||
307 | my $major = $1; | ||
308 | my $minor = $2; | ||
309 | |||
310 | $found_version = 1; | ||
311 | if ($major < 2 || | ||
312 | ($major == 2 && $minor < 17)) { | ||
313 | $use_locals = 0; | ||
314 | } | ||
315 | last; | ||
316 | } | ||
317 | } | ||
318 | close (IN); | ||
319 | |||
320 | if (!$found_version) { | ||
321 | print STDERR "WARNING: could not find objcopy version.\n" . | ||
322 | "\tDisabling local function references.\n"; | ||
323 | } | ||
324 | 322 | ||
325 | # | 323 | # |
326 | # Step 1: find all the local (static functions) and weak symbols. | 324 | # Step 1: find all the local (static functions) and weak symbols. |
@@ -367,7 +365,7 @@ sub update_funcs | |||
367 | if (defined $locals{$ref_func}) { | 365 | if (defined $locals{$ref_func}) { |
368 | 366 | ||
369 | # only use locals if objcopy supports globalize-symbols | 367 | # only use locals if objcopy supports globalize-symbols |
370 | if (!$use_locals) { | 368 | if (!$can_use_local) { |
371 | return; | 369 | return; |
372 | } | 370 | } |
373 | $convert{$ref_func} = 1; | 371 | $convert{$ref_func} = 1; |