http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60084
Bug ID: 60084
Summary: GCC 4.8.3 miscompiles code on ARM at -Os optimization
level
Product: gcc
Version: 4.8.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: florin.iu...@hill-rom.com
Using GCC built by Linaro.
Source code (ROMCopy.c from CodeWarrior 10.5)
CW-MCU-v10.5\MCU\ARM_GCC_Support\ewl\EWL_Runtime\include\arm\ROMCopy.c
-8< ---8< ---8< ---8< ---8< ---8< ---8< ---8< --
RomInfo __S_romp[] __attribute__((weak));/* linker defined symbol */
void __copy_rom_sections_to_ram(void)
{
intindex;
if (__S_romp == 0L) return;
/*
*Go through the entire table, copying sections from ROM to RAM.
*/
for (index = 0;
__S_romp[index].Source != 0 ||
__S_romp[index].Target != 0 ||
__S_romp[index].Size != 0;
++index)
{
__copy_rom_section( __S_romp[index].Target,
__S_romp[index].Source,
__S_romp[index].Size );
__flush_cache( __S_romp[index].Target, __S_romp[index].Size);
}
}
-8< ---8< ---8< ---8< ---8< ---8< ---8< ---8< --
Compiled with 4.7_2013q1
gcc version 4.7.3 20130312 (release) [ARM/embedded-4_7-branch revision
196615] (GNU Tools for ARM Embedded Processors)
Command line
arm-none-eabi-gcc -std=c11 -g -Wall -Wextra -Os -flto -ffunction-sections
-fdata-sections -fno-builtin -fomit-frame-pointer -mthumb -mcpu=cortex-m4
-mfpu=fpv4-sp-d16 -mfloat-abi=softfp -DMK60N512VMD100 -D__thumb -I.
-IGenerated_Code -ISources -Istartup
-I..\\..\\vendors\\Freescale\\1.0.0\\Kinetis\\pdd\\inc
-DUNALIGNED_SUPPORT_DISABLE -mno-unaligned-access -c -o obj.gcc/ROMCopy.o
./startup/ROMCopy.c
Produces:
Disassembly of section .text.__copy_rom_sections_to_ram:
<__copy_rom_sections_to_ram>:
0:b510 push{r4, lr}
2:4c0a ldrr4, [pc, #40]; (2c
<__copy_rom_sections_to_ram+0x2c>)
4:b18c cbzr4, 2a <__copy_rom_sections_to_ram+0x2a>
6:3408 addsr4, #8
8:f854 1c08 ldr.wr1, [r4, #-8]
c:b131 cbzr1, 1c <__copy_rom_sections_to_ram+0x1c>
e:f854 0c04 ldr.wr0, [r4, #-4]
12:f854 2b0c ldr.wr2, [r4], #12
16:f7ff fffe bl0 <__copy_rom_sections_to_ram>
1a:e7f5 b.n8 <__copy_rom_sections_to_ram+0x8>
1c:f854 3c04 ldr.wr3, [r4, #-4]
20:2b00 cmpr3, #0
22:d1f4 bne.ne <__copy_rom_sections_to_ram+0xe>
24:6820 ldrr0, [r4, #0]
26:2800 cmpr0, #0
28:d1f1 bne.ne <__copy_rom_sections_to_ram+0xe>
2a:bd10 pop{r4, pc}
2c: .word0x
-8< ---8< ---8< ---8< ---8< ---8< ---8< ---8< --
Compiled with 4.8_2013q4
gcc version 4.8.3 20131129 (release) [ARM/embedded-4_8-branch revision
205641] (GNU Tools for ARM Embedded Processors)
Command line
arm-none-eabi-gcc -std=c11 -g -Wall -Wextra -Os -flto -ffunction-sections
-fdata-sections -fno-builtin -fomit-frame-pointer -mthumb -mcpu=cortex-m4
-mfpu=fpv4-sp-d16 -mfloat-abi=softfp -DMK60N512VMD100 -D__thumb -I.
-IGenerated_Code -ISources -Istartup
-I..\\..\\vendors\\Freescale\\1.0.0\\Kinetis\\pdd\\inc
-DUNALIGNED_SUPPORT_DISABLE -mno-unaligned-access -c -o obj.gcc/ROMCopy.o
./startup/ROMCopy.c
Produces:
<__copy_rom_sections_to_ram>:
0:b508 push{r3, lr}
2:4b07 ldrr3, [pc, #28]; (20
<__copy_rom_sections_to_ram+0x20>)
4:b15b cbzr3, 1e <__copy_rom_sections_to_ram+0x1e>
6:6819 ldrr1, [r3, #0]
8:b119 cbzr1, 12 <__copy_rom_sections_to_ram+0x12>
a:6858 ldrr0, [r3, #4]
c:689a ldrr2, [r3, #8]
e:f7ff fffe bl0 <__copy_rom_sections_to_ram>
12:685a ldrr2, [r3, #4]
14:2a00 cmpr2, #0
16:d1f8 bne.na <__copy_rom_sections_to_ram+0xa>
18:689a ldrr2, [r3, #8]
1a:2a00 cmpr2, #0
1c:d1f5 bne.na <__copy_rom_sections_to_ram+0xa>
1e:bd08 pop{r3, pc}
20: .word0x