This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Prelinking on ARM with Debug Link
- From: Torsten Polle <Torsten dot Polle at gmx dot de>
- To: Mark Wielaard <mjw at redhat dot com>
- Cc: systemtap at sourceware dot org
- Date: Wed, 6 Apr 2016 22:44:52 +0200
- Subject: Re: Prelinking on ARM with Debug Link
- Authentication-results: sourceware.org; auth=none
- References: <4BCA4243-B16B-436F-9D53-41C551492A51 at gmx dot de> <6E47DD0A-0515-45C6-86A1-4669A8182663 at gmx dot de> <1455121041 dot 7606 dot 104 dot camel at redhat dot com> <3855EE25-54F2-47FB-88A8-FF1EC3963C06 at gmx dot de> <1455136517 dot 7606 dot 107 dot camel at redhat dot com> <trinity-fb9190d9-ee29-4674-8066-0251f630d69b-1455187752264 at 3capp-gmx-bs27> <1455617312 dot 9915 dot 50 dot camel at redhat dot com> <1FF3B18B-EEA4-4A00-8E4F-3B7977E0111C at gmx dot de> <1455812509 dot 7770 dot 4 dot camel at redhat dot com> <23DAF1AA-DD74-4B03-8290-A4CB49F10D14 at gmx dot de> <1456246011 dot 7770 dot 120 dot camel at redhat dot com> <97BC1582-878D-4841-9D3B-B0C50A017B1B at gmx dot de> <CBF70205-25B4-4972-8AB5-BC6357618455 at gmx dot de> <8BE9FE12-777D-4C56-89C0-26FC2718CCAE at gmx dot de> <1459516058 dot 8147 dot 138 dot camel at redhat dot com> <ED8344C8-189F-41BF-9780-64DE038ED1B4 at gmx dot de> <1459863878 dot 8147 dot 242 dot camel at redhat dot com>
Hi Mark,
> Am 05.04.2016 um 15:44 schrieb Mark Wielaard <mjw@redhat.com>:
>
> [stuff deleted]
>
> OK. So the issue is that we use a hex representation of a negative
> number that might not fit when converted to an unsigned value.
> The simplest fix seems to be to just use a (signed) decimal
> representation, that can be converted to the unsigned value on
> assignment.
The issue remains if we use decimals. Because even the decimal 0xffffffffffffebc0 = 18446744073709546432 is too large to be represented as 32 bit value. :-( Therefore my cross compiler on the 64bit host complains.
> But you prefer to use the hex representation instead?
The usage of hex over decimal is just a matter of taste.
> I don't completely understand what sec_load_offset represents and why it
> is an unsigned value. We use it in two places:
>
> runtime/sym.c (_stp_linenumber_lookup):
>
> // if addr is a kernel address, it will need to be adjusted
> if (!task)
> {
> int i;
> unsigned long offset = 0;
> // have to factor in the load_offset of (specifically) the .text section
> for (i=0; i<m->num_sections; i++)
> if (!strcmp(m->sections[i].name, ".text"))
> {
> offset = (m->sections[i].static_addr - m->sections[i].sec_load_offset);
> break;
> }
>
> if (addr < offset)
> return 0;
> addr = addr - offset;
> }
>
> runtime/unwind.c (adjustStartLoc):
>
> if (is_ehframe)
> return startLoc + vm_addr;
> else
> return startLoc + vm_addr - s->sec_load_offset;
I had twiddled with the else branch in the past. I do not recall all attempts. But Iâm sure that I set sec_load_offset even to 0. The result is that the probes are set at the wrong address in libc. To be more concrete they are offset by -5184 compared to the original address. Still Iâll check your patch and let you know the result.
> The first is clearly only used for the kernel. The second is only used
> for .debug_frame addresses. And if you read the rest of the code
> (".dynamic" is user space dynamic library (ET_DYN), ".absolute" is user
> space executable (ET_EXEC), the kernel has a special name "_stext" and
> only kernel modules have section names attached because they are
> ET_REL), it looks like sec_load_offset is only used when handling kernel
> modules.
>
> This makes sense. Except for kernel modules all other "modules" exist of
> just one executable segment/section. But kernel modules (ET_REL files)
> can have multiple executable sections with different names and offsets.
>
> So in practice sec_load_offset is only used for kernel modules to
> calculate the section static_addr - sec_load_offset.
>
> Given that I think we are solving the wrong problem. Calculating
> sec_load_offset for anything except kernel modules doesn't make sense.
> So maybe the simplest solution is the attached patch?
>
> It is odd that we only seem to do this for the ".text" section. A kernel
> module can have multiple code sections with different names. This isn't
> a regression since we never seemed to handle any other section. But if
> there are problems unwinding through some kernel modules then this might
> explain it.
>
> Cheers,
>
> Mark
> diff --git a/translate.cxx b/translate.cxx
> index 5daf725..f10c98d 100644
> --- a/translate.cxx
> +++ b/translate.cxx
> @@ -6911,10 +6911,17 @@ dump_unwindsym_cxt (Dwfl_Module *m,
> << "_debug_frame_hdr_" << secidx << ",\n";
> c->output << ".debug_hdr_len = " << debug_frame_hdr_len << ", \n";
>
> - Dwarf_Addr dwbias = 0;
> - dwfl_module_getdwarf (m, &dwbias);
> - c->output << ".sec_load_offset = 0x"
> - << hex << debug_frame_off - dwbias << dec << "\n";
> + /* Only kernel modules has section names. And the only section
> + name we are currently interested in (see above) is ".text". */
> + if (secname == ".text")
> + {
> + Dwarf_Addr dwbias = 0;
> + dwfl_module_getdwarf (m, &dwbias);
> + c->output << ".sec_load_offset = 0x"
> + << hex << debug_frame_off - dwbias << dec << "\n";
> + }
> + else
> + c->output << ".sec_load_offset = 0\n";
>
> c->output << "#else\n";
> c->output << ".debug_hdr = NULL,\nâ;
Cheers,
Torsten