[FFmpeg-cvslog] Hack around gcc 4.6 breaking asm using call.

Reimar Döffinger git at videolan.org
Wed Sep 21 23:52:32 CEST 2011


ffmpeg | branch: release/0.8 | Reimar Döffinger <Reimar.Doeffinger at gmx.de> | Sun Aug 28 21:14:13 2011 +0200| [f36cea267381571488070d3d6b8290359f3f94d3] | committer: Carl Eugen Hoyos

Hack around gcc 4.6 breaking asm using call.

gcc 4.6 no longer decrements esp to account for local variables.
Thus using call will end up overwriting some local variable.
So add an extra one it can safely clobber.
This is a huge hack because it's basically pure chance it works,
no idea how this is supposed to be done.

Fixes trac ticket #397.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
(cherry picked from commit c928e9172928f3cddab949b107dd53b6bf79555e)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f36cea267381571488070d3d6b8290359f3f94d3
---

 libswscale/x86/swscale_template.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c
index 25399fa..e715270 100644
--- a/libswscale/x86/swscale_template.c
+++ b/libswscale/x86/swscale_template.c
@@ -2240,6 +2240,10 @@ static void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
 #if defined(PIC)
     DECLARE_ALIGNED(8, uint64_t, ebxsave);
 #endif
+    // HACK: gcc 4.6 no longer decrements esp,
+    // use this to make it reserve space for the call
+    // return address
+    void *dummy;
 
     __asm__ volatile(
 #if defined(PIC)
@@ -2291,6 +2295,7 @@ static void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
 #if defined(PIC)
           ,"m" (ebxsave)
 #endif
+          ,"m" (dummy)
         : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
 #if !defined(PIC)
          ,"%"REG_b
@@ -2312,6 +2317,10 @@ static void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,
 #if defined(PIC)
     DECLARE_ALIGNED(8, uint64_t, ebxsave);
 #endif
+    // HACK: gcc 4.6 no longer decrements esp,
+    // use this to make it reserve space for the call
+    // return address
+    void *dummy;
 
     __asm__ volatile(
 #if defined(PIC)
@@ -2351,6 +2360,7 @@ static void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,
 #if defined(PIC)
           ,"m" (ebxsave)
 #endif
+          ,"m" (dummy)
         : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
 #if !defined(PIC)
          ,"%"REG_b



More information about the ffmpeg-cvslog mailing list