It appears that 4.4.0 cegcc doesn't align properly. There's a simple test code:

typedef struct{
        int i;
        short d __attribute__((aligned(16)));
} test16 __attribute__((aligned(16))) ;

void do_test16_dummy(void *);
void do_test16_stack(int N)
{
        test16 tmp[N];
        do_test16_dummy(&tmp[0]);
}

>From that code, sizeof test16 is at least 32 bytes, but cegcc 4.4.0 compiles 
>it as if it was 16 bytes only. At the same time gcc for android based on 4.4.0 
>generates correct code, cegcc 4.1.0 also generates correct code.


Command line used:
/opt/mingw32ce-4.4.0/bin/arm-mingw32ce-gcc -O3 -std=gnu99 -fomit-frame-pointer 
-S -o align16.s.4.4.0 align16.c


Outputs:

do_test16_stack:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 1, uses_anonymous_args = 0
        stmfd   sp!, {fp, lr}
        mov     r0, r0, asl #4                             //  <-- error, 
sizeof test16 has to be 32!
        add     r0, r0, #16
        add     fp, sp, #4
        sub     sp, sp, r0
        add     r0, sp, #15
        bic     r0, r0, #15
        bl      do_test16_dummy
        sub     sp, fp, #4
        ldmfd   sp!, {fp, pc}


same compilation with 4.1.0:

do_test16_stack:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 1, uses_anonymous_args = 0
        mov     ip, sp
        stmfd   sp!, {r4, fp, ip, lr, pc}
        mov     r0, r0, asl #5                     // <--- OK
        add     r0, r0, #8
        mov     r4, sp
        rsb     sp, r0, sp
        add     r0, sp, #7
        sub     fp, ip, #4
        bic     r0, r0, #7
        bl      do_test16_dummy
        mov     sp, r4
        sub     sp, fp, #16
        ldmfd   sp, {r4, fp, sp, pc}



android ndk gcc 4.4.0:

do_test16_stack:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 1, uses_anonymous_args = 0
        mov     r0, r0, asl #5                        // <--- OK
        add     r0, r0, #8
        stmfd   sp!, {fp, lr}
        add     fp, sp, #4
        sub     sp, sp, r0
        mov     r0, sp
        bl      do_test16_dummy
        sub     sp, fp, #4
        ldmfd   sp!, {fp, pc}



Any ideas what could be wrong? 4.4.0 from android is OK, could that be related 
to wince related changes or it's (more likely) because there is some bugs 
related to coff and alignment in gcc code?..
The reason I came to that error is that I had a weird problem: I was getting 
misalignment crashes and wanted to printout addresses of some structure members 
and their alignment. At some point I got strange output, where address of 
structure was clearly not 16 bit aligned, but that same address modulo 16 would 
output 0! After I run some tests it looks like it's related to this alignment 
problem.




------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to