GCC 4.6.x miscompiling arm-linux?

Matthew Leach matthew at mattleach.net
Tue Sep 11 06:33:20 EDT 2012


Michael Olbrich <mol at pengutronix.de> writes:
>> Btw, Here's what I get from it:
>> 
>> flexcan_chip_start:
>>         @ args = 0, pretend = 0, frame = 0
>>         @ frame_needed = 0, uses_anonymous_args = 0
>>         @ link register save eliminated.
>>         mov     r3, #0
>>         cmp     r0, #9
>>         str     r3, [r1, #0]
>>         ldrle   r3, [r1, #4]
>>         mov     r0, #0
>>         str     r3, [r1, #4]
>>         bx      lr
>>         .size   flexcan_chip_start, .-flexcan_chip_start
>>         .ident  "GCC: (OSELAS.Toolchain-2011.11.1) 4.6.3"
>>         .section        .note.GNU-stack,"",%progbits
>
> How can I reproduce this output? I'd like to test this with different
> toolchain versions.

You can use this code fragment to produce the error:

/* Structure of the hardware registers */
struct flexcan_regs {
	unsigned int mcr;
	unsigned int rxfgmask;
};

#define flexcan_read(a) (*(volatile unsigned int *)(a))
#define flexcan_write(v,a)      (*(volatile unsigned int *)(a) = (v))

int flexcan_chip_start(int ver, struct flexcan_regs *regs)
{
	flexcan_write(0, &regs->mcr);

	if (ver >= 10)
		flexcan_write(0, &regs->rxfgmask);

	return 0;
}

Matt



More information about the linux-arm-kernel mailing list