This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ARM: Invalid Stack Alignment



Hi All,

  I have been trying the latest CVS version on the ARM processor and
the compiler now generates unaligned stack pointers which are invalid
on the ARM.  This happens alot in my code with "-O[123]" but it also
happens with "-O0" ... so here is a test case that generates invalid
code with "-O0":

A Simple Test Program:

--- t.c -------------------------
void *a;

int 
f(void) 
{
        unsigned char b;

        if(g(a, 0x002000, &b, 1) != 1)
                return -1;
        return b;
}
---------------------------------

Compiled with "arm-elf-gcc -S t.c" produces:

--- t.s -------------------------
@ Generated by gcc 2.96 20000309 (experimental) for ARM/elf
	.file	"t.c"
 .gcc2_compiled.:
.text
	.align	2
	.global	f
	.type	 f,function
f:
	@ args = 0, pretend = 0, frame = 1
	@ frame_needed = 1, current_function_anonymous_args = 0
	mov	ip, sp
	stmfd	sp!, {fp, ip, lr, pc}
	sub	fp, ip, #4
	sub	sp, sp, #1            <<=== ** BUG **
	ldr	r3, .L4
	sub	r2, fp, #13
	ldr	r0, [r3, #0]
	mov	r1, #8192
	mov	r3, #1
	bl	g
	mov	r3, r0
	cmp	r3, #1
	beq	.L3
	mvn	r0, #0
	b	.L2
.L3:
	ldrb	r3, [fp, #-13]	@ zero_extendqisi2
	mov	r0, r3
.L2:
	ldmea	fp, {fp, sp, pc}
.L5:
	.align	2
.L4:
	.word	a
.Lfe1:
	.size	 f,.Lfe1-f
	.comm	a, 4	@ 4
----------------------------------------------

	Thanks,

		CraigN
--
      Craig Newell                email: CraigN@cheque.uq.edu.au
      Free Spirit                 icbm:  somewhere in NJ, USA



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]