Skip to content

Commit

Permalink
tracing: Fix objcopy revision check in recordmcount.pl
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Li Hong authored and Steven Rostedt committed Oct 29, 2009
1 parent bdd3b05 commit 7b7edc2
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions scripts/recordmcount.pl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,31 @@
my $mcount_regex; # Find the call site to mcount (return offset)
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

##
# check_objcopy - whether objcopy supports --globalize-symbols
#
# --globalize-symbols came out in 2.17, we must test the version
# of objcopy, and if it is less than 2.17, then we can not
# record local functions.
sub check_objcopy
{
open (IN, "$objcopy --version |") or die "error running $objcopy";
while (<IN>) {
if (/objcopy.*\s(\d+)\.(\d+)/) {
$can_use_local = 1 if ($1 > 2 || ($1 == 2 && $2 >= 17));
last;
}
}
close (IN);

if (!$can_use_local) {
print STDERR "WARNING: could not find objcopy version or version " .
"is less than 2.17.\n" .
"\tLocal function references is disabled.\n";
}
}

if ($arch eq "x86") {
if ($bits == 64) {
Expand Down Expand Up @@ -293,34 +318,7 @@
my $mcount_s = $dirname . "/.tmp_mc_" . $prefix . ".s";
my $mcount_o = $dirname . "/.tmp_mc_" . $prefix . ".o";

#
# --globalize-symbols came out in 2.17, we must test the version
# of objcopy, and if it is less than 2.17, then we can not
# record local functions.
my $use_locals = 01;
my $local_warn_once = 0;
my $found_version = 0;

open (IN, "$objcopy --version |") || die "error running $objcopy";
while (<IN>) {
if (/objcopy.*\s(\d+)\.(\d+)/) {
my $major = $1;
my $minor = $2;

$found_version = 1;
if ($major < 2 ||
($major == 2 && $minor < 17)) {
$use_locals = 0;
}
last;
}
}
close (IN);

if (!$found_version) {
print STDERR "WARNING: could not find objcopy version.\n" .
"\tDisabling local function references.\n";
}
check_objcopy();

#
# Step 1: find all the local (static functions) and weak symbols.
Expand Down Expand Up @@ -367,7 +365,7 @@ sub update_funcs
if (defined $locals{$ref_func}) {

# only use locals if objcopy supports globalize-symbols
if (!$use_locals) {
if (!$can_use_local) {
return;
}
$convert{$ref_func} = 1;
Expand Down

0 comments on commit 7b7edc2

Please sign in to comment.