public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/16691] New: arm-elf-gcc generates wrong-code
@ 2004-07-23 15:01 gcc-bugzilla at gcc dot gnu dot org
2004-07-23 16:12 ` [Bug target/16691] " rearnsha at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-07-23 15:01 UTC (permalink / raw)
To: gcc-bugs
arm-elf-gcc generates wrong-code.
Why it use two 'strb', not one 'strh'?
And why it do 'ldrb'?
Because the 'glob_ptr' is the pointer to external device (16bit only,
volatile), both code could be a problem.
If I removed '__attribute__((__packed__))', gcc generates the code
what I expected.
The gcc (3.4.1, host compiler) and m6811-elf-gcc (3.4.1) generates
same assembly code with or without the '__attribute__((__packed__))'.
$ cat ex.c
struct a {
volatile unsigned short v1;
} __attribute__((__packed__));
extern volatile void *glob_ptr;
void test(void)
{
struct a *ptr = (struct a *) glob_ptr;
ptr->v1 = 0xaa;
}
$ arm-elf-gcc -S -O2 ex.c
$ cat ex.s
.file "ex.c"
.text
.align 2
.global test
.type test, %function
test:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
ldr r3, .L2
ldr r2, [r3, #0]
mvn r3, #85
ldrb r1, [r2, #0] @ zero_extendqisi2
strb r3, [r2, #0]
ldrb r1, [r2, #1] @ zero_extendqisi2
add r3, r3, #86
@ lr needed for prologue
strb r3, [r2, #1]
mov pc, lr
.L3:
.align 2
.L2:
.word glob_ptr
.size test, .-test
.ident "GCC: (GNU) 3.4.2 20040718 (prerelease)"
Environment:
System: Linux namsh 2.6.8-rc2 #91 Mon Jul 19 09:05:11 KST 2004 i686 athlon i386 GNU/Linux
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: arm-unknown-elf
configured with: ../configure --target=arm-elf --prefix=/usr/GNUARM --program-prefix=arm-elf- --with-gnu-ld --with-gnu-as --disable-shared --enable-languages=c,c++ --without-headers --with-newlib --disable-nls
How-To-Repeat:
Just gerates the assembly code using the given ex.c.
------- Additional Comments From namsh at kldp dot org 2004-07-23 15:01 -------
Fix:
Do not use '__attribute__((__packed__))'.
Instead use '#pragma pack...'
--
Summary: arm-elf-gcc generates wrong-code
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: namsh at kldp dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-unknown-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16691
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/16691] arm-elf-gcc generates wrong-code
2004-07-23 15:01 [Bug target/16691] New: arm-elf-gcc generates wrong-code gcc-bugzilla at gcc dot gnu dot org
@ 2004-07-23 16:12 ` rearnsha at gcc dot gnu dot org
2004-07-24 2:35 ` namsh at kldp dot org
2004-07-24 12:50 ` rearnsha at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-07-23 16:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rearnsha at gcc dot gnu dot org 2004-07-23 16:12 -------
Invalid. strh requires an aligned memory location. If the object is unaligned
then two byte accesses are needed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16691
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/16691] arm-elf-gcc generates wrong-code
2004-07-23 15:01 [Bug target/16691] New: arm-elf-gcc generates wrong-code gcc-bugzilla at gcc dot gnu dot org
2004-07-23 16:12 ` [Bug target/16691] " rearnsha at gcc dot gnu dot org
@ 2004-07-24 2:35 ` namsh at kldp dot org
2004-07-24 12:50 ` rearnsha at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: namsh at kldp dot org @ 2004-07-24 2:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From namsh at kldp dot org 2004-07-24 02:35 -------
You mean arm-elf-gcc guesses its not aligned?
Then arm-elf-gcc's guess is wrong. Why it think memory is not aligned?
Actually memory is 2byte aligned. I already print the address.
And the addresses were 0xe0000aaa and 0xe0000554.
If this bug is really invalid, how I can avoid the problem with
__attribute__?
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16691
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/16691] arm-elf-gcc generates wrong-code
2004-07-23 15:01 [Bug target/16691] New: arm-elf-gcc generates wrong-code gcc-bugzilla at gcc dot gnu dot org
2004-07-23 16:12 ` [Bug target/16691] " rearnsha at gcc dot gnu dot org
2004-07-24 2:35 ` namsh at kldp dot org
@ 2004-07-24 12:50 ` rearnsha at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-07-24 12:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rearnsha at gcc dot gnu dot org 2004-07-24 12:50 -------
You wrote 'packed'. Packed means it can be unaligned and the compiler must
treat it as so. If it won't be unaligned, don't put packed on it.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16691
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-07-24 12:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-23 15:01 [Bug target/16691] New: arm-elf-gcc generates wrong-code gcc-bugzilla at gcc dot gnu dot org
2004-07-23 16:12 ` [Bug target/16691] " rearnsha at gcc dot gnu dot org
2004-07-24 2:35 ` namsh at kldp dot org
2004-07-24 12:50 ` rearnsha at gcc dot gnu dot 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).