https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119279

--- Comment #6 from Linus Torvalds <torva...@linux-foundation.org> ---
(In reply to Jakub Jelinek from comment #5)
> Call instructions are normally valid anywhere in the function, including
> prologue and epilogue, even with frame pointers.

Sure, the call instruction actually works regardless. 

This is mostly related to the kernel build doing a lot of various sanity
checking of various object file rules, and following the stack setup is part of
that. Part of it is wanting to have reliable stack frames for the special
cases, part of it is sanity checking of the code.

And one of those rules is basically "non-leaf functions have frame pointers if
we have them enabled in the kernel config".

And I think your example of calls without frames is more than a bit misleading. 

Yes, there's __fentry__. A *very* special function. 

And yes, there are tail-calls. But tail calls are - by definition - returning
to where the frame is. It's not a "call" at all, it has been turned into a
"jmp".

So I think both of your alleged "normally valid" examples are misleading to the
point of being outright falsehoods.

And the code you then quote shows the actual *real* calls being done with the
frame in place, do they not? So why are you arguing that inline asms shouldn't
follow the same rules that the compiler does for the call instructions it
generates?

Now, I agree that the kernel could likely solve issues by just "don't check so
much, then". But our build-time object file checking does actually find real
issues, because we tend to have various constraints that normal programs don't
have (and we do various rewriting of the object files due to them, which is
another big reason for checking: making sure the rewriting tool understands the
code it rewrites!).

You can see some 'objtool' docs at

https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/objtool/Documentation/objtool.txt

so yes, we have some tighter rules than maybe other projects have.

Reply via email to