From fc4c73554c9d93b3e495f2f7acae1323b0d5db84 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Thu, 23 Jul 2009 17:16:14 +0100 Subject: ftrace: Fix the conditional that updates $ref_func Fix the conditional that checks if we already have a $ref_func and that the new function is weak. The code as previously checking whether either condition was false, and we really need to only update $ref_func is both cconditions are false. Signed-off-by: Matt Fleming LKML-Reference: <1248365775-25196-1-git-send-email-matt@console-pimps.org> Signed-off-by: Steven Rostedt --- scripts/recordmcount.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/recordmcount.pl') diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 7109e2b..16c5563 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -414,7 +414,7 @@ while () { $read_function = 0; } 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})) { $ref_func = $text; } } -- cgit v1.1 From bd171d5ffc5cb2ba471e8205c679ee9d12b90116 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Thu, 23 Jul 2009 17:16:15 +0100 Subject: ftrace: Only update $offset when we update $ref_func The value of $offset should be the offset of $ref_func from the beginning of the object file. Therefore, we should set both variables together. This fixes a bug I was hitting on sh where $offset (which is used to calcualte the addends for the __mcount_loc entries) was being set multiple times and didn't correspond to $ref_func's offset in the object file. The addends in __mcount_loc were calculated incorrectly, resulting in ftrace dynamically modifying addresses that weren't mcount call sites. Signed-off-by: Matt Fleming LKML-Reference: <1248365775-25196-2-git-send-email-matt@console-pimps.org> Signed-off-by: Steven Rostedt --- scripts/recordmcount.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/recordmcount.pl') diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 16c5563..d29baa2 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -403,7 +403,6 @@ while () { # section found, now is this a start of a function? } elsif ($read_function && /$function_regex/) { $text_found = 1; - $offset = hex $1; $text = $2; # if this is either a local function or a weak function @@ -412,10 +411,12 @@ while () { if (!defined($locals{$text}) && !defined($weak{$text})) { $ref_func = $text; $read_function = 0; + $offset = hex $1; } else { # if we already have a function, and this is weak, skip it if (!defined($ref_func) && !defined($weak{$text})) { $ref_func = $text; + $offset = hex $1; } } } elsif ($read_headers && /$mcount_section/) { -- cgit v1.1 From 3f6e968ef4e1d8d93d8a8505461b0e50a9e97ad8 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Wed, 5 Aug 2009 22:00:14 -0400 Subject: tracing: do not use functions starting with .L in recordmcount.pl On Wed, 5 Aug 2009, Ingo Molnar wrote: > * Dave Airlie wrote: > > > 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. Reported-by: Dave Airlie LKML-Reference: Signed-off-by: Steven Rostedt --- scripts/recordmcount.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/recordmcount.pl') 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 () { $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; } -- cgit v1.1 From 7dbdee2e9a2ac42ea5135801bcc9d1a8e3f672aa Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Thu, 6 Aug 2009 19:53:18 -0400 Subject: tracing: Fix recordmcount.pl to handle sections with only weak functions Roland Dreier found that a section that contained only a weak function in one of the staging drivers and this caused recordmcount.pl to spit out a warning and fail. Although it is strange that a driver would have a weak function, and this function only be used in one place, it should not be something to make recordmcount.pl fail. This patch fixes the issue in a simple manner: if only weak functions exist in a section, then that section will not be recorded. Reported-by: Roland Dreier Signed-off-by: Steven Rostedt Signed-off-by: Ingo Molnar --- scripts/recordmcount.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/recordmcount.pl') diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 4889c44..911ba7f 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -393,7 +393,7 @@ while () { $read_function = 0; } # print out any recorded offsets - update_funcs() if ($text_found); + update_funcs() if (defined($ref_func)); # reset all markers and arrays $text_found = 0; @@ -444,7 +444,7 @@ while () { } # dump out anymore offsets that may have been found -update_funcs() if ($text_found); +update_funcs() if (defined($ref_func)); # If we did not find any mcount callers, we are done (do nothing). if (!$opened) { -- cgit v1.1