[PATCH 2/2] Fast tracepoint for powerpc64le
Ulrich Weigand
uweigand@de.ibm.com
Wed Apr 8 16:53:00 GMT 2015
Wei-cheng Wang wrote:
> On 2015/3/18 ä¸Âå 02:29, Ulrich Weigand wrote:
> > Power8, we might be able to use a bctar, but we may not be able to rely
> > on the TAR register being available.)
>
> If I clobbered TAR register, won't it affect the user code?
Well, the ABI defines that user code must never use TAR, and must not
rely on it not being clobbered. The intent is specifically to allow
it to be used by system code for purposes just like this.
There's still a bit of uncertainty what exactly "system code" is and
whether use of TAR by a gdbserver IPA stub might interfere with use
of TAR by *other* parts of the system, so it's probably best to
leave it alone for now. But definitely something to revisit later.
> > As a first implementation, I guess I'd be fine with those) restriction,
> > but we should be thinking of how we could lift (some of) them. We might
> > want to, for example,
> > - determine the actual mapping base of the main executable and place
> > the jump pad close even if it is not at the default address
>
> How about this? AT_PHDR should be at the very beginning of the first
> loadable segment of the executable. This should work for PIE.
>
> uintptr_t
> jump_pad_area_hint (void)
> {
> /* Use AT_PHDR address to guess where the main executable is mapped,
> and try to map the jump pad before it. The jump pad should be
> closed enough to the executable for unconditional branch (+/- 32MB). */
>
> uintptr_t base = getauxval (AT_PHDR);
> uintptr_t pagesz = sysconf (_SC_PAGE_SIZE);
> uintptr_t hint = (base & ~(pagesz - 1)) - 1 * 1024 * 1024;
>
> /* Is wrap around? */
> if (hint > base)
> hint = pagesz;
>
> return hint;
> }
Looks OK to me. Note that getauxval was only introduced with
a relatively recent glibc release, so might warrant a configure
check to avoid breaking the build on older releases ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com
More information about the Gdb-patches
mailing list