From: Steven Rostedt <srostedt@redhat.com>
Subject: ftrace: objcopy version test for local symbols
The --globalize-symbols option came out in objcopy version 2.17.
If the kernel is being compiled on a system with a lower version of
objcopy, then we can not use the globalize / localize trick to
link to symbols pointing to local functions.
This patch tests the version of objcopy and will only use the trick
if the version is greater than or equal to 2.17. Otherwise, if an
object has only local functions within a section, it will give a
nice warning and recommend the user to upgrade their objcopy.
Leaving the symbols unrecorded is not that big of a deal, since the
mcount record method changes the actual mcount code to be a simple
"ret" without recording registers or anything.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
scripts/recordmcount.pl | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
Index: linux-tip.git/scripts/recordmcount.pl
===================================================================
--- linux-tip.git.orig/scripts/recordmcount.pl 2008-08-25 14:02:03.000000000 -0400
+++ linux-tip.git/scripts/recordmcount.pl 2008-08-25 14:38:36.000000000 -0400
@@ -187,6 +187,36 @@ my $mcount_s = $dirname . "/.tmp_mc_" .
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 ...applied to tip/tracing/ftrace, also have integrated it into auto-ftrace-next. (without much testing - i hope it goes well) Ingo --
Hi Ingo, Steve, I was right, it produces way to many messages :-( I applied the following patch for now. It would be nice if this check could be done once per build and warned about once as well. -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ From 54bc3035c76a242d14df554966110e5964b3eac3 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell <sfr@canb.auug.org.au> Date: Tue, 26 Aug 2008 11:45:01 +1000 Subject: [PATCH] ftrace: silence overly verbose warning Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> --- scripts/recordmcount.pl | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index ee9e126..ef0c6db 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -262,12 +262,12 @@ sub update_funcs # only use locals if objcopy supports globalize-symbols if (!$use_locals) { - print STDERR - "$inputfile: WARNING: referencing local function " . - "$ref_func for mcount\n" . - "\tConsider upgrading objcopy to support the globalize-" . - "symbols option.\n" - if (!$local_warn_once++); +# print STDERR +# "$inputfile: WARNING: referencing local function " . +# "$ref_func for mcount\n" . +# "\tConsider upgrading objcopy to support the globalize-" . +# "symbols option.\n" +# if (!$local_warn_once++); return; } $convert{$ref_func} = 1; -- 1.5.6.3 --
Actually, there is a way. I'll write one up and send it out. -- Steve --
[ Stephen, can you try to see if this works for you, with the issue of spamming warnings? Thanks, -- Steve ] Older versions of objcopy do not support the --globalize-symbols option, which prevent mcount calls in local functions within their own sections from being reference by the mcount_loc table. We want to warn the user about this out of date objcopy without spamming them with warning messages. To do this, we create a .tmp_mcversion and compare it with the .version to see if we have already warned the user for that build. Signed-off-by: Steven Rostedt <srostedt@redhat.com> --- Makefile | 3 +- scripts/recordmcount.pl | 69 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 7 deletions(-) Index: linux-tip.git/Makefile =================================================================== --- linux-tip.git.orig/Makefile 2008-08-25 14:01:57.000000000 -0400 +++ linux-tip.git/Makefile 2008-08-25 23:17:57.000000000 -0400 @@ -1155,7 +1155,8 @@ endif # CONFIG_MODULES # Directories & files removed with 'make clean' CLEAN_DIRS += $(MODVERDIR) CLEAN_FILES += vmlinux System.map \ - .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map + .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map \ + .tmp_mcversion # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include2 usr/include Index: linux-tip.git/scripts/recordmcount.pl =================================================================== --- linux-tip.git.orig/scripts/recordmcount.pl 2008-08-25 16:23:29.000000000 -0400 +++ linux-tip.git/scripts/recordmcount.pl 2008-08-25 23:19:52.000000000 -0400 @@ -96,6 +96,8 @@ use strict; my $P = $0; +my $D = $P; +$D =~ s@(.*)/.*@$1@; $P =~ s@.*/@@g; my $V = '0.1'; @@ -235,6 +237,66 @@ my $ref_func; # reference function to u my $offset = 0; # offset of ref_func to section beginning ## +# warn_on_local - check to see if ...
Hi Steve, On Mon, 25 Aug 2008 23:25:25 -0400 (EDT) Steven Rostedt <rostedt@goodmis.or= I get no warnings at all. I think this is because I always build with O=3D... so that the way you find $topdir (and therefore the .version file) does not work. --=20 Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/
Hmm, Well we don't need the warning, although it would be nice to give. There seems to be a lot of hacking to get a warning for this. Perhaps we just ignore the local functions and not warn at all? -- Steve --
The warning messages about old objcopy and local functions spam the
user quite drastically. Remove the warning until we can find a nicer
way of tell the user to upgrade their objcopy.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
scripts/recordmcount.pl | 6 ------
1 file changed, 6 deletions(-)
Index: linux-tip.git/scripts/recordmcount.pl
===================================================================
--- linux-tip.git.orig/scripts/recordmcount.pl 2008-08-27 12:57:40.000000000 -0400
+++ linux-tip.git/scripts/recordmcount.pl 2008-08-27 12:58:03.000000000 -0400
@@ -262,12 +262,6 @@ sub update_funcs
# only use locals if objcopy supports globalize-symbols
if (!$use_locals) {
- print STDERR
- "$inputfile: WARNING: referencing local function " .
- "$ref_func for mcount\n" .
- "\tConsider upgrading objcopy to support the globalize-" .
- "symbols option.\n"
- if (!$local_warn_once++);
return;
}
$convert{$ref_func} = 1;
--
applied to tip/tracing/ftrace, thanks! Ingo --
