Source: struct s { int i; } __attribute__((packed)); int a(struct s *s) { return s->i; }
Using 4.5: > /usr/local/gcc-arm/bin/arm-none-linux-gnueabi-gcc -Os -mcpu=cortex-a8 -S > unaligned.c > cat unaligned.s .cpu cortex-a8 .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, 2 .eabi_attribute 30, 4 .eabi_attribute 18, 4 .file "unaligned.c" .text .align 2 .global a .type a, %function a: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. ldrb r2, [r0, #1] @ zero_extendqisi2 ldrb r3, [r0, #0] @ zero_extendqisi2 orr r3, r3, r2, asl #8 ldrb r2, [r0, #2] @ zero_extendqisi2 ldrb r0, [r0, #3] @ zero_extendqisi2 orr r3, r3, r2, asl #16 orr r0, r3, r0, asl #24 bx lr .size a, .-a .ident "GCC: (GNU) 4.5.0 20100325 (experimental)" .section .note.GNU-stack,"",%progbits At least some configurations of cortex-a8 support unaligned access just fine, so it should be possible to use it. But it doesn't look like it is - there is no -mno-strict-align for arm. This would be a major code size reduction for FFmpeg. -- Summary: Some ARMs support unaligned Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: astrange at ithinksw dot com GCC target triplet: arm-unknown-linux-gnueabi http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43723