[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LSU.2.20.2209141201400.8265@wotan.suse.de>
Date: Wed, 14 Sep 2022 12:08:37 +0000 (UTC)
From: Michael Matz <matz@...e.de>
To: Josh Poimboeuf <jpoimboe@...nel.org>
cc: Segher Boessenkool <segher@...nel.crashing.org>,
Mark Rutland <mark.rutland@....com>,
Peter Zijlstra <peterz@...radead.org>,
linuxppc-dev@...ts.ozlabs.org,
Chen Zhongjin <chenzhongjin@...wei.com>, x86@...nel.org,
Nick Desaulniers <ndesaulniers@...gle.com>,
linux-kernel@...r.kernel.org, Mark Brown <broonie@...nel.org>,
Sathvika Vasireddy <sv@...ux.ibm.com>,
linux-toolchains@...r.kernel.org,
Indu Bhagat <indu.bhagat@...cle.com>,
live-patching@...r.kernel.org, Miroslav Benes <mbenes@...e.cz>,
Will Deacon <will@...nel.org>,
Ard Biesheuvel <ardb@...nel.org>,
linux-arm-kernel@...ts.infradead.org,
"Jose E. Marchesi" <jemarch@....org>
Subject: Re: [RFC] Objtool toolchain proposal:
-fannotate-{jump-table,noreturn}
Hello,
On Wed, 14 Sep 2022, Josh Poimboeuf wrote:
> > > This information is needed because the
> > > code after the call to such a function is optimized out as
> > > unreachable and objtool has no way of knowing that.
> >
> > Since June we (GCC) have -funreachable-traps. This creates a trap insn
> > wherever control flow would otherwise go into limbo.
>
> Ah, that's interesting, though I'm not sure if we'd be able to
> distinguish between "call doesn't return" traps and other traps or
> reasons for UD2.
There are two reasons (which will turn out to be the same) for a trap (say
'UD2' on x86-64) directly after a call insn:
1) "the call shall not have returned"
2) something else jumps to that trap because it was __builtin_unreachable
(or equivalent), and the compiler happened to put that ud2 directly
after the call. It could have done that only when the call itself was
noreturn:
cmp $foo, %rax
jne do_trap
call noret
do_trap:
ud2
So, it's all the same. If there's an ud2 (or whatever the trap maker is)
after a call then it was because it's noreturn.
(But, of course this costs (little) code size, unlike the non-alloc
checker sections)
Ciao,
Michael.
Powered by blists - more mailing lists