From: Matt Fischer <mattfischer84@gmail.com>
To: Matt Fischer <mattfischer84@gmail.com>, gdb@sourceware.org
Subject: Re: ARM signal trampolines
Date: Mon, 18 Jan 2010 22:27:00 -0000 [thread overview]
Message-ID: <be62573b1001181427y56441d50md314b545db0c6f12@mail.gmail.com> (raw)
In-Reply-To: <20100115231656.GA31325@caradoc.them.org>
On Fri, Jan 15, 2010 at 5:17 PM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> Looks that way. This code doesn't matter though... GLIBC always sets
> SA_RESTORER. What C library are you using that could trigger this
> at all?
I'm working on an Android system. Bionic doesn't seem to bother with
SA_RESTORER--it just wires sigaction() straight up to the syscall, so
unless you specify your own, the kernel sets up the stack frame with a
return address pointing to the trampolines on the vector page.
> None of this code is for the vector area trampolines which are brand
> new. Just a few months old, I believe. It is for the SA_RESTORER
> functions in glibc.
I guess I'm confused--the code I'm looking at appears to have been in
the kernel since about 2.6.13--it's the vector of return codes called
sigreturn_codes[] in arch/arm/kernel/signal.c, which gets copied to
the vector page by trap_init() in arch/arm/kernel/traps.c. Is there
some other change which has been made to this mechanism in more recent
kernels?
>> 2. A bigger problem, though, is that GDB can't seem to read the
>> vector table area at all. Any attempt to examine that memory area
>> results in garbage values. Indeed, I can't even seem to get ptrace()
>> to read that memory area in any process--any attempt to do so just
>> returns -1. This makes it seem as though the kernel just doesn't let
>> you read that region via ptrace() at all.
>
> That's correct. There's a workaround for single-stepping through the
> atomic operations on the same vector page, for this reason. The
> correct solution depends on whether the signal trampolines are at an
> ABI-fixed address. If they are, we could hardcode them. Otherwise,
> someone has to stop putting off making the page ptrace readable.
Given what you've said, the easiest thing to do for my purposes is
probably just to patch Bionic to use SA_RESTORER. Then I can just
ensure the trampoline is constructed to match what's already in there
for glibc, and things should all work out. I don't know if I could
get it accepted upstream or not, but it should at least allow my local
testing to work out.
Long term, though, it would certainly be nice if gdb could see the
vector page--I've run into a couple situations where I've needed to
see what was in there, and gdb wasn't able to help. It seems like the
kernel patch to do this wouldn't be overly complicated--is there some
reason that this isn't a desirable feature, or is it just that
nobody's had a pressing enough need for it so far?
--Matt
next prev parent reply other threads:[~2010-01-18 22:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-15 22:47 Matt Fischer
2010-01-15 23:17 ` Daniel Jacobowitz
2010-01-18 22:27 ` Matt Fischer [this message]
2010-01-19 4:04 ` Daniel Jacobowitz
2010-01-19 15:14 ` Matt Fischer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=be62573b1001181427y56441d50md314b545db0c6f12@mail.gmail.com \
--to=mattfischer84@gmail.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox