public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Martitz <thomas.martitz@student.HTW-Berlin.de>
To: gcc-help@gcc.gnu.org
Subject: Problems migrating to gcc 4.4.3&eabi  - apparently a gcc bug
Date: Tue, 09 Mar 2010 16:31:00 -0000	[thread overview]
Message-ID: <4B9677C1.6040502@htw-berlin.de> (raw)

Hello,

I'm trying to migrate to gcc 4.4.3 and eabi (from 4.0.3 non-eabi) for 
the ARM targets of Rockbox[1]. I have the strong feeling I stumbled upon 
a gcc bug here.

The story:
The core and codecs run fine under the new compiler, however at least 1 
plugin is problematic: mpegplayer[2]. The cpu throws a data abort when 
rendering begins.

I've narrowed down the problem to the following function call:

mpeg2_idct_add (last, decoder->DCTblock, dest, stride);[3]

mpeg2_idct_add itself is written entirely in assembler. gcc doesn't 
touch it. However, its prototype for C callers is[4]:

void mpeg2_idct_add(const int last, int16_t * block,
                     uint8_t * dest, const int stride);


According to the (E)ABI, all parameters are supposed to be passed in the 
registers r0-3.

The disassembly shows that this only happens for the old gcc4.0.3
new gcc:

30788e98:    ebfff984     bl    307874b0 <get_non_intra_block>
30788e9c:    e1a03000     mov    r3, r0
30788ea0:    e58d301c     str    r3, [sp, #28]
30788ea4:    e59d3014     ldr    r3, [sp, #20]
30788ea8:    e59330d0     ldr    r3, [r3, #208]    ; 0xd0
30788eac:    e59d2008     ldr    r2, [sp, #8]
30788eb0:    e58d2000     str    r2, [sp]
30788eb4:    e59d001c     ldr    r0, [sp, #28]
30788eb8:    e1a02003     mov    r2, r3
30788ebc:    e59d300c     ldr    r3, [sp, #12]
30788ec0:    ebffe28a     bl    307818f0 <mpeg2_idct_add>

old gcc:

30794760:    ebffc861     bl    307868ec <get_non_intra_block>
30794764:    e1a03000     mov    r3, r0
30794768:    e58d3014     str    r3, [sp, #20]
3079476c:    e59d3010     ldr    r3, [sp, #16]
30794770:    e59330d0     ldr    r3, [r3, #208]
30794774:    e59d0014     ldr    r0, [sp, #20]
30794778:    e1a01003     mov    r1, r3
3079477c:    e59d2008     ldr    r2, [sp, #8]
30794780:    e59d3004     ldr    r3, [sp, #4]
30794784:    ebffb4ea     bl    30781b34 <mpeg2_idct_add>

(the above disassemblies are from code generated with -O0 to make the 
parameter passig obvious)

On 4.4.3, 1 parameter is passed via the stack (I figured it goes like 
this from the old to the new compiler:  r0 = r0; r1 > r2; r2 > r3; r3 > 
stack). So, this call works fine with 4.0.3, but does not with 4.4.3.

Now the reason why I think this is a gcc bug:

If I change the prototype to  (the 2nd and 4th argument are swapped, I 
didn't change the callee or the caller, so gcc obviously throws warnings 
but the effective parameter passing was the same):

void mpeg2_idct_add(const int last, const int stride,
                     uint8_t * dest, int16_t * block);


then the plugin runs fine, without data abort. And the disassembly shows 
correct parameter passing.


EABI IIRC only mentions changed rules for passing 64bit types. This call 
should have been the same with 4.4.3. It eventually is if the parameters 
are in a different order.

If this is really a gcc bug, how should we proceed? I assume a bug 
report on bugzilla?

Best regards.


[1]: http://www.rockbox.org/
[2]: http://www.rockbox.org/wiki/PluginMpegplayer
[3]: 
http://svn.rockbox.org/viewvc.cgi/trunk/apps/plugins/mpegplayer/slice.c?revision=17904&view=markup
[4]: 
http://svn.rockbox.org/viewvc.cgi/trunk/apps/plugins/mpegplayer/mpeg2_internal.h?revision=23677&view=markup


             reply	other threads:[~2010-03-09 16:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-09 16:31 Thomas Martitz [this message]
2010-03-09 16:42 ` Andrew Haley
2010-03-09 17:11   ` Thomas Martitz
2010-03-09 18:36     ` Andrew Haley
2010-03-09 18:54       ` Thomas Martitz
2010-03-09 19:11         ` Thomas Martitz
2010-03-09 19:39           ` John (Eljay) Love-Jensen
2010-03-09 19:44             ` Thomas Martitz
2010-03-09 19:46         ` Andrew Haley
2010-03-10 15:56           ` Ian Lance Taylor
2010-03-10 16:36             ` Thomas Martitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B9677C1.6040502@htw-berlin.de \
    --to=thomas.martitz@student.htw-berlin.de \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).