From c068f68557e6a0d7d2f5232221900205076429aa Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Fri, 6 Jul 2018 23:32:25 +0100 Subject: games-emulation/zsnes: apply stack realignment to more functions Expand existing stack realignment hack to more C functions that get called from early init assembly. Fixes zsnes startup for me. Bug: https://bugs.gentoo.org/503138 Package-Manager: Portage-2.3.41, Repoman-2.3.9 --- .../zsnes/files/zsnes-1.51-stack-align-v2.patch | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch (limited to 'games-emulation/zsnes/files') diff --git a/games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch b/games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch new file mode 100644 index 000000000000..35613a953596 --- /dev/null +++ b/games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch @@ -0,0 +1,56 @@ +zsnes call C initialization code from assembler. + +Example backtrace: + + Thread 1 "zsnes" received signal SIGSEGV, Segmentation fault. + => 0xf7550275 <+37>: vmovdqa (%esp),%xmm1 + ... + #13 0x5699ef82 in InitSound () at linux/audio.c:336 + #14 0x569a25af in initwinvideo () at linux/sdllink.c:1080 + #15 0x5699fc13 in initvideo () at linux/sdllink.c:1298 + #16 0x56f9d5bc in regptwa () + #17 0x56a34b50 in SA1tableG () + #18 0x56f84788 in selcB800 () + ... + +Call to 'initwinvideo' (first C function) looks like that: + NEWSYM InitPreGame ; Executes before starting/continuing a game + mov byte[pressed+1],2 + pushad + call Start60HZ + %ifdef __OPENGL__ + call drawscreenwin + %endif + call initwinvideo + +Note: pushad / call does not 16-byte maintain stack alignment +and breaks i386 ABI. + +We apply realignment attribute to all functions noticed by users. +Bug: https://bugs.gentoo.org/503138 +--- src/linux/sdllink.c.old ++++ src/linux/sdllink.c +@@ -773,11 +773,11 @@ BOOL InitInput() + { + InitJoystickInput(); + return TRUE; + } + +-int startgame() ++int __attribute__((force_align_arg_pointer)) startgame() + { + static bool ranonce = false; + int status; + + if (!ranonce) +--- a/linux/sdllink.c ++++ b/linux/sdllink.c +@@ -897,7 +897,7 @@ bool OGLModeCheck() + return(cvidmode > 4); + } + +-void initwinvideo(void) ++void __attribute__((force_align_arg_pointer)) initwinvideo(void) + { + DWORD newmode = 0; + -- cgit v1.2.3-65-gdbad