[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8bfda75985c4429297afce9340303e34@AcuMS.aculab.com>
Date: Wed, 13 Jan 2021 22:39:53 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Josh Poimboeuf' <jpoimboe@...hat.com>,
"vanessa.hack@....de" <vanessa.hack@....de>
CC: "peterz@...radead.org" <peterz@...radead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: objtool/ORC generation for noreturn functions
> On Wed, Jan 13, 2021 at 11:44:22AM +0100, vanessa.hack@....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)
Powered by blists - more mailing lists