On Mon, Apr 17, 2017 at 05:02:32PM +0100, Paul Brook wrote:
> Package: libsbc1
> Version: 1.3-1+b2
> Followup-For: Bug #856487
> 
> Not a stack corruption.
> 
> This is miscompilation of sbc_analyze_4b_8s_armv6.  gcc appears to look
> into the asm function and decides that it does not clobber r3 (which the
> normal ARM ABI says is call clobbered).  The last out += out_stride ends
> up incrementing the pointer by an arbitrary amount.
> 
> The attached patch works around the bug.

Unfortunately this is not correct since extended asm is not allowed in 
naked functions.

Short-term I'd suggest to use the attached patch, that disables the 
ARMv6 asm implementation and uses the C implementation instead.

> I'm not entirely sure whether this is a gcc bug or not, but at best it's
> surprising behavior from gcc.  I've attached a reduced testcase for the 
> toolchain
> folks to argue over (compile with gcc -O2, tested with gcc 6.3.0-2 from
> sid).

This is either a bug in gcc or insufficient documentation in gcc.

Could you (or did you already) submit that to the gcc bugzilla?

> Paul
>...

Thanks
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

Description: Disable the ARMv6 asm implementation
 This gets miscompiled with recent gcc since gcc does not consider
 r3 clobbered by the basic asm in a naked function (see #856487).
 .
 The imost simple short-term fix is to disable the ARMv6 asm
 implementation on armhf and use the C implementation instead.
Author: Adrian Bunk <b...@debian.org>
Bug-Debian: https://bugs.debian.org/856487

--- sbc-1.3.orig/sbc/sbc_primitives_armv6.h
+++ sbc-1.3/sbc/sbc_primitives_armv6.h
@@ -35,7 +35,7 @@
 	defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_7__) || \
 	defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || \
 	defined(__ARM_ARCH_7M__)
-#define SBC_HAVE_ARMV6 1
+//#define SBC_HAVE_ARMV6 1
 #endif
 
 #if !defined(SBC_HIGH_PRECISION) && (SCALE_OUT_BITS == 15) && \

Reply via email to