//Reading specs from /usr/local/cross-arm/bin/../lib/gcc-lib/arm-linux/3.3.2/specs //Configured with: /home/localgjs/tnbt_cvstrees/software/tools/gcc/../../tools/gcc/configure --target=arm-linux --disable-shared --disable-threads --with-gnu-as --with-gnu-ld --enable-multilib --enable-languages=c --prefix=/usr/local/cross_arm --with-headers=/home/localgjs/tnbt_cvstrees/software/tools/gcc/../../os/linux/include/ //Thread model: single //gcc version 3.3.2 // This fails if compiled with... /usr/local/cross-arm/bin/arm-linux-gcc -O1 -mbig-endian -march=armv3 -o test.o -c test.c // It generates code which sets *us to be 0, not 0x800 // With not big-endian, or without optimization, or with a Thumb-capable arch, it works void test(unsigned short *us) { *us = (unsigned short)0x800; return; } Output code from above: Disassembly of section .text: 00000000 <test>: 0: e3a03000 mov r3, #0 ; 0x0 4: e5c03000 strb r3, [r0] 8: e5c03001 strb r3, [r0, #1] c: e1a0f00e mov pc, lr If built without -big-endian the output is correct: Disassembly of section .text: 00000000 <test>: 0: e3a03000 mov r3, #0 ; 0x0 4: e5c03000 strb r3, [r0] 8: e3a03008 mov r3, #8 ; 0x8 c: e5c03001 strb r3, [r0, #1] 10: e1a0f00e mov pc, lr
gcc-4.0.1 works fine. $ arm-linux-eabi-gcc gcc-pr22528.c -O2 -march=armv3 -S -mlittle-endian test: mov r3, #8 mov r2, #0 strb r3, [r0, #1] strb r2, [r0, #0] mov pc, lr $ arm-linux-eabi-gcc gcc-pr22528.c -O2 -march=armv3 -S -mbig-endian test: mov r3, #0 mov r2, #8 strb r3, [r0, #1] strb r2, [r0, #0] mov pc, lr
The 3.3 branch is no-longer being maintained, and this was fixed in gcc-3.4. If you need to patch a 3.3 compiler you can apply the patch from here: http://gcc.gnu.org/ml/gcc-patches/2003-11/msg00832.html
*** Bug 24528 has been marked as a duplicate of this bug. ***