x86: Disable sibcall if indirect_return attribute doesn't match
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 14 Jul 2022 17:31:21 +0000 (10:31 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 15 Jul 2022 23:58:05 +0000 (16:58 -0700)
commit2582080f19e8fe9c1204dfb6fecf744311f00777
treeccb21c1bca24976e4f9b669fcddf28c46ada2dec
parentfd3d25d6df1cbd385d2834ff3059dfb6905dd75c
x86: Disable sibcall if indirect_return attribute doesn't match

When shadow stack is enabled, function with indirect_return attribute
may return via indirect jump.  In this case, we need to disable sibcall
if caller doesn't have indirect_return attribute and indirect branch
tracking is enabled since compiler won't generate ENDBR when calling the
caller.

gcc/

PR target/85620
* config/i386/i386.cc (ix86_function_ok_for_sibcall): Return
false if callee has indirect_return attribute and caller
doesn't.

gcc/testsuite/

PR target/85620
* gcc.target/i386/pr85620-2.c: Updated.
* gcc.target/i386/pr85620-5.c: New test.
* gcc.target/i386/pr85620-6.c: Likewise.
* gcc.target/i386/pr85620-7.c: Likewise.
gcc/config/i386/i386.cc
gcc/testsuite/gcc.target/i386/pr85620-2.c
gcc/testsuite/gcc.target/i386/pr85620-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr85620-6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr85620-7.c [new file with mode: 0644]