gcc miscompiles csum_tcpudp_magic() on ARMv5

Måns Rullgård mans at mansr.com
Thu Dec 12 09:37:59 EST 2013


Willy Tarreau <w at 1wt.eu> writes:

>> #include <stdint.h>
>> #include <stdio.h>
>> 
>> static inline uint32_t asm_add(uint16_t len, uint32_t sum)
>> {
>>         __asm__(
>>         "add    %0, %1, %2 \n"
>>         : "=&r"(sum)
>>         : "r" (sum), "r" (len)
>>         );
>>         return sum;
>> }
>
> Hmmm aren't you passing a 16-bit register directly to the ASM for being used
> as a 32-bit one ? This seems hasardous to me since nowhere you tell gcc how
> you're going to use the register.

There is no such thing as a 16-bit register on ARM.  What this code does
is ask the compiler to take the 16-bit value 'len' and put it in a register
for use in the asm code.  All registers are 32-bit, so there is no ambiguity.

-- 
Måns Rullgård
mans at mansr.com



More information about the linux-arm-kernel mailing list