Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp128853iof; Sun, 5 Jun 2022 23:13:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvHzWpJFXPafOx/B+lY+mcnPw8js55S0oRSj3+QplFmGru3UcAT00IvR3HErISwiHmLIwh X-Received: by 2002:a63:8841:0:b0:3fc:6f1f:d11 with SMTP id l62-20020a638841000000b003fc6f1f0d11mr20093645pgd.498.1654496018369; Sun, 05 Jun 2022 23:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654496018; cv=none; d=google.com; s=arc-20160816; b=qpIpJxGZBPARx4wBDSy/MD8znVXs+2zQkO4epnMaDg8UZJCFvDPah+AajVqzuPd0i9 ShlMlU3PZW23obk1HPXDGQIen3l/fEmGymP6BnPz2Fd5W5AHZ+lXB8L4Ttms2iYL45ts EGGBPvj8euRkNos8R75hkjUT9QzUALcWOZxe01paXPWuVcpem1paY4Kq08LVcdt03Mbr ziZ18DzRPQcdlATXuDMTL/u3qmUhtrAlHKmh7gUBhFI2lqzKwlBoaI0hFeCz6ySP5oka resHTca8k+A1GHvQbyA5vl5vuG9cFEu7hKEvmI0+QqYSjLhHW0ksovmAxZFgeOet7C8T Z1vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=itT1+tklOPyEGHjM6JBr0kjSHnziCwiISwWRvsQC7/E=; b=auXicV4Ee9v9Rx9cWCNgo+BvkN/y2M9IDrqPIALUX2fUY3di28k6bcq42hetOpKmt5 uLddWorKLevAvwXmYPpRHxk+Xzh4gg4jaWy3Abq1ycjBlyAVz8igM+eRulW1+ZKL1Bcz 1haGkFi4Pznac6SEa/VLYLbZaCHP88LzBXtByztALyzRAj6Zx/L64YwBE5dDV4TLKWnX WuYsy+HIDUTH1LROhSrbC+vl0gwalrZYsi+yWt4Iylj/chqh8GXLK/gA66VGhX2gDn55 0GAXcQRTMWLQmALpzTV0lOijjLUXMjrolJ+2h5ZrZEmjwrtUmu5CihFxwcPycrjnP13R oa4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O9MHOZXY; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p18-20020a62ab12000000b0051c1c914f3fsi2899528pff.290.2022.06.05.23.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 23:13:38 -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=@kernel.org header.s=k20201202 header.b=O9MHOZXY; 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=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 972DAFB42A; Sun, 5 Jun 2022 21:53:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349200AbiFCTYH (ORCPT + 99 others); Fri, 3 Jun 2022 15:24:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344263AbiFCTYF (ORCPT ); Fri, 3 Jun 2022 15:24:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B92D7BE22; Fri, 3 Jun 2022 12:24:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 568EC61A40; Fri, 3 Jun 2022 19:24:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90FF6C385B8; Fri, 3 Jun 2022 19:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654284243; bh=yt+bB3Q+W8oVkpzAEgMcRoEXyzhk3C1iaR9Ljh12V+0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=O9MHOZXYaNO1a0uNf4TGQcDx2TvE/MXiR8+rLcoxIoSZe/ykSV82GLX9qufcBKcK3 XeYlZBUGLdwXWglLZo/ct9mgVN+bWTjnCFPWMzLw5l51uvjZ8uHO1KmSwyF4dxJNT1 U6Z31jCH/wDI75npKvF3m7dYGx6WgLubziWrnzu/JesQV58NM8lHiDAI3AuqLbN481 THO0RULtZ0jyhxUixw270coBskVc/QYq0Pk7EsHUUBWw7i7HsgrlMxy1bMfc72wSqu OITLuH13u+7gnw4BIUekewYEuBoZ/NglJy2mU6a7oosx+LZWupfU8oG7GAHjfzKGLX trNk6TfYBiqhg== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id AB1C14096F; Fri, 3 Jun 2022 21:24:01 +0200 (CEST) Date: Fri, 3 Jun 2022 21:24:01 +0200 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Fangrui Song , Peter Zijlstra , Ingo Molnar , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Sebastian Ullrich Subject: Re: [PATCH v2] perf: Fix segbase for ld.lld linked objects Message-ID: References: <20220527182039.673248-1-maskray@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Em Fri, May 27, 2022 at 11:51:54AM -0700, Ian Rogers escreveu: > On Fri, May 27, 2022 at 11:20 AM Fangrui Song wrote: > > > > segbase is the address of .eh_frame_hdr and table_data is segbase plus > > the header size. find_proc_info computes segbase as `map->start + > > segbase - map->pgoff` which is wrong when > > > > * .eh_frame_hdr and .text are in different PT_LOAD program headers > > * and their p_vaddr difference does not equal their p_offset difference > > > > Since 10.0, ld.lld's default --rosegment -z noseparate-code layout has > > such R and RX PT_LOAD program headers. > > > > ld.lld (default) => perf report fails to unwind `perf record > > --call-graph dwarf` recorded data > > ld.lld --no-rosegment => ok (trivial, no R PT_LOAD) > > ld.lld -z separate-code => ok but by luck: there are two PT_LOAD but > > their p_vaddr difference equals p_offset difference > > > > ld.bfd -z noseparate-code => ok (trivial, no R PT_LOAD) > > ld.bfd -z separate-code (default for Linux/x86) => ok but by luck: > > there are two PT_LOAD but their p_vaddr difference equals p_offset > > difference > > > > To fix the issue, compute segbase as dso's base address plus > > PT_GNU_EH_FRAME's p_vaddr. The base address is computed by iterating > > over all dso-associated maps and then subtract the first PT_LOAD p_vaddr > > (the minimum guaranteed by generic ABI) from the minimum address. > > > > In libunwind, find_proc_info transitively called by unw_step is cached, > > so the iteration overhead is acceptable. > > > > Reported-by: Sebastian Ullrich > > Link: https://github.com/ClangBuiltLinux/linux/issues/1646 > > Signed-off-by: Fangrui Song > > Cc: Ian Rogers > > Reviewed-by: Ian Rogers Thanks, applied. - Arnaldo