public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59178] New: Stack corruption on register save/restore when using frame pointer on pdp-11
@ 2013-11-18 18:54 martin.alcock at praebius dot ca
  2013-11-18 18:55 ` [Bug target/59178] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: martin.alcock at praebius dot ca @ 2013-11-18 18:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59178

            Bug ID: 59178
           Summary: Stack corruption on register save/restore when using
                    frame pointer on pdp-11
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: martin.alcock at praebius dot ca

Created attachment 31239
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31239&action=edit
simple C functions and their assembly prologues/epilogues

When targeting the pdp-11 and more than one register has to be saved in the
function pologue, different modes are used for the save and restore in the
epilogue that causes stack corruption. 

In the prologue, the registers are pushed onto the stack using a "-(sp)",
syntax, however when restored in the epilogue the "xx(fp)" syntax is used
instead, thus not correcting the stack pointer on the restore. R5 is used as
the frame pointer. This causes the code to go wild, as it returns to an address
that previously contained arbitrary register contents.

Attached is a file showing the C source from some small routines and the
assembly code for the prologue and epilogue.


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

* [Bug target/59178] Stack corruption on register save/restore when using frame pointer on pdp-11
  2013-11-18 18:54 [Bug c/59178] New: Stack corruption on register save/restore when using frame pointer on pdp-11 martin.alcock at praebius dot ca
@ 2013-11-18 18:55 ` pinskia at gcc dot gnu.org
  2023-07-13 18:08 ` pkoning at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-11-18 18:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59178

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target
           Severity|blocker                     |normal


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

* [Bug target/59178] Stack corruption on register save/restore when using frame pointer on pdp-11
  2013-11-18 18:54 [Bug c/59178] New: Stack corruption on register save/restore when using frame pointer on pdp-11 martin.alcock at praebius dot ca
  2013-11-18 18:55 ` [Bug target/59178] " pinskia at gcc dot gnu.org
@ 2023-07-13 18:08 ` pkoning at gcc dot gnu.org
  2023-07-15  8:54 ` mikpelinux at gmail dot com
  2023-07-15 16:39 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pkoning at gcc dot gnu.org @ 2023-07-13 18:08 UTC (permalink / raw)
  To: gcc-bugs

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

pkoning at gcc dot gnu.org changed:

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

--- Comment #1 from pkoning at gcc dot gnu.org ---
It works properly in the current version -- I see stack push in the prologue
and matching stack pop operations in the epilogue.

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

* [Bug target/59178] Stack corruption on register save/restore when using frame pointer on pdp-11
  2013-11-18 18:54 [Bug c/59178] New: Stack corruption on register save/restore when using frame pointer on pdp-11 martin.alcock at praebius dot ca
  2013-11-18 18:55 ` [Bug target/59178] " pinskia at gcc dot gnu.org
  2023-07-13 18:08 ` pkoning at gcc dot gnu.org
@ 2023-07-15  8:54 ` mikpelinux at gmail dot com
  2023-07-15 16:39 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mikpelinux at gmail dot com @ 2023-07-15  8:54 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Pettersson <mikpelinux at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpelinux at gmail dot com

--- Comment #2 from Mikael Pettersson <mikpelinux at gmail dot com> ---
This was fixed for gcc-9.1.0, see PR59172.

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

* [Bug target/59178] Stack corruption on register save/restore when using frame pointer on pdp-11
  2013-11-18 18:54 [Bug c/59178] New: Stack corruption on register save/restore when using frame pointer on pdp-11 martin.alcock at praebius dot ca
                   ` (2 preceding siblings ...)
  2023-07-15  8:54 ` mikpelinux at gmail dot com
@ 2023-07-15 16:39 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-15 16:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.0

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

end of thread, other threads:[~2023-07-15 16:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-18 18:54 [Bug c/59178] New: Stack corruption on register save/restore when using frame pointer on pdp-11 martin.alcock at praebius dot ca
2013-11-18 18:55 ` [Bug target/59178] " pinskia at gcc dot gnu.org
2023-07-13 18:08 ` pkoning at gcc dot gnu.org
2023-07-15  8:54 ` mikpelinux at gmail dot com
2023-07-15 16:39 ` 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).