From: David Laight <David.Laight@ACULAB.COM>
To: 'Josh Poimboeuf' <jpoimboe@redhat.com>,
"vanessa.hack@fau.de" <vanessa.hack@fau.de>
Cc: "peterz@infradead.org" <peterz@infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: objtool/ORC generation for noreturn functions
Date: Wed, 13 Jan 2021 22:39:53 +0000 [thread overview]
Message-ID: <8bfda75985c4429297afce9340303e34@AcuMS.aculab.com> (raw)
In-Reply-To: <20210113184131.yh4zh4olfkdpydv7@treble>
> On Wed, Jan 13, 2021 at 11:44:22AM +0100, vanessa.hack@fau.de wrote:
> > Hi,
> > I am currently writing my final thesis at university on the topic of stack
> > unwinding. My goal is to implement and evaluate stack unwinders for
> > research operating system ports to x86 32 and 64 bit architectures and
> > SPARC V8.
> > For the x86 ports I chose ORC as unwinding format due to its simplicity
> > and reliability. So far, it works quite well (although I've ran into some
> > minor issues with objtool as the research OS is written in C++).
> > But now I have some problems with functions that are explicitly marked as
> > noreturn with the [[noreturn]] attribute, all following unwinding steps
> > are unreliable. I have read in the objtool documentation that such
> > functions have to be added to the objtool global_noreturn array.
> > Unfortunately, I do not understand the purpose of that array and the
> > intended ORC behaviour for noreturn functions. Are the unwinding steps
> > that follow a noreturn intended to be unreliable?
There was an 'interesting' unwinder I saw a few years ago.
(Which couldn't handle 'noreturn' functions.)
The idea is to follow forwards through the code while keeping
track of %sp and %fp until a return instruction is found.
You need to be able to detect loops, and then continue from
the other target of an earlier conditional branch.
Provided function calls don't change %sp they can be ignored.
If the %fp isn't used as a frame pointer it won't get reloaded
into %sp so it doesn't matter
This works (most of the time) with no debug info and no symbol
table.
Adding a code marker after a call to a 'notreturn' function (eg 'jmp .')
might be the simplest way of stopping them being an issue.
The extra instruction is unlikely to be an issue.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2021-01-13 22:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <daf04159-a458-4f0d-9f29-d8ef5a63fae6@email.android.com>
2021-01-13 18:41 ` Josh Poimboeuf
2021-01-13 22:39 ` David Laight [this message]
2021-01-13 22:45 ` Josh Poimboeuf
2021-01-14 19:35 ` Hack, Vanessa
2021-01-14 19:47 ` Josh Poimboeuf
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=8bfda75985c4429297afce9340303e34@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=vanessa.hack@fau.de \
/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
all inboxes | Powered by JetHome®