Re: ftrace scripts and make V=1

Subsystems: the rest

3 messages, 2 authors, 2009-08-06 · open the first message on its own page

Re: ftrace scripts and make V=1

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2009-08-06 02:00:18

On Wed, 5 Aug 2009, Ingo Molnar wrote:
* Dave Airlie [off-list ref] wrote:
quoted
Hey,

So I spent 3-4 hrs today (I'm stupid yes) tracking down a .o 
breakage by blaming rawhide gcc/binutils as I was using make 
V=1and seeing only the compiler chain running,
Hm, is this that powerpc related build bug you just reported?
Well we tracked it down and it is powerpc64 specific.

Seems that in drivers/hwmon/lm93.c there's a function called:

   LM93_IN_FROM_REG()

But PPC64 has function descriptors and the real function names (the ones 
you see in objdump) start with a '.'. Thus this in objdump you have:

 Disassembly of section .text:

 0000000000000000 <.LM93_IN_FROM_REG>:
       0:       7c 08 02 a6     mflr    r0
       4:       fb 81 ff e0     std     r28,-32(r1)


The function name used is .LM93_IN_FROM_REG. But gcc considers symbols 
that start with ".L" as a special symbol that is used inside the assembly 
stage.

The nm passed into recordmcount uses the --synthetic option which shows 
the ".L" symbols (my runs outside of the build did not include the 
--synthetic option, so my older patch worked). We see the function as a 
local.

Now to capture all the locations that use "mcount" we need to have a 
reference to link into the object file a list of mcount callers. We need a 
reference that will not disappear. We try to use a global function and if 
that does not work, we use a local function as a reference. But to relink 
the section back into the object, we need to make it global. In this case, 
we run objcopy using --globalize-symbol and --localize-symbol to convert 
the symbol into a global symbol, link the mcount list, then convert it 
back to a local symbol.

This works great except for this case. .L* symbols can not be converted 
into a global symbol, and the mcount section referencing it will remain 
unresolved.

Try this patch and see if it fixes your issue.

Thanks!

-- Steve
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index d29baa2..4889c44 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -414,7 +414,10 @@ while (<IN>) {
 	    $offset = hex $1;
 	} else {
 	    # if we already have a function, and this is weak, skip it
-	    if (!defined($ref_func) && !defined($weak{$text})) {
+	    if (!defined($ref_func) && !defined($weak{$text}) &&
+		 # PPC64 can have symbols that start with .L and
+		 # gcc considers these special. Don't use them!
+		 $text !~ /^\.L/) {
 		$ref_func = $text;
 		$offset = hex $1;
 	    }

Re: ftrace scripts and make V=1

From: Ingo Molnar <hidden>
Date: 2009-08-06 03:43:47

* Steven Rostedt [off-list ref] wrote:
quoted hunk
Well we tracked it down and it is powerpc64 specific.

Seems that in drivers/hwmon/lm93.c there's a function called:

   LM93_IN_FROM_REG()

But PPC64 has function descriptors and the real function names (the ones 
you see in objdump) start with a '.'. Thus this in objdump you have:

 Disassembly of section .text:

 0000000000000000 <.LM93_IN_FROM_REG>:
       0:       7c 08 02 a6     mflr    r0
       4:       fb 81 ff e0     std     r28,-32(r1)


The function name used is .LM93_IN_FROM_REG. But gcc considers 
symbols that start with ".L" as a special symbol that is used 
inside the assembly stage.

The nm passed into recordmcount uses the --synthetic option which 
shows the ".L" symbols (my runs outside of the build did not 
include the --synthetic option, so my older patch worked). We see 
the function as a local.

Now to capture all the locations that use "mcount" we need to have 
a reference to link into the object file a list of mcount callers. 
We need a reference that will not disappear. We try to use a 
global function and if that does not work, we use a local function 
as a reference. But to relink the section back into the object, we 
need to make it global. In this case, we run objcopy using 
--globalize-symbol and --localize-symbol to convert the symbol 
into a global symbol, link the mcount list, then convert it back 
to a local symbol.

This works great except for this case. .L* symbols can not be 
converted into a global symbol, and the mcount section referencing 
it will remain unresolved.

Try this patch and see if it fixes your issue.

Thanks!

-- Steve
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index d29baa2..4889c44 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -414,7 +414,10 @@ while (<IN>) {
 	    $offset = hex $1;
 	} else {
 	    # if we already have a function, and this is weak, skip it
-	    if (!defined($ref_func) && !defined($weak{$text})) {
+	    if (!defined($ref_func) && !defined($weak{$text}) &&
+		 # PPC64 can have symbols that start with .L and
+		 # gcc considers these special. Don't use them!
+		 $text !~ /^\.L/) {
 		$ref_func = $text;
 		$offset = hex $1;
 	    }
Ah, indeed. I'm wondering whether also emitting a build warning 
would be useful - just in the (admittedly unlikely) case of someone 
wondering about why LM93_IN_FROM_REG does not show up in function 
traces.

	Ingo

Re: ftrace scripts and make V=1

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2009-08-06 15:02:23

On Thu, 6 Aug 2009, Ingo Molnar wrote:
quoted
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index d29baa2..4889c44 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -414,7 +414,10 @@ while (<IN>) {
 	    $offset = hex $1;
 	} else {
 	    # if we already have a function, and this is weak, skip it
-	    if (!defined($ref_func) && !defined($weak{$text})) {
+	    if (!defined($ref_func) && !defined($weak{$text}) &&
+		 # PPC64 can have symbols that start with .L and
+		 # gcc considers these special. Don't use them!
+		 $text !~ /^\.L/) {
 		$ref_func = $text;
 		$offset = hex $1;
 	    }
Ah, indeed. I'm wondering whether also emitting a build warning 
would be useful - just in the (admittedly unlikely) case of someone 
wondering about why LM93_IN_FROM_REG does not show up in function 
traces.
Actually, it just skips it as the function to use as the reference point. 
It should still record the mcount for that function. Now we may have an 
issues if all functions in a section start with .L

-- Steve
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help