Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp83600pxb; Fri, 15 Oct 2021 00:53:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk5LGi3FPZwyTYBc0mhg11fNYtA/Aa3+84sendtp6Ew4S7nsDqtcquKPUtAeFguGUZzj7P X-Received: by 2002:a17:906:d8d5:: with SMTP id re21mr5171976ejb.110.1634284416801; Fri, 15 Oct 2021 00:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634284416; cv=none; d=google.com; s=arc-20160816; b=HLOCmobkZAqmlJ4XQUFp3BKzuAG2ZhuKHTuUfsw/housHRLbukUusMkVYuN/vxU6zf nTuvUm0SN6FtVEyPeZKo9eRtcoUcoGkTHAlDwKkwFwSpesf2J2YIKfqVfBSq3H6DDo0C ZK+pZe60+pIqh0W6jL1Pck71i/TRIrB9QUB1fBHJNsyueipWUp55tEW/YYG2PkiyFlhL ttTgdsOOpldZ0MUWQEsfcKeBDRaDuDljvwyq1m+lmNxbLIQxYDtvA7CHaegu6q/zaTiF mBk9XVayTzOa5k236GPAy/hyDII66m+NWU6eSagwvpBQPTIl29kMnPUfHHx6exQzEvrn ADAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=3+5b06haTPMyGtomaiqAwErioMcClLD7g8Ln+zY+qQ4=; b=dB2t6495dBJbiIDd7xMEyXFytgk1IiuD++5y9iy6XrPuF0Ib7FVC21+UzTlcrPcvLI qc+/2KdKHAuk3DYoU78PlNXpsjL/4p8h/YCaL3ojYbiKmMPgkfrnLy47i+ajDkUNB1fz 4iOGyZMwsA006KcGiM1aldKjluRasFNo5aiRtahWWW2yxUU1RDSTgCZWGJ4fHXeIkPB3 /qn8Q/RfvtRYtO84WWjB9SlLEPH2mT6Ee/u2szkFe/Tn7PfWeMC6EF1ojnYDppkt/iDK y15KiBGgEtxau9wwKUnojdS4j5/TU0Z3ArXtCV9mSw0ura1sbR+/vyybzv+12NC9Ie1Y LpEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Q750YQIL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e13si8197440edm.248.2021.10.15.00.53.12; Fri, 15 Oct 2021 00:53:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Q750YQIL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233159AbhJOA5R (ORCPT + 99 others); Thu, 14 Oct 2021 20:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231284AbhJOA5Q (ORCPT ); Thu, 14 Oct 2021 20:57:16 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9AC0C061570 for ; Thu, 14 Oct 2021 17:55:10 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id e5-20020a17090a804500b001a116ad95caso510653pjw.2 for ; Thu, 14 Oct 2021 17:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3+5b06haTPMyGtomaiqAwErioMcClLD7g8Ln+zY+qQ4=; b=Q750YQILdfzpohGDrnI1r7WzNcoHQNL4HeozRXQA6yPy3mwf0PDnZT6veY4owUzd4U y1taUbA9pO1kERe8PW6zQu9JCU4dkVZfVF3AGA8EjxhjDlxv7H6g1TH2zYU8U+uO3Rnr vF6pFmk4Y43+7ZVnZMb/lK9spxzfm9oR4Hp0s+WFrexJ2++SH1GDZ22TSThftAkegRh2 FtVl+2lqIps0+agfw1L9B+IWKerrKNQLJnCT8oeH8/qImGXAW4dY2yjoDRxEumyv9wgE TminGtVI3vlo9zX7cW+T3zY7PMUaMd51Kd2LwJUxr98LFuF/V/9QGvFmmzPYe10pgn74 673w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=3+5b06haTPMyGtomaiqAwErioMcClLD7g8Ln+zY+qQ4=; b=LaM8bC7h5mP/NVnGyGj5N4qB+kPIWy+4LfHXF0Idmotd9jk0VxIEHUG80PfzQILr1K bIY6ZH3HsGsIlSjSHfv5hhM63Gwq72FtXvZu+YuXLH7Qdkg+1CYBOG4fOCzEX8osrTN7 B14axhUgE6BfZjydCmh7tTjdtWURUFNIRTuJiAeyJCqIGWoG/vkebhv1hMyOFwd6FI52 fAomkflJBbDPiukgcUaDIjAfvVEk3GtOMdXCbeEwYVuRcxtmFsflKUxZ2xd7MP1tyGXr vJG+IiqV9ypGszX+grIfxDJ8EVp5RHRvPzYHwnKAuVZSTFjrSxumTy60mKGxGnrTK0mm AaKg== X-Gm-Message-State: AOAM532EENFtevKUfKSMSanhbi0w41niHlUFP/5/gpjchAywlyfmFqIg yuPNUVtVWSZ9kSZ7Ph07i6pr53s1W8IinuekC9w= X-Received: by 2002:a17:90a:7345:: with SMTP id j5mr24394426pjs.48.1634259310278; Thu, 14 Oct 2021 17:55:10 -0700 (PDT) MIME-Version: 1.0 References: <20211014143507.4ad2c0f7@gandalf.local.home> In-Reply-To: <20211014143507.4ad2c0f7@gandalf.local.home> From: Greentime Hu Date: Fri, 15 Oct 2021 08:54:35 +0800 Message-ID: Subject: Re: [PATCH] nds32/ftrace: Fix Error: invalid operands (*UND* and *UND* sections) for `^' 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@andestech.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Steven Rostedt =E6=96=BC 2021=E5=B9=B410=E6=9C=8815= =E6=97=A5 =E9=80=B1=E4=BA=94 =E4=B8=8A=E5=8D=882:35=E5=AF=AB=E9=81=93=EF=BC= =9A > > [ 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 erro= r, > 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 look= ed > 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 th= at > 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_.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 o= f. > > 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) > --- > 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 =3D~ /(x86(_64)?)|(i386)/) { > $local_regex =3D "^[0-9a-fA-F]+\\s+t\\s+(\\S+)"; > $weak_regex =3D "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)"; > $section_regex =3D "Disassembly of section\\s+(\\S+):"; > -$function_regex =3D "^([0-9a-fA-F]+)\\s+<(.*?)>:"; > +$function_regex =3D "^([0-9a-fA-F]+)\\s+<([^^]*?)>:"; > $mcount_regex =3D "^\\s*([0-9a-fA-F]+):.*\\s(mcount|__fentry__)\$"; > $section_type =3D '@progbits'; > $mcount_adjust =3D 0; loop in Alan and KC