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.