From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8579 invoked by alias); 4 Mar 2011 07:13:25 -0000 Received: (qmail 8571 invoked by uid 22791); 4 Mar 2011 07:13:23 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e23smtp05.au.ibm.com (HELO e23smtp05.au.ibm.com) (202.81.31.147) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 Mar 2011 07:13:16 +0000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp05.au.ibm.com (8.14.4/8.13.1) with ESMTP id p2477cwd020813 for ; Fri, 4 Mar 2011 18:07:38 +1100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p247DCFp2490586 for ; Fri, 4 Mar 2011 18:13:12 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p247DCEX012696 for ; Fri, 4 Mar 2011 18:13:12 +1100 Received: from in.ibm.com ([9.124.35.37]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p247D7wI012591 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 4 Mar 2011 18:13:10 +1100 Date: Fri, 04 Mar 2011 07:13:00 -0000 From: "K.Prasad" To: Mark Wielaard Cc: Roland McGrath , systemtap@sourceware.org Subject: Re: Failures with exelib.exp testcase (was Re: minutes 2010-08-19) Message-ID: <20110304071306.GA2328@in.ibm.com> Reply-To: prasad@linux.vnet.ibm.com References: <20110202121440.GB3524@in.ibm.com> <1296651551.4270.34.camel@springer.wildebeest.org> <20110203050358.GA2488@in.ibm.com> <1296728173.3341.7.camel@springer.wildebeest.org> <20110203123353.GC2488@in.ibm.com> <1296737077.3341.22.camel@springer.wildebeest.org> <20110203185926.19226180954@magilla.sf.frob.com> <1297170815.3956.34.camel@springer.wildebeest.org> <20110214164945.GA2159@in.ibm.com> <1297715606.3344.29.camel@springer.wildebeest.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1297715606.3344.29.camel@springer.wildebeest.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2011-q1/txt/msg00327.txt.bz2 On Mon, Feb 14, 2011 at 09:33:26PM +0100, Mark Wielaard wrote: > On Mon, 2011-02-14 at 22:19 +0530, K.Prasad wrote: > > On Tue, Feb 08, 2011 at 02:13:35PM +0100, Mark Wielaard wrote: > > > On Thu, 2011-02-03 at 10:59 -0800, Roland McGrath wrote: > > > > What you need to do is: > > > > > > > > Elf64_Addr opd_addr; > > > > Dwarf_Addr bias; > > > > Elf_Scn *opd = dwfl_module_address_section (mod, &sym_addr, &bias); > > > > if (opd == NULL) ...; > > > > Elf_Data *data = elf_rawdata (opd, NULL); > > > > if (data == NULL) ...; > > > > Elf_Data in, out; > > > > out.d_buf = &final_addr; > > > > in.d_buf = (char *) data->d_buf + sym_addr; > > > > out.d_size = in.d_size = sizeof (Elf64_Addr); > > > > out.d_type = in.d_type = ELF_T_ADDR; > > > > if (elf64_xlatetom (elf, &out, &in, e_ident[EI_DATA]) == NULL) ...; > > > > sym_addr = opd_addr + bias; > > > So I made an attempt at turning the above piece of pseudocode into a patch for systemtap/translate.cxx and here's what it turned out to be. Upon execution the runtime experiences "Segmentation fault" at the line if (elf64_xlatetom (&out, &in, elf_getident (elf, NULL)[EI_DATA]) != NULL) and I'm trying to understand why. Any suggestions or pointers to mistakes in creation of the patch are welcome. --- translate.cxx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) Index: systemtap/translate.cxx =================================================================== --- systemtap.orig/translate.cxx +++ systemtap/translate.cxx @@ -5018,7 +5018,30 @@ || sym.st_value >= end // beyond current module, || sym.st_value < base)) // before first section. { - Dwarf_Addr sym_addr = sym.st_value; + Dwarf_Addr sym_addr; +#ifdef __powerpc__ +// Elf64_Addr opd_addr; + Dwarf_Addr bias; + Elf_Data *data = NULL; + Elf_Data in, out; + Elf_Scn *opd = dwfl_module_address_section (m, &sym_addr, &bias); + Elf* elf = (dwfl_module_getelf (m, &bias)); + + if (opd != NULL) + { + data = elf_rawdata (opd, NULL); + if (data == NULL) + return DWARF_CB_ABORT; + } + out.d_buf = *userdata; + in.d_buf = (char *) data->d_buf + sym_addr; + out.d_size = in.d_size = sizeof (Elf64_Addr); + out.d_type = in.d_type = ELF_T_ADDR; + if (elf64_xlatetom (&out, &in, elf_getident (elf, NULL)[EI_DATA]) != NULL) + sym_addr = sym.st_value + bias; +#else + sym_addr = sym.st_value; +#endif /* __powerpc__ */ Dwarf_Addr save_addr = sym_addr; const char *secname = NULL; Thanks, K.Prasad