[Bug target/41999] Bug in generation of interrupt function code for ARM processor
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41999 Domen Puncer domen at cba dot si changed: What|Removed |Added CC||domen at cba dot si --- Comment #3 from Domen Puncer domen at cba dot si 2011-06-16 08:23:25 UTC --- FWIW, this and 45540 don't happen on gcc 4.5.2 anymore (confirmed that it DOES happen on 2010q1-188 4.4.1): irq_: @ Interrupt Service Routine. @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 sublr, lr, #4 stmfdsp!, {r0, r1, r2, r3, r4, r5, ip, lr} ldrr4, .L2 ldrr0, [r4, #0] blexternal ldrr0, [r4, #0] movr3, r0, asl #1 movr0, r3 strr3, [r4, #0] blexternal ldmfdsp!, {r0, r1, r2, r3, r4, r5, ip, pc}^ .L3: .align2 .L2: .word.LANCHOR0 .sizeirq_, .-irq_ .bss .align2 .set.LANCHOR0,. + 0 .typecnt, %object .sizecnt, 4 cnt: .space4 .identGCC: (Sourcery G++ Lite 2011.03-42) 4.5.2
[Bug target/49437] New: interrupt return pop sometimes corrupts sp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49437 Summary: interrupt return pop sometimes corrupts sp Product: gcc Version: 4.5.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: do...@cba.si Simple to reproduce, it seems =5 arguments with any of printf* can cause this. Some code around it was left, as it does not happen otherwise. $ cat bug.c #include stdio.h char *pending_messages_put_start(void); void pending_messages_put_final(void); void __attribute__((interrupt)) TIM7_IRQHandler(void) { char *msg = pending_messages_put_start(); snprintf(msg, 20, %i %i, 1, 1); pending_messages_put_final(); } $ arm-none-eabi-gcc -Wall -Os -S bug.c $ cat bug.s .syntax unified .arch armv7-m .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, 4 .eabi_attribute 18, 4 .thumb .file bug.c .text .align 1 .global TIM7_IRQHandler .thumb .thumb_func .type TIM7_IRQHandler, %function TIM7_IRQHandler: @ Stack Align: May be called with mis-aligned SP. @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 mov r0, sp bic r1, r0, #7 mov sp, r1 push{r0, lr} sub sp, sp, #8 bl pending_messages_put_start movsr3, #1 movsr1, #20 ldr r2, .L2 str r3, [sp, #0] bl snprintf bl pending_messages_put_final pop {r0, r2, r3, lr}// -- r3 is in place of r0; expected would be add sp, sp, #8, pop {r0, lr}, I guess mov sp, r0 bx lr .L3: .align 2 .L2: .word .LC0 .size TIM7_IRQHandler, .-TIM7_IRQHandler .section.rodata.str1.1,aMS,%progbits,1 .LC0: .ascii %i %i\000 .ident GCC: (GNU) 4.5.3
[Bug c/46762] New: gcc crosscompiled for arm optimises away volatile struct member access when -Os
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46762 Summary: gcc crosscompiled for arm optimises away volatile struct member access when -Os Product: gcc Version: 4.5.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: do...@cba.si $ cat bug.c struct GPIO { volatile unsigned int IDR; } *GPIO = (struct GPIO *)(0x40010808); volatile unsigned int *GPIO_PTR = (volatile unsigned int *)(0x40010808); static inline int gpio_get_value_ok() { if (*GPIO_PTR 1) return 1; return 0; } void function_with_no_bug(void) { int timeout = 0x100; while (gpio_get_value_ok() == 0) { if (timeout-- == 0) { return; } } } static inline int gpio_get_value_wrong() { if (GPIO-IDR 1) return 1; return 0; } void function_with_bug(void) { int timeout = 0x100; while (gpio_get_value_wrong() == 0) { if (timeout-- == 0) { return; } } } $ arm-none-eabi-gcc -Wall -Os -c bug.c -o bug.o arm-none-eabi-objdump -xd bug.o bug.o: file format elf32-littlearm bug.o architecture: arm, flags 0x0011: HAS_RELOC, HAS_SYMS start address 0x private flags = 500: [Version5 EABI] Sections: Idx Name Size VMA LMA File off Algn 0 .text 0030 0034 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 1 .data 0008 0064 2**2 CONTENTS, ALLOC, LOAD, DATA 2 .bss 006c 2**0 ALLOC 3 .comment 002b 006c 2**0 CONTENTS, READONLY 4 .ARM.attributes 0034 0097 2**0 CONTENTS, READONLY SYMBOL TABLE: ldf *ABS* bug.c ld .text .text ld .data .data ld .bss .bss ld .comment .comment ld .ARM.attributes .ARM.attributes g F .text 002c function_with_no_bug 002c g F .text 0004 function_with_bug 0004 g O .data 0004 GPIO g O .data 0004 GPIO_PTR Disassembly of section .text: function_with_no_bug: 0: e59f3020ldr r3, [pc, #32] ; 28 function_with_no_bug+0x28 4: e5932000ldr r2, [r3] 8: e3a03401mov r3, #16777216 ; 0x100 c: e5921000ldr r1, [r2] 10: e3110001tst r1, #1 14: 112fff1ebxnelr 14: R_ARM_V4BX *ABS* 18: e353cmp r3, #0 1c: 012fff1ebxeqlr 1c: R_ARM_V4BX *ABS* 20: e2433001sub r3, r3, #1 24: eaf8b c function_with_no_bug+0xc 28: .word 0x 28: R_ARM_ABS32 .data 002c function_with_bug: 2c: e12fff1ebx lr 2c: R_ARM_V4BX *ABS* $ arm-none-eabi-gcc -v Using built-in specs. COLLECT_GCC=arm-none-eabi-gcc COLLECT_LTO_WRAPPER=/home/domen/toolchains/arm-2010.09/bin/../libexec/gcc/arm-none-eabi/4.5.1/lto-wrapper Target: arm-none-eabi Configured with: /scratch/julian/2010q3-release-eabi-lite/src/gcc-4.5-2010.09/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2010 -D__CS_SOURCERYGXX_MIN__=9 -D__CS_SOURCERYGXX_REV__=51 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --disable-shared --enable-lto --with-newlib --with-pkgversion='Sourcery G++ Lite 2010.09-51' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --with-sysroot=/opt/codesourcery/arm-none-eabi --with-build-sysroot=/scratch/julian/2010q3-release-eabi-lite/install/arm-none-eabi --with-gmp=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-pc-linux-gnu/usr --with-mpc=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-pc-linux-gnu/usr --with-ppl=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-pc-linux-gnu/usr