ARM: CORTEX M, PRIMASK and FAULTMASK are misplaced, WINDOWS mingw 4.6.1 bug
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Just want to warn anyone who hacks QEMU cortex M support under MinGW, it seems there is a bug in gcc 4.6.1 that compiles this peace of code wrong.
translate.c:
if (IS_M(env)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
/* PRIMASK */
if (insn & 2) {
}
/* FAULTMASK */
if (insn & 1) {
}
if we just switch conditions order it will compile OK
if (IS_M(env)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
/* FAULTMASK */
if (insn & 1) {
}
/* PRIMASK */
if (insn & 2) {
}
I have attached gdb disassembly in the attachment for both cases
That generated code certainly looks fishy, but really you need to report gcc bugs to the gcc folks, not us.
I see from your quoted fragments of source code that you're using a version of QEMU which has a bug in its handling of PRIMASK/FAULTMASK here, incidentally. Commit d3cb6e2b0 (January, not in a QEMU release yet) fixes bug 913925 -- we were passing the wrong constant values.