Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752187AbZL3WXK (ORCPT ); Wed, 30 Dec 2009 17:23:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752073AbZL3WXI (ORCPT ); Wed, 30 Dec 2009 17:23:08 -0500 Received: from cantor.suse.de ([195.135.220.2]:47698 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751896AbZL3WXG (ORCPT ); Wed, 30 Dec 2009 17:23:06 -0500 Subject: Re: [PATCH 1/3] x86: record relocation offset From: James Bottomley To: Arnaldo Carvalho de Melo Cc: "H. Peter Anvin" , Xiao Guangrong , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Frederic Weisbecker , Paul Mackerras , "Frank Ch. Eigler" , linux-kernel@vger.kernel.org In-Reply-To: <20091230215847.GB2384@ghostprotocols.net> References: <4B3AC5CD.1000502@cn.fujitsu.com> <4B3AC629.4030504@cn.fujitsu.com> <20091230131518.GD2956@ghostprotocols.net> <4B3BADDA.8040102@zytor.com> <20091230203936.GA2384@ghostprotocols.net> <20091230215847.GB2384@ghostprotocols.net> Content-Type: text/plain; charset="UTF-8" Date: Wed, 30 Dec 2009 16:22:56 -0600 Message-Id: <1262211776.2749.249.camel@mulgrave.site> Mime-Version: 1.0 X-Mailer: Evolution 2.28.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2248 Lines: 50 On Wed, 2009-12-30 at 19:58 -0200, Arnaldo Carvalho de Melo wrote: > Em Wed, Dec 30, 2009 at 06:39:36PM -0200, Arnaldo Carvalho de Melo escreveu: > > Em Wed, Dec 30, 2009 at 11:45:30AM -0800, H. Peter Anvin escreveu: > > > The kernel already knows where it is loaded -- obviously, by sheer > > > necessity -- and knows how it was itself configured, and as such we > > > can do this calculation in C code without modifying boot_params or > > > the early bootstrap. > > > > Problem is that at 'perf record' time we may not have access to the > > vmlinux file, and thus not be able to figure out the relocation applied > > in that boot. > > > > Then, at a later time, and possibly on another machine, on another arch, > > we try to map back IPs to symbols, the /proc/kallsyms is completely > > unrelated and we now have a vmlinux unrelocated... > > > > So we need a way to get the relocation applied at 'perf record' time and > > encode it in the perf.data header. Ideas about how to do that? > > Well, I guess we could do the _stext trick again, storing its value, > taken from /proc/kallsyms, into the perf.data header, then figuring out > the relocation by looking at its value in the vmlinux symtab. So reading the thread, I think the problem only exists for x86 compiled as a relocateable kernel. > There were concerns in the past about relying on _stext, IIRC, James? Well, the original concerns were that _text relative relocation resolution only works for the core kernel, not for modules. Additionally, the kernel is in several sections, most notably init and runtime ... these may get loaded at different locations so _text relative symbol resolution won't work in init sections. Right at the moment, only x86 and ppc do a relocatable kernel, and, as I understand the process, the whole kernel image gets a relative offset applied, so all sections get the same offset. Thus, for this case it looks like computing the offset from any known symbol would work (including _text). James -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/