diff mbox

[1/2] scripts/recordmcount.pl: support data in text section on powerpc

Message ID 1452600863-6294-1-git-send-email-mpe@ellerman.id.au (mailing list archive)
State Accepted
Headers show

Commit Message

Michael Ellerman Jan. 12, 2016, 12:14 p.m. UTC
From: Ulrich Weigand <ulrich.weigand@de.ibm.com>

If a text section starts out with a data blob before the first
function start label, disassembly parsing doing in recordmcount.pl
gets confused on powerpc, leading to creation of corrupted module
objects.

This was not a problem so far since the compiler would never create
such text sections.  However, this has changed with a recent change
in GCC 6 to support distances of > 2GB between a function and its
assoicated TOC in the ELFv2 ABI, exposing this problem.

There is already code in recordmcount.pl to handle such data blobs
on the sparc64 platform.  This patch uses the same method to handle
those on powerpc as well.

Cc: stable@vger.kernel.org
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 scripts/recordmcount.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Steve can we get an ack for this one, to go via powerpc? cheers

Comments

Steven Rostedt Jan. 12, 2016, 3:42 p.m. UTC | #1
On Tue, 12 Jan 2016 23:14:22 +1100
Michael Ellerman <mpe@ellerman.id.au> wrote:

> From: Ulrich Weigand <ulrich.weigand@de.ibm.com>
> 
> If a text section starts out with a data blob before the first
> function start label, disassembly parsing doing in recordmcount.pl
> gets confused on powerpc, leading to creation of corrupted module
> objects.
> 
> This was not a problem so far since the compiler would never create
> such text sections.  However, this has changed with a recent change
> in GCC 6 to support distances of > 2GB between a function and its
> assoicated TOC in the ELFv2 ABI, exposing this problem.
> 
> There is already code in recordmcount.pl to handle such data blobs
> on the sparc64 platform.  This patch uses the same method to handle
> those on powerpc as well.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  scripts/recordmcount.pl | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> Steve can we get an ack for this one, to go via powerpc? cheers

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

> 
> diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> index 826470d7f000..96e2486a6fc4 100755
> --- a/scripts/recordmcount.pl
> +++ b/scripts/recordmcount.pl
> @@ -263,7 +263,8 @@ if ($arch eq "x86_64") {
>  
>  } elsif ($arch eq "powerpc") {
>      $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
> -    $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:";
> +    # See comment in the sparc64 section for why we use '\w'.
> +    $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?\\w*?)>:";
>      $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
>  
>      if ($bits == 64) {
Michael Ellerman Jan. 12, 2016, 10:43 p.m. UTC | #2
On Tue, 2016-01-12 at 10:42 -0500, Steven Rostedt wrote:
> On Tue, 12 Jan 2016 23:14:22 +1100
> Michael Ellerman <mpe@ellerman.id.au> wrote:
> > From: Ulrich Weigand <ulrich.weigand@de.ibm.com>
> > 
> > If a text section starts out with a data blob before the first
> > function start label, disassembly parsing doing in recordmcount.pl
> > gets confused on powerpc, leading to creation of corrupted module
> > objects.
> > 
> > This was not a problem so far since the compiler would never create
> > such text sections.  However, this has changed with a recent change
> > in GCC 6 to support distances of > 2GB between a function and its
> > assoicated TOC in the ELFv2 ABI, exposing this problem.
> > 
> > There is already code in recordmcount.pl to handle such data blobs
> > on the sparc64 platform.  This patch uses the same method to handle
> > those on powerpc as well.
> > 
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> > ---
> >  scripts/recordmcount.pl | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > Steve can we get an ack for this one, to go via powerpc? cheers
> 
> Acked-by: Steven Rostedt <rostedt@goodmis.org>

Thanks.
Michael Ellerman Jan. 13, 2016, 1:09 p.m. UTC | #3
On Tue, 2016-12-01 at 12:14:22 UTC, Michael Ellerman wrote:
> From: Ulrich Weigand <ulrich.weigand@de.ibm.com>
> 
> If a text section starts out with a data blob before the first
> function start label, disassembly parsing doing in recordmcount.pl
> gets confused on powerpc, leading to creation of corrupted module
> objects.
> 
> This was not a problem so far since the compiler would never create
> such text sections.  However, this has changed with a recent change
> in GCC 6 to support distances of > 2GB between a function and its
> assoicated TOC in the ELFv2 ABI, exposing this problem.
> 
> There is already code in recordmcount.pl to handle such data blobs
> on the sparc64 platform.  This patch uses the same method to handle
> those on powerpc as well.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Acked-by: Steven Rostedt <rostedt@goodmis.org>

Applied to powerpc next.

https://git.kernel.org/powerpc/c/2e50c4bef77511b42cc226865d

cheers
diff mbox

Patch

diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 826470d7f000..96e2486a6fc4 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -263,7 +263,8 @@  if ($arch eq "x86_64") {
 
 } elsif ($arch eq "powerpc") {
     $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
-    $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:";
+    # See comment in the sparc64 section for why we use '\w'.
+    $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?\\w*?)>:";
     $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
 
     if ($bits == 64) {