This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Failures with exelib.exp testcase (was Re: minutes 2010-08-19)
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