[PATCH] i386; Add indirect_return function attribute

H.J. Lu hjl.tools@gmail.com
Tue Jul 3 16:53:00 GMT 2018


On Tue, Jul 3, 2018 at 9:12 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Tue, Jul 3, 2018 at 5:32 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Fri, Jun 8, 2018 at 3:27 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>> On x86, swapcontext may return via indirect branch when shadow stack
>>> is enabled.  To support code instrumentation of control-flow transfers
>>> with -fcf-protection, add indirect_return function attribute to inform
>>> compiler that a function may return via indirect branch.
>>>
>>> Note: Unlike setjmp, swapcontext only returns once.  Mark it return
>>> twice will unnecessarily disable compiler optimization.
>>>
>>> OK for trunk?
>>>
>>> H.J.
>>> ----
>>> gcc/
>>>
>>>         PR target/85620
>>>         * config/i386/i386.c (rest_of_insert_endbranch): Also generate
>>>         ENDBRANCH for non-tail call which may return via indirect branch.
>>>         * doc/extend.texi: Document indirect_return attribute.
>>>
>>> gcc/testsuite/
>>>
>>>         PR target/85620
>>>         * gcc.target/i386/pr85620-1.c: New test.
>>>         * gcc.target/i386/pr85620-2.c: Likewise.
>>>
>>
>> Here is the updated patch with a testcase to show the impact of
>> returns_twice attribute.
>>
>> Jan, Uros, can you take a look?
>
> LGTM for the implementation, can't say if attribute is really needed or not.

This gives programmers more flexibly.

> +@item indirect_return
> +@cindex @code{indirect_return} function attribute, x86
> +
> +The @code{indirect_return} attribute on a function is used to inform
> +the compiler that the function may return via indiret branch.
>
> s/indiret/indirect/

Fixed.  Here is the updated patch.

Thanks.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-i386-Add-indirect_return-function-attribute.patch
Type: text/x-patch
Size: 5916 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180703/135858c2/attachment.bin>


More information about the Gcc-patches mailing list