All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nds32/ftrace: Fix Error: invalid operands (*UND* and *UND* sections) for `^'
@ 2021-10-14 18:35 Steven Rostedt
  2021-10-15  0:54 ` Greentime Hu
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2021-10-14 18:35 UTC (permalink / raw)
  To: LKML
  Cc: Nick Hu, Greentime Hu, Vincent Chen, Ingo Molnar, Andrew Morton,
	Arnd Bergmann, Zong Li, Gustavo A. R. Silva, kernel test robot

[ Resending with "PATCH" in subject ]

I received a build failure for a new patch I'm working on the nds32
architecture, and when I went to test it, I couldn't get to my build error,
because it failed to build with a bunch of:

  Error: invalid operands (*UND* and *UND* sections) for `^'

issues with various files. Those files were temporary asm files that looked
like:  kernel/.tmp_mc_fork.s

I decided to look deeper, and found that the "mc" portion of that name
stood for "mcount", and was created by the recordmcount.pl script. One that
I wrote over a decade ago. Once I knew the source of the problem, I was
able to investigate it further.

The way the recordmcount.pl script works (BTW, there's a C version that
simply modifies the ELF object) is by doing an "objdump" on the object
file. Looks for all the calls to "mcount", and creates an offset of those
locations from some global variable it can use (usually a global function
name, found with <.*>:). Creates a asm file that is a table of references
to these locations, using the found variable/function. Compiles it and
links it back into the original object file. This asm file is called
".tmp_mc_<object_base_name>.s".

The problem here is that the objdump produced by the nds32 object file,
contains things that look like:

 0000159a <.L3^B1>:
    159a:       c6 00           beqz38 $r6, 159a <.L3^B1>
                        159a: R_NDS32_9_PCREL_RELA      .text+0x159e
    159c:       84 d2           movi55 $r6, #-14
    159e:       80 06           mov55 $r0, $r6
    15a0:       ec 3c           addi10.sp #0x3c
 

Where ".L3^B1 is somehow selected as the "global" variable to index off of.

Then the assembly file that holds the mcount locations looks like this:

        .section __mcount_loc,"a",@progbits
        .align 2
        .long .L3^B1 + -5522
        .long .L3^B1 + -5384
        .long .L3^B1 + -5270
        .long .L3^B1 + -5098
        .long .L3^B1 + -4970
        .long .L3^B1 + -4758
        .long .L3^B1 + -4122
        [...]

And when it is compiled back to an object to link to the original object,
the compile fails on the "^" symbol.

Simple solution for now, is to have the perl script ignore using function
symbols that have an "^" in the name.

Fixes: fbf58a52ac088 ("nds32/ftrace: Add RECORD_MCOUNT support")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 8f6b13ae46bf..7d631aaa0ae1 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -189,7 +189,7 @@ if ($arch =~ /(x86(_64)?)|(i386)/) {
 $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
 $weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)";
 $section_regex = "Disassembly of section\\s+(\\S+):";
-$function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
+$function_regex = "^([0-9a-fA-F]+)\\s+<([^^]*?)>:";
 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s(mcount|__fentry__)\$";
 $section_type = '@progbits';
 $mcount_adjust = 0;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] nds32/ftrace: Fix Error: invalid operands (*UND* and *UND* sections) for `^'
  2021-10-14 18:35 [PATCH] nds32/ftrace: Fix Error: invalid operands (*UND* and *UND* sections) for `^' Steven Rostedt
@ 2021-10-15  0:54 ` Greentime Hu
  2021-10-15 14:18   ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Greentime Hu @ 2021-10-15  0:54 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Nick Hu, Vincent Chen, Ingo Molnar, Andrew Morton,
	Arnd Bergmann, Zong Li, Gustavo A. R. Silva, kernel test robot,
	Alan Kao, kclin

