[poky] Bad ARM code with GCC 4.7.1
Gary Thomas
gary at mlbassoc.com
Thu May 10 07:28:00 PDT 2012
After updating to the latest master, I'm running into trouble
using GCC 4.7.1 with my ARM kernel(s).
The problem code is in mm/percpu.c - this function [header]
static void pcpu_dump_alloc_info(const char *lvl,
const struct pcpu_alloc_info *ai)
{
int group_width = 1, cpu_width = 1, width;
char empty_str[] = "--------";
int alloc = 0, alloc_end = 0;
int group, v;
int upa, apl; /* units per alloc, allocs per line */
generates this code:
0xc03669d0 <pcpu_dump_alloc_info>: ldr r3, [pc, #532] ; 0xc0366bec <pcpu_dump_alloc_info+540>
0xc03669d4 <pcpu_dump_alloc_info+4>: push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
0xc03669d8 <pcpu_dump_alloc_info+8>: sub sp, sp, #52 ; 0x34
0xc03669dc <pcpu_dump_alloc_info+12>: ldr r2, [r3]
0xc03669e0 <pcpu_dump_alloc_info+16>: mov r4, r1
0xc03669e4 <pcpu_dump_alloc_info+20>: mov r10, r0
which in turn generates an alignment exception at pcpu_dump_alloc_info+12
The same code generates this using GCC 4.6.3
0xc02bf6b0 <pcpu_dump_alloc_info>: push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
0xc02bf6b4 <pcpu_dump_alloc_info+4>: sub sp, sp, #52 ; 0x34
0xc02bf6b8 <pcpu_dump_alloc_info+8>: mov r4, r1
0xc02bf6bc <pcpu_dump_alloc_info+12>: mov r2, #9
0xc02bf6c0 <pcpu_dump_alloc_info+16>: str r0, [sp, #20]
0xc02bf6c4 <pcpu_dump_alloc_info+20>: add r0, sp, #39 ; 0x27
0xc02bf6c8 <pcpu_dump_alloc_info+24>: ldr r1, [pc, #444] ; 0xc02bf88c <pcpu_dump_alloc_info+476>
0xc02bf6cc <pcpu_dump_alloc_info+28>: mov r9, #1
0xc02bf6d0 <pcpu_dump_alloc_info+32>: bl 0xc017f2a0 <memcpy>
Which looks much better to me - the runtime assignment
char empty_str[] = "--------";
should cause the 9 byte string "--------" to be copied to the
stack variable.
I even tried to rewrite the code to match GCC 4.6.3 as
char empty_str[10];
memcpy(empty_str, "--------", 9);
but GCC 4.7.1 managed to generate the same bad code :-(
If I disable CONFIG_OPTIMIZE_FOR_SPEED, i.e. use -O2 instead of -Os,
this function is compiled properly. Sadly, there are other gremlins
in there as Linux-3.0 still crashes when built with GCC 4.7.1
Are these known problems? Are there work arounds?
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
More information about the poky
mailing list