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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
In any case, I agree with Richi that
__builtin_frame_address_(0)
is the right thing, even when the inline asm doesn't use itself %rbp, the
dependency on %rbp is what is needed in the compiler so that
post-prologue/epilogue expansion the inline asm isn't scheduled before the
frame pointer setup, plus there shouldn't be a runtime cost for it at all, the
frame pointer is in %rbp for the whole duration of the body of the function
(except for prologue/epilogue).
The only disadvantage is that it counts to the maximum of 30 input/output
operands of inline asm, but I'd hope the kernel doesn't go near that.
Sure, for -fomit-frame-pointer using it causes a frame pointer, so it needs to
be used conditionally, just define some macro based on whether objtool will
verify for the objects calls are after frame pointer setup or not.  GCC doesn't
predefine macro based on -fomit-frame-pointer vs. -fno-omit-frame-pointer, and
after all, for the kernel guess it is more important whether objtool is told to
check it or not, so the
use of "r" (__builtin_frame_address (0)) or not should be conditionalized on
exactly that.

Reply via email to