From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116831 invoked by alias); 7 Jul 2017 11:03:38 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 116814 invoked by uid 89); 7 Jul 2017 11:03:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=congrats, H*F:U*mark, cool, research X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Jul 2017 11:03:35 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id A72A3308B999; Fri, 7 Jul 2017 13:03:32 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 93ABE413CD07; Fri, 7 Jul 2017 13:03:32 +0200 (CEST) Message-ID: <1499425412.14595.78.camel@klomp.org> Subject: Re: dwfl_module_addrinfo and @plt entries From: Mark Wielaard To: Milian Wolff Cc: elfutils-devel@sourceware.org Date: Fri, 07 Jul 2017 11:03:00 -0000 In-Reply-To: <3866408.Fn4hcxxxTc@milian-kdab2> References: <4389913.7LHyNoxDn3@agathebauer> <4367790.cbajsgPFcv@milian-kdab2> <20170106191753.GB8669@stream> <3866408.Fn4hcxxxTc@milian-kdab2> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.12.11 (3.12.11-22.el7) Mime-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00001.txt.bz2 Hi Milian, First congrats on https://www.kdab.com/hotspot-gui-linux-perf-profiler/ Very cool. On Wed, 2017-07-05 at 15:34 +0200, Milian Wolff wrote: > On Friday, January 6, 2017 8:17:53 PM CEST Mark Wielaard wrote: > I have now looked into this issue again and have found a way to workaroun= d=20 > this limitation outside of elfutils, by manually resolving the address in= a=20 > .plt section to a symbol. See: >=20 > https://github.com/KDAB/perfparser/commit/ > 885f88f3d66904cd94af65f802232f6c6dc339f4 >=20 > This seems to work in my limited tests (only on X86_64). Beside the 32bit/ > 64bit difference, it isn't really platform dependent, is it? Or was this = what=20 > you had in mind when you said the elfutils code would be "architecture=20 > specific [and] we would need a backend function that translates an addres= s=20 > pointing into the PLT into an actual function address"? >=20 > If my code is roughly OK, then I'll try to put it into a patch for elfuti= ls=20 > and submit it there. If it's fundamentally broken, please tell me. I stil= l=20 > plan to get this functionality upstream into elfutils. Thanks for the research. I don't know if the PLT/GOT resolving works identical for all architectures. But yes, it does look like what you came up with is in general architecture independent. In general it would be nice if we could avoid any name based section lookups (or only do them as fallbacks) since we might not have section headers (for example if you got the ELF image from memory). I wonder if we can get all the information needed from the dynamic segment. For example it seems we have a DT_JMPREL that points directly at the .plt table, DT_PLTREL gives you what kind of relocation entries REL or RELA it contains and DT_PLTRELSZ gives the size of the plt table.=20 In your code you get the GOT address through DT_PLTGOT, but then use that address to lookup the .got.plt section and use its sh_addr to index into the table. Why is that? Isn't that address equal to what you already got through DT_PLTGOT?=20 Thanks, Mark