public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/60084] New: GCC 4.8.3 miscompiles code on ARM at -Os optimization level
@ 2014-02-05 18:45 florin.iucha@hill-rom.com
2014-02-05 18:46 ` [Bug c/60084] " florin.iucha@hill-rom.com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: florin.iucha@hill-rom.com @ 2014-02-05 18:45 UTC (permalink / raw)
To: gcc-bugs
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.iucha@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)
{
int index;
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:
00000000 <__copy_rom_sections_to_ram>:
0: b510 push {r4, lr}
2: 4c0a ldr r4, [pc, #40] ; (2c
<__copy_rom_sections_to_ram+0x2c>)
4: b18c cbz r4, 2a <__copy_rom_sections_to_ram+0x2a>
6: 3408 adds r4, #8
8: f854 1c08 ldr.w r1, [r4, #-8]
c: b131 cbz r1, 1c <__copy_rom_sections_to_ram+0x1c>
e: f854 0c04 ldr.w r0, [r4, #-4]
12: f854 2b0c ldr.w r2, [r4], #12
16: f7ff fffe bl 0 <__copy_rom_sections_to_ram>
1a: e7f5 b.n 8 <__copy_rom_sections_to_ram+0x8>
1c: f854 3c04 ldr.w r3, [r4, #-4]
20: 2b00 cmp r3, #0
22: d1f4 bne.n e <__copy_rom_sections_to_ram+0xe>
24: 6820 ldr r0, [r4, #0]
26: 2800 cmp r0, #0
28: d1f1 bne.n e <__copy_rom_sections_to_ram+0xe>
2a: bd10 pop {r4, pc}
2c: 00000000 .word 0x00000000
-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:
00000000 <__copy_rom_sections_to_ram>:
0: b508 push {r3, lr}
2: 4b07 ldr r3, [pc, #28] ; (20
<__copy_rom_sections_to_ram+0x20>)
4: b15b cbz r3, 1e <__copy_rom_sections_to_ram+0x1e>
6: 6819 ldr r1, [r3, #0]
8: b119 cbz r1, 12 <__copy_rom_sections_to_ram+0x12>
a: 6858 ldr r0, [r3, #4]
c: 689a ldr r2, [r3, #8]
e: f7ff fffe bl 0 <__copy_rom_sections_to_ram>
12: 685a ldr r2, [r3, #4]
14: 2a00 cmp r2, #0
16: d1f8 bne.n a <__copy_rom_sections_to_ram+0xa>
18: 689a ldr r2, [r3, #8]
1a: 2a00 cmp r2, #0
1c: d1f5 bne.n a <__copy_rom_sections_to_ram+0xa>
1e: bd08 pop {r3, pc}
20: 00000000 .word 0x00000000
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/60084] GCC 4.8.3 miscompiles code on ARM at -Os optimization level
2014-02-05 18:45 [Bug c/60084] New: GCC 4.8.3 miscompiles code on ARM at -Os optimization level florin.iucha@hill-rom.com
@ 2014-02-05 18:46 ` florin.iucha@hill-rom.com
2014-02-05 18:46 ` florin.iucha@hill-rom.com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: florin.iucha@hill-rom.com @ 2014-02-05 18:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60084
--- Comment #2 from Florin Iucha <florin.iucha@hill-rom.com> ---
Created attachment 32058
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32058&action=edit
objdump of binary built with gcc-4.8.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/60084] GCC 4.8.3 miscompiles code on ARM at -Os optimization level
2014-02-05 18:45 [Bug c/60084] New: GCC 4.8.3 miscompiles code on ARM at -Os optimization level florin.iucha@hill-rom.com
2014-02-05 18:46 ` [Bug c/60084] " florin.iucha@hill-rom.com
@ 2014-02-05 18:46 ` florin.iucha@hill-rom.com
2014-02-05 19:07 ` [Bug target/60084] " florin.iucha@hill-rom.com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: florin.iucha@hill-rom.com @ 2014-02-05 18:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60084
--- Comment #1 from Florin Iucha <florin.iucha@hill-rom.com> ---
Created attachment 32057
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32057&action=edit
objdump of binary built with gcc-4.7.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/60084] GCC 4.8.3 miscompiles code on ARM at -Os optimization level
2014-02-05 18:45 [Bug c/60084] New: GCC 4.8.3 miscompiles code on ARM at -Os optimization level florin.iucha@hill-rom.com
2014-02-05 18:46 ` [Bug c/60084] " florin.iucha@hill-rom.com
2014-02-05 18:46 ` florin.iucha@hill-rom.com
@ 2014-02-05 19:07 ` florin.iucha@hill-rom.com
2014-02-05 19:09 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: florin.iucha@hill-rom.com @ 2014-02-05 19:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60084
--- Comment #3 from Florin Iucha <florin.iucha@hill-rom.com> ---
gcc version 4.7.4 20130913 (release) [ARM/embedded-4_7-branch revision 202601]
(GNU Tools for ARM Embedded Processors) generates the same code as 4.7.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/60084] GCC 4.8.3 miscompiles code on ARM at -Os optimization level
2014-02-05 18:45 [Bug c/60084] New: GCC 4.8.3 miscompiles code on ARM at -Os optimization level florin.iucha@hill-rom.com
` (2 preceding siblings ...)
2014-02-05 19:07 ` [Bug target/60084] " florin.iucha@hill-rom.com
@ 2014-02-05 19:09 ` pinskia at gcc dot gnu.org
2014-02-05 19:15 ` florin.iucha@hill-rom.com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-02-05 19:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60084
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Do you have the preprocessed source?
>Using GCC built by Linaro.
Also you should be reporting this bug to them as they are the ones who modified
the source.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/60084] GCC 4.8.3 miscompiles code on ARM at -Os optimization level
2014-02-05 18:45 [Bug c/60084] New: GCC 4.8.3 miscompiles code on ARM at -Os optimization level florin.iucha@hill-rom.com
` (3 preceding siblings ...)
2014-02-05 19:09 ` pinskia at gcc dot gnu.org
@ 2014-02-05 19:15 ` florin.iucha@hill-rom.com
2014-02-05 19:17 ` florin.iucha@hill-rom.com
2014-02-05 19:22 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: florin.iucha@hill-rom.com @ 2014-02-05 19:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60084
--- Comment #5 from Florin Iucha <florin.iucha@hill-rom.com> ---
Created attachment 32059
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32059&action=edit
Preprocessed source file (both 4.7.4 and 4.8.3 produce the same .i file)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/60084] GCC 4.8.3 miscompiles code on ARM at -Os optimization level
2014-02-05 18:45 [Bug c/60084] New: GCC 4.8.3 miscompiles code on ARM at -Os optimization level florin.iucha@hill-rom.com
` (4 preceding siblings ...)
2014-02-05 19:15 ` florin.iucha@hill-rom.com
@ 2014-02-05 19:17 ` florin.iucha@hill-rom.com
2014-02-05 19:22 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: florin.iucha@hill-rom.com @ 2014-02-05 19:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60084
--- Comment #6 from Florin Iucha <florin.iucha@hill-rom.com> ---
Andrew,
Is that a general comment regarding Linaro GCC build, or do you have more
specific information about some of their changes that might have an impact on
compiling the source code I am referencing in this bug report?
Thanks,
florin
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/60084] GCC 4.8.3 miscompiles code on ARM at -Os optimization level
2014-02-05 18:45 [Bug c/60084] New: GCC 4.8.3 miscompiles code on ARM at -Os optimization level florin.iucha@hill-rom.com
` (5 preceding siblings ...)
2014-02-05 19:17 ` florin.iucha@hill-rom.com
@ 2014-02-05 19:22 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-02-05 19:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60084
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I get the following warning:
./startup/ROMCopy.c:15:9: warning: array ‘__S_romp’ assumed to have one element
[enabled by default]
So the code is invalid and undefined. Writing past the bounds of an array is
undefined.
If I add extern to the definition of RomInfo, I get the correct behavior.
>From gcc-bugs-return-442742-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Feb 05 19:33:47 2014
Return-Path: <gcc-bugs-return-442742-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 14194 invoked by alias); 5 Feb 2014 19:33:46 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 14164 invoked by uid 48); 5 Feb 2014 19:33:42 -0000
From: "florin.iucha@hill-rom.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/60084] GCC 4.8.3 miscompiles code on ARM at -Os optimization level
Date: Wed, 05 Feb 2014 19:33:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.8.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: florin.iucha@hill-rom.com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-60084-4-ZeTRkVRWX1@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60084-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60084-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg00499.txt.bz2
Content-length: 240
http://gcc.gnu.org/bugzilla/show_bug.cgi?id`084
--- Comment #8 from Florin Iucha <florin.iucha@hill-rom.com> ---
Andrew,
You are correct! Sorry, I have missed the lack of 'extern'. I noticed the
warning, but did not heed it ;(
florin
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-02-05 19:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-05 18:45 [Bug c/60084] New: GCC 4.8.3 miscompiles code on ARM at -Os optimization level florin.iucha@hill-rom.com
2014-02-05 18:46 ` [Bug c/60084] " florin.iucha@hill-rom.com
2014-02-05 18:46 ` florin.iucha@hill-rom.com
2014-02-05 19:07 ` [Bug target/60084] " florin.iucha@hill-rom.com
2014-02-05 19:09 ` pinskia at gcc dot gnu.org
2014-02-05 19:15 ` florin.iucha@hill-rom.com
2014-02-05 19:17 ` florin.iucha@hill-rom.com
2014-02-05 19:22 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).