Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4887588iob; Mon, 9 May 2022 04:08:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwliLxxoc+WXYLrc8H2Ebx7Qjd2PqgBuvdrNCuIOOr1yiYCnomdkIRni778kYj3/5bZh+DW X-Received: by 2002:a05:6a00:a85:b0:4e0:57a7:2d5d with SMTP id b5-20020a056a000a8500b004e057a72d5dmr15491459pfl.81.1652094481581; Mon, 09 May 2022 04:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652094481; cv=none; d=google.com; s=arc-20160816; b=pbOSHNMUSEGC93YcyOx92uBhtGQ0AXVTzDX4hRJdy7F/Y6HX6xadJ1nz44oXvVD21u AueVO+1M4OcZ57+9OdG5gZgqv4J/xBmMkj3/EW5KigqcERc1DLrM/CMOf+j1zJ9HYEon D0cqWBrTzzGM8bfYeda0dgotAqeTqgOF01oKaKsW+YoiqiBH/xYWt9K0e6S12cSuPdAi JF8tk4SZnHNqYhIwjduRWPtollU3mGJTK4kfIfc/OwdB0OMjpE3oPQA4b5lw7EcQMFrZ YFsP5rlZorWacoeN7nT4mhRzcoCI0yWZ0hxcPmCo1hwi99BeYjOUnxJtNtqwJpqW+i3v FA7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MJu1QBrUmYKsWkPpzJPRKOLKMujPLz1avDzlkqqe+L8=; b=w5oh1VwpffK7cYWJQ9Gl0zxWwPi+6eep6rqR7gn/HM6/ldB4mM4mK6P2lVaQ/6OyUM gocGAluCfPTBkbQXZBusglGbZ8I9hZbAY5g7GbF2h2uZiJepsr4n1rSbqmMloV2QWV0T URsW30Kds7eCD7FVarwv9CEPVFGOHby/YFyfUczpzj7AJf5o/3cqEs6KZlDK+tLaZlgY aIw6q267f88QN80eDJHCUTAx9cqDWUI248PYeykbmBEPQA3xrrRLQr/M+Go0x42PJYpc l3dBEY6XlQ8YavLaWELaY89yOoefpANGKWPHkm0btzIl15xwi+libqCBLVi5sk0xAosn CPBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p1ZrXpxb; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v10-20020a63610a000000b003c63bf66bcesi11240190pgb.685.2022.05.09.04.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 04:08:01 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p1ZrXpxb; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B56CE27F102; Mon, 9 May 2022 03:21:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389342AbiEFGIB (ORCPT + 99 others); Fri, 6 May 2022 02:08:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353072AbiEFGIA (ORCPT ); Fri, 6 May 2022 02:08:00 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53FFD6542C for ; Thu, 5 May 2022 23:04:18 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id g20so7514313edw.6 for ; Thu, 05 May 2022 23:04:18 -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; bh=MJu1QBrUmYKsWkPpzJPRKOLKMujPLz1avDzlkqqe+L8=; b=p1ZrXpxb63uHbrml1c8HgR6R8n6VXAQv2DV7PGrsCqaaPDcdt1d1FoueVXGEIgbvVt /nB25xLd28nAcVcUSeYEa4vWHl6llvjLvil9Een/4ZnLF9kVHt9t5zfLWhlce17PsUc1 5YerJuRVq1snCMLlEXqVQECmcSvr6FY1zky4lP/wlA0KX5jXrZsBgZww9okQvwCnctlW GJFDQScmIJx9DAAODntgndBf7j17ZqVq5C2eY0A3WDQIPLkEYnq2PMkyDUnKfyCaeaes lbnZDhxIDt6tIueEHR4/fKt3QiOlvkpIjNZe7STkNFKWxKbQmiloKbPCwmuN+8UR1agB JgIg== 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; bh=MJu1QBrUmYKsWkPpzJPRKOLKMujPLz1avDzlkqqe+L8=; b=4oj62+3MZb9yVBpAHGXVTy1q7HbNLX+Q4N5pIDXsVVVmlPXLRiM4qyedVsFgJEOars if9u+KW65B/G4mHDRD99HvWxKKTbzNLDowh4WUGFAVcl9/gbPabS9If4kBzHH079VLfL m+Hw/dCeeLxpv0c0dhShWk2Lt8kcYG2PtVOzX8CTWofSzW3A0TLH3tt6E+O6bGR98+k3 NCtjDi1DRJG7wJUJPAhzH9vhTzp0qTFZWQqfTL/3NNCXofL73wLXWTxDP2NXQfLtecJD KrmVbSUybe7b8JK6aQ5Om4IZKgCfjjHQLQ28niuZjWOb3qafLziQZeE0oycocPUTSl13 SzNw== X-Gm-Message-State: AOAM5325xOuFOAHUEaTV1xAzUrDZBN3EA6sUN39j3YGRNcUbAgjqXrrH LfCxMIlEV7XTXY3nIpTzud62hAAaDLiOu6xd+eWgM1SSNdOd/Q== X-Received: by 2002:a05:6402:268e:b0:427:c402:d6f3 with SMTP id w14-20020a056402268e00b00427c402d6f3mr1836865edd.358.1651817056757; Thu, 05 May 2022 23:04:16 -0700 (PDT) MIME-Version: 1.0 References: <2fb2bc4e857848c83cfa96483e4b25b23d46be49.1651516951.git.jpoimboe@redhat.com> In-Reply-To: <2fb2bc4e857848c83cfa96483e4b25b23d46be49.1651516951.git.jpoimboe@redhat.com> From: Kaiwan N Billimoria Date: Fri, 6 May 2022 11:34:00 +0530 Message-ID: Subject: Re: [PATCH] scripts/faddr2line: Only use text symbols to calculate function size To: Josh Poimboeuf Cc: Peter Zijlstra , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Josh, Unfortunately, it didn't work with my test case (as before): $ <...>/linux-5.10.60/scripts/faddr2line ./oops_tryv2.ko do_the_work+0x124 bad symbol size: base: 0x0000000000000000 end: 0x0000000000000000 $ What _did_ work was the earlier (much longer) patch you'd sent (your email dt 20 Jan 2022), Could you pl recheck... (As before, i have the test case module here: https://github.com/PacktPublishing/Linux-Kernel-Debugging/tree/main/ch7/oops_tryv2 ) Regards, Kaiwan. On Tue, May 3, 2022 at 12:14 AM Josh Poimboeuf wrote: > > With the following commit > > efdb4167e676 ("scripts/faddr2line: Fix "size mismatch" error") > > it was discovered that faddr2line can't just read a function's ELF > size, because that wouldn't match the kallsyms function size which is > printed in the stack trace. The kallsyms size includes any padding > after the function, whereas the ELF size does not. > > So faddr2line has to manually calculate the size of a function similar > to how kallsyms does. It does so by starting with a sorted list of > symbols and subtracting the function address from the subsequent > symbol's address. > > That calculation is broken in the case where the function is the last > (or only) symbol in the .text section, which can occur quite commonly in > a kernel module or a .o file. In that case, the next symbol in the > sorted list might actually be a data symbol, which breaks the function > size detection: > > $ scripts/faddr2line sound/soundcore.ko sound_devnode+0x5/0x35 > bad symbol size: base: 0x0000000000000000 end: 0x0000000000000000 > > Fix it by only including text symbols in the symbol list. > > Fixes: efdb4167e676 ("scripts/faddr2line: Fix "size mismatch" error") > Reported-by: Kaiwan N Billimoria > Signed-off-by: Josh Poimboeuf > --- > scripts/faddr2line | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/faddr2line b/scripts/faddr2line > index 6c6439f69a72..2a130134f1e6 100755 > --- a/scripts/faddr2line > +++ b/scripts/faddr2line > @@ -189,7 +189,7 @@ __faddr2line() { > > DONE=1 > > - done < <(${NM} -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }') > + done < <(${NM} -n $objfile | awk -v fn=$func -v end=$file_end '$2 !~ /[Tt]/ {next} $3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }') > } > > [[ $# -lt 2 ]] && usage > -- > 2.34.1 >