public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet.
@ 2020-03-18 18:31 gsdrtge6h at protonmail dot com
  2020-03-18 18:32 ` [Bug middle-end/94218] " gsdrtge6h at protonmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gsdrtge6h at protonmail dot com @ 2020-03-18 18:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94218
           Summary: Different __builtin_setjmp/__builtin_longjmp buffer
                    layout is suggested in case of cet.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gsdrtge6h at protonmail dot com
  Target Milestone: ---
            Target: ia32

Created attachment 48058
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48058&action=edit
test for setjmp call

The current implementation layout is to put shadow stack pointer at jb + 16 and
normal stack pointer at jb + 24 when cet is enabled.

        rdsspq  %rax
        movq    %rax, jb_extern+16(%rip)
        movq    %rsp, jb_extern+24(%rip)

When CET is disabled normal stack pointer goes to jb + 16.

It is suggested to switch the locations of shadow stack pointer and normal
stack pointer within the jump buffer.  This way there can be a chance to link
legacy/no-cet __builtin_longjmp() code with cet __builtin_setjmp() code.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/94218] Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet.
  2020-03-18 18:31 [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet gsdrtge6h at protonmail dot com
@ 2020-03-18 18:32 ` gsdrtge6h at protonmail dot com
  2020-03-18 18:36 ` [Bug target/94218] " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: gsdrtge6h at protonmail dot com @ 2020-03-18 18:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from gsdrtge6h at protonmail dot com ---
Created attachment 48059
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48059&action=edit
longjmp part of the test

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/94218] Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet.
  2020-03-18 18:31 [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet gsdrtge6h at protonmail dot com
  2020-03-18 18:32 ` [Bug middle-end/94218] " gsdrtge6h at protonmail dot com
@ 2020-03-18 18:36 ` pinskia at gcc dot gnu.org
  2020-03-18 18:37 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-03-18 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
__builtin_setjmp/__builtin_longjmp really should not be used.  They are
normally used internally for Exception handling if dwarf2 eh is not enabled.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/94218] Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet.
  2020-03-18 18:31 [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet gsdrtge6h at protonmail dot com
  2020-03-18 18:32 ` [Bug middle-end/94218] " gsdrtge6h at protonmail dot com
  2020-03-18 18:36 ` [Bug target/94218] " pinskia at gcc dot gnu.org
@ 2020-03-18 18:37 ` pinskia at gcc dot gnu.org
  2020-03-18 18:38 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-03-18 18:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc/Nonlocal-Gotos.html#index-_005f_005fbuiltin_005fsetjmp

"You should use the standard C library functions declared in <setjmp.h> in user
code instead of the builtins"

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/94218] Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet.
  2020-03-18 18:31 [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet gsdrtge6h at protonmail dot com
                   ` (2 preceding siblings ...)
  2020-03-18 18:37 ` pinskia at gcc dot gnu.org
@ 2020-03-18 18:38 ` pinskia at gcc dot gnu.org
  2020-03-18 18:39 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-03-18 18:38 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
"This can make __builtin_setjmp and __builtin_longjmp more efficient than their
library counterparts in some cases, but it can also cause incorrect and
mysterious behavior when mixing with code that uses the full register set."

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/94218] Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet.
  2020-03-18 18:31 [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet gsdrtge6h at protonmail dot com
                   ` (3 preceding siblings ...)
  2020-03-18 18:38 ` pinskia at gcc dot gnu.org
@ 2020-03-18 18:39 ` pinskia at gcc dot gnu.org
  2020-03-18 18:41 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-03-18 18:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> "This can make __builtin_setjmp and __builtin_longjmp more efficient than
> their library counterparts in some cases, but it can also cause incorrect
> and mysterious behavior when mixing with code that uses the full register
> set."

CET is considered register set differences.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/94218] Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet.
  2020-03-18 18:31 [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet gsdrtge6h at protonmail dot com
                   ` (4 preceding siblings ...)
  2020-03-18 18:39 ` pinskia at gcc dot gnu.org
@ 2020-03-18 18:41 ` pinskia at gcc dot gnu.org
  2020-03-18 18:52 ` gsdrtge6h at protonmail dot com
  2020-03-18 18:55 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-03-18 18:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also:
"GCC provides the built-in functions __builtin_setjmp and __builtin_longjmp
which are similar to, but not interchangeable with, the C library functions
setjmp and longjmp."

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/94218] Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet.
  2020-03-18 18:31 [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet gsdrtge6h at protonmail dot com
                   ` (5 preceding siblings ...)
  2020-03-18 18:41 ` pinskia at gcc dot gnu.org
@ 2020-03-18 18:52 ` gsdrtge6h at protonmail dot com
  2020-03-18 18:55 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: gsdrtge6h at protonmail dot com @ 2020-03-18 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from gsdrtge6h at protonmail dot com ---
Okay, but why the current layout is any better than the suggested layout.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/94218] Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet.
  2020-03-18 18:31 [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet gsdrtge6h at protonmail dot com
                   ` (6 preceding siblings ...)
  2020-03-18 18:52 ` gsdrtge6h at protonmail dot com
@ 2020-03-18 18:55 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-03-18 18:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to gsdrtge6h from comment #7)
> Okay, but why the current layout is any better than the suggested layout.

Because these are not useful for anything really.  The suggested layout might
require big changes in the compiler which does not make a big difference in the
long run anways since these are not used except for testing to make sure sjlj
eh still works.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-03-18 18:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18 18:31 [Bug middle-end/94218] New: Different __builtin_setjmp/__builtin_longjmp buffer layout is suggested in case of cet gsdrtge6h at protonmail dot com
2020-03-18 18:32 ` [Bug middle-end/94218] " gsdrtge6h at protonmail dot com
2020-03-18 18:36 ` [Bug target/94218] " pinskia at gcc dot gnu.org
2020-03-18 18:37 ` pinskia at gcc dot gnu.org
2020-03-18 18:38 ` pinskia at gcc dot gnu.org
2020-03-18 18:39 ` pinskia at gcc dot gnu.org
2020-03-18 18:41 ` pinskia at gcc dot gnu.org
2020-03-18 18:52 ` gsdrtge6h at protonmail dot com
2020-03-18 18:55 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).