All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Hong <lihong.hi@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 4/9] tracing: recordmcount.pl Objcopy check should disable local reference correctly
Date: Tue, 27 Oct 2009 15:00:11 +0800	[thread overview]
Message-ID: <20091027070011.GD22032@uhli> (raw)
In-Reply-To: <20091027065421.GA22032@uhli>

>From 580ea035d04d4ca58300423db3dd5b4c73c8d61c Mon Sep 17 00:00:00 2001
From: Li Hong <lihong.hi@gmail.com>
Date: Tue, 27 Oct 2009 12:41:22 +0800
Subject: [PATCH] tracing: recordmcount.pl Objcopy check should disable local reference correctly

Use a function to do objcopy version check. Disable the local reference if
copy can't support it. Remove some unused variables.

Signed-off-by: Li Hong <lihong.hi@gmail.com>

diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 94daf9e..970c6d6 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -155,6 +155,28 @@ my $function_regex;	# Find the name of a function
 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);
+
+    print STDERR "WARNING: could not find objcopy version or version is less than 2.17.\n" .
+	"\tLocal function references is disabled.\n" if !$can_use_local; 
+}
 
 if ($arch eq "x86") {
     if ($bits == 64) {
@@ -289,34 +311,7 @@ if ($filename =~ m,^(.*)(\.\S),) {
 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.
@@ -363,7 +358,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;
-- 
1.6.0.4


  parent reply	other threads:[~2009-10-27  7:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27  6:54 [PATCH 1/9] tracing: recordmcount.pl Amend the documentation according to the implementation Li Hong
2009-10-27  6:57 ` [PATCH 2/9] tracing: recordmcount.pl Correct the check on the number of parameters Li Hong
2009-10-30 16:19   ` [tip:tracing/core] tracing: Correct the check for number of arguments in recordmcount.pl tip-bot for Li Hong
2009-10-27  6:58 ` [PATCH 3/9] tracing: recordmcount.pl Support absolute path check on $inputfile Li Hong
2009-10-27 20:12   ` Steven Rostedt
2009-10-27  7:00 ` Li Hong [this message]
2009-10-27 20:16   ` [PATCH 4/9] tracing: recordmcount.pl Objcopy check should disable local reference correctly Steven Rostedt
2009-10-27  7:01 ` [PATCH 5/9] tracing: recordmcount.pl Clarify the logic on mcount section check Li Hong
2009-10-27 20:18   ` Steven Rostedt
2009-10-27  7:02 ` [PATCH 6/9] tracing: recordmcount.pl Exit early if no work to do Li Hong
2009-10-27 20:20   ` Steven Rostedt
2009-10-27  7:03 ` [PATCH 7/9] tracing: recordmcount.pl Combine the condition validation in update_funcs Li Hong
2009-10-27 20:22   ` Steven Rostedt
2009-10-27  7:04 ` [PATCH 8/9] tracing: recordmcount.pl We won't use weak function as reference, remove the check Li Hong
2009-10-27 20:25   ` Steven Rostedt
2009-10-27  7:05 ` [PATCH 9/9] tracing: recordmcount.pl Remove the redundant code Li Hong
2009-10-27 20:51   ` Steven Rostedt
2009-10-27 20:04 ` [PATCH 1/9] tracing: recordmcount.pl Amend the documentation according to the implementation Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091027070011.GD22032@uhli \
    --to=lihong.hi@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.