If a little bit more complex interrupt function is required the compiler genrates wrong code (olny with -O flag set). Compiler generats: sub lr, lr, #4 stmfd sp!, {r.., lr} . . . ldmfd sp!, {r.., lr} subs pc, lr, #4 Here the LR is decremented one time too mutch. Ether first or the second "sub" is wrong. It should be: sub lr, lr, #4 stmfd sp!, {r.., lr} . . . ldmfd sp!, {r.., lr}^ (the last '^' is important) P.S. Since I can't add any attachments now. I'll try this after 'commit'.
Created attachment 10497 [details] except.i
Created attachment 10498 [details] working result: arm-elf-gcc -save-temps -mthumb-interwork -march=armv4t -Wall -c except.c
Created attachment 10499 [details] not working result: arm-elf-gcc -save-temps -mthumb-interwork -O -march=armv4t -Wall -c except.c
Created attachment 10500 [details] still working result: arm-elf-gcc -save-temps -mthumb-interwork -march=armv4t -Wall -c except.c
Created attachment 10501 [details] now working result: arm-elf-gcc -save-temps -mthumb-interwork -O -march=armv4t -Wall -c except.c
Created attachment 10502 [details] possible patch (used diff -Bbwu)
To me it looks like, that this patch also fixes Bug #16634 But I might be wrong, here.
Created attachment 10513 [details] working: arm-elf-gcc -save-temps -mthumb-interwork -mapcs-frame -O -march=armv4t -Wall -c except.c
Created attachment 10514 [details] working: arm-elf-gcc -save-temps -mthumb-interwork -mno-apcs-frame -O -march=armv4t -Wall -c except.c
Ping to remember Fails on Version 3.2.3; 3.4.5; 4.0.2; 4.1.0; 4.2.0 (snapshot). Earlier versions with additonal other buggs. So useless to test. Bugfix still exists and working but ignorded at GCC side; Why ?????????????
Assembly in initial comment is bogus. Should be ldmfd {..., pc}^. ldmrd {... lr}^ does somethething completely different. *** This bug has been marked as a duplicate of 16634 ***