Steven Rostedt <rostedt@goodmis.org> 於 2021年10月15日 週五 上午2:35寫道:
>
> [ Resending with "PATCH" in subject ]
>
> I received a build failure for a new patch I'm working on the nds32
> architecture, and when I went to test it, I couldn't get to my build error,
> because it failed to build with a bunch of:
>
>   Error: invalid operands (*UND* and *UND* sections) for `^'
>
> issues with various files. Those files were temporary asm files that looked
> like:  kernel/.tmp_mc_fork.s
>
> I decided to look deeper, and found that the "mc" portion of that name
> stood for "mcount", and was created by the recordmcount.pl script. One that
> I wrote over a decade ago. Once I knew the source of the problem, I was
> able to investigate it further.
>
> The way the recordmcount.pl script works (BTW, there's a C version that
> simply modifies the ELF object) is by doing an "objdump" on the object
> file. Looks for all the calls to "mcount", and creates an offset of those
> locations from some global variable it can use (usually a global function
> name, found with <.*>:). Creates a asm file that is a table of references
> to these locations, using the found variable/function. Compiles it and
> links it back into the original object file. This asm file is called
> ".tmp_mc_<object_base_name>.s".
>
> The problem here is that the objdump produced by the nds32 object file,
> contains things that look like:
>
>  0000159a <.L3^B1>:
>     159a:       c6 00           beqz38 $r6, 159a <.L3^B1>
>                         159a: R_NDS32_9_PCREL_RELA      .text+0x159e
>     159c:       84 d2           movi55 $r6, #-14
>     159e:       80 06           mov55 $r0, $r6
>     15a0:       ec 3c           addi10.sp #0x3c
>
>
> Where ".L3^B1 is somehow selected as the "global" variable to index off of.
>
> Then the assembly file that holds the mcount locations looks like this:
>
>         .section __mcount_loc,"a",@progbits
>         .align 2
>         .long .L3^B1 + -5522
>         .long .L3^B1 + -5384
>         .long .L3^B1 + -5270
>         .long .L3^B1 + -5098
>         .long .L3^B1 + -4970
>         .long .L3^B1 + -4758
>         .long .L3^B1 + -4122
>         [...]
>
> And when it is compiled back to an object to link to the original object,
> the compile fails on the "^" symbol.
>
> Simple solution for now, is to have the perl script ignore using function
> symbols that have an "^" in the name.
>
> Fixes: fbf58a52ac088 ("nds32/ftrace: Add RECORD_MCOUNT support")
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> index 8f6b13ae46bf..7d631aaa0ae1 100755
> --- a/scripts/recordmcount.pl
> +++ b/scripts/recordmcount.pl
> @@ -189,7 +189,7 @@ if ($arch =~ /(x86(_64)?)|(i386)/) {
>  $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
>  $weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)";
>  $section_regex = "Disassembly of section\\s+(\\S+):";
> -$function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
> +$function_regex = "^([0-9a-fA-F]+)\\s+<([^^]*?)>:";
>  $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s(mcount|__fentry__)\$";
>  $section_type = '@progbits';
>  $mcount_adjust = 0;
loop in Alan and KC

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nds32/ftrace: Fix Error: invalid operands (*UND* and *UND* sections) for `^'
  2021-10-15  0:54 ` Greentime Hu
@ 2021-10-15 14:18   ` Steven Rostedt
  2021-10-15 15:25     ` Greentime Hu
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2021-10-15 14:18 UTC (permalink / raw)
  To: Greentime Hu
  Cc: LKML, Nick Hu, Vincent Chen, Ingo Molnar, Andrew Morton,
	Arnd Bergmann, Zong Li, Gustavo A. R. Silva, kernel test robot,
	Alan Kao, kclin

On Fri, 15 Oct 2021 08:54:35 +0800
Greentime Hu <green.hu@gmail.com> wrote:

> loop in Alan and KC

Any thoughts?

This has passed my tests, and I want to send it off to Linus. But it would
be nice to have an acked by from one of the nds32 maintainers.

If I don't hear back today, I'll just send my queue without this update to
Linus, as I want to get my changes in before the next rc release.

Thanks!

-- Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nds32/ftrace: Fix Error: invalid operands (*UND* and *UND* sections) for `^'
  2021-10-15 14:18   ` Steven Rostedt
@ 2021-10-15 15:25     ` Greentime Hu
  0 siblings, 0 replies; 4+ messages in thread
From: Greentime Hu @ 2021-10-15 15:25 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Nick Hu, Vincent Chen, Ingo Molnar, Andrew Morton,
	Arnd Bergmann, Zong Li, Gustavo A. R. Silva, kernel test robot,
	Alan Kao, kclin

Steven Rostedt <rostedt@goodmis.org> 於 2021年10月15日 週五 下午10:18寫道:
>
> On Fri, 15 Oct 2021 08:54:35 +0800
> Greentime Hu <green.hu@gmail.com> wrote:
>
> > loop in Alan and KC
>
> Any thoughts?
>
> This has passed my tests, and I want to send it off to Linus. But it would
> be nice to have an acked by from one of the nds32 maintainers.
>
> If I don't hear back today, I'll just send my queue without this update to
> Linus, as I want to get my changes in before the next rc release.
>
> Thanks!

Acked-by: Greentime Hu <green.hu@gmail.com>
Thanks you, Steven.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-15 15:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 18:35 [PATCH] nds32/ftrace: Fix Error: invalid operands (*UND* and *UND* sections) for `^' Steven Rostedt
2021-10-15  0:54 ` Greentime Hu
2021-10-15 14:18   ` Steven Rostedt
2021-10-15 15:25     ` Greentime Hu

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.