On Sat, Apr 27, 2013 at 07:40:38PM +0200, Jonas Gorski wrote:
> On Sat, Apr 27, 2013 at 3:38 PM, Sergey Vlasov <v...@altlinux.ru> wrote:
[...]
> > The "madd $3,$2" command here is incorrect - it performs sign
> > extension of its arguments; it should be "maddu $3,$2".
> 
> I came to the same conclusion after looking at the assembly of the
> function. Using your testcase I tested the available gcc versions. It
> looks the bug is already in vanilla gcc up to 4.7.2, but is fixed in
> 4.8.0. At least I see a maddu there instead of a addu. I did not test 4.7.3.

I tested 4.7.3 (using crosstool-ng), and it has the same bug.  And now
finally managed to compile 4.8.0, and can confirm that the bug does
not appear there at least with my test code (and 4.8.0 also does not
generate a useless "move" command, like 4.6-linaro and unlike 4.7.x).

Note that adding an explicit u32 cast avoids the problem even with a buggy
compiler:

static inline u32 get_unaligned_le32(const u8 *p)
{
        return (u32)p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
}

> Now the next step will finding the appropriate changeset and backport
> it to 4.6.x/4.7.x.

Hope you will be able to find it - who knows where else similar
miscompiled code may appear.

Attachment: signature.asc
Description: Digital signature

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to