Julian, This patch works for register ld/st, but doesn't work for immediate, as showed in example.
Would you further improve it for imm? Thanks - Joey $ arm-none-eabi-gcc -v 2>&1 | grep version gcc version 4.7.0 20110922 (experimental) [trunk revision 179074] (GCC) $ cat u.c struct packed_str { char f0; int f1; }__attribute__((packed)) u; void foo(int a) { u.f1 = a; // works fine } void bar() { u.f1 = 1; // doesn't work } $ arm-none-eabi-gcc -mthumb -march=armv7 -S -O2 u.c $ cat u.s .syntax unified .arch armv7 .fpu softvfp .eabi_attribute 20, 1 .eabi_attribute 21, 1 .eabi_attribute 23, 3 .eabi_attribute 24, 1 .eabi_attribute 25, 1 .eabi_attribute 26, 1 .eabi_attribute 30, 2 .eabi_attribute 34, 1 .eabi_attribute 18, 4 .thumb .file "u.c" .text .align 2 .global foo .thumb .thumb_func .type foo, %function foo: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. movw r3, #:lower16:u movt r3, #:upper16:u str r0, [r3, #1] @ unaligned bx lr .size foo, .-foo .align 2 .global bar .thumb .thumb_func .type bar, %function bar: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. movw r3, #:lower16:u movs r1, #0 movt r3, #:upper16:u @ Still uses aligned str from here ldrb r2, [r3, #0] @ zero_extendqisi2 strb r1, [r3, #4] orr r2, r2, #256 str r2, [r3, #0] bx lr .size bar, .-bar .comm u,5,4 .ident "GCC: (GNU) 4.7.0 20110922 (experimental) [trunk revision 179074]"