From: David Addison <addy@quadrics.com>
To: "'axp-list@redhat.com'" <axp-list@redhat.com>
Subject: Weird Compaq CCC / GCC interaction ?
Date: Tue, 26 Sep 2000 09:55:12 +0100 [thread overview]
Message-ID: <010C86D15E4D1247B9A5DD312B7F5AA70BEC27@stegosaurus.bristol.quadrics.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2171 bytes --]
Help! Am I going mad or is there something obviously wrong with my C
programming skills?
Here are two very simple files to compile. What I have found is that if I
compile the fn.c code using gcc and ccc for the main code, it gets the wrong
answer. Whereas it works if I use either ccc or gcc for both. It also works
if I compile the fn.c code with ccc and main with gcc.
Anyone know what's wrong ... is this a bug with ccc or gcc ?
cat fn.c
unsigned int fn()
{
return (0xc00fc00f);
}
cat madness.c
extern unsigned int fn();
#define MAGIC 0xc00fc00f
int main()
{
unsigned int baseAddr;
baseAddr = fn();
if (baseAddr == MAGIC)
printf("GOOD baseAddr %x == %x\n", baseAddr, MAGIC);
else
printf("BADNESS baseAddr %x != %x\n", baseAddr, MAGIC);
}
Then compile as follows;
cc -O3 -c fn.c -o fn_gcc.o
ccc -O3 -c fn.c -o fn_ccc.o
ccc -O3 madness.c -o madness_gcc fn_gcc.o
ccc -O3 madness.c -o madness_ccc fn_ccc.o
Then run;
./madness_ccc
GOOD baseAddr c00fc00f == c00fc00f
./madness_gcc
BADNESS baseAddr c00fc00f != c00fc00f
It starts working if I change the MAGIC constant to 0x400fc00f so that
suggests sign problems ?
Disassembling the fn code we see the only differences ...
objdump -d fn_gcc.o
fn_gcc.o: file format elf64-alpha
Disassembly of section .text:
0000000000000000 <fn>:
0: 0f c0 1f 20 lda v0,-16369(zero)
4: 10 c0 00 24 ldah v0,-16368(v0)
8: 20 f6 01 48 zapnot v0,0xf,v0
c: 01 80 fa 6b ret zero,(ra),0x1
...
objdump -d fn_ccc.o
fn_ccc.o: file format elf64-alpha
Disassembly of section .text:
0000000000000000 <fn>:
0: 10 c0 1f 24 ldah v0,-16368(zero)
4: 1f 04 ff 47 nop
8: 0f c0 00 20 lda v0,-16369(v0)
c: 01 80 fa 6b ret zero,(ra),0x1
GCC is inserting a ZAPNOT instruction to zero the top 4-bytes - is this
correct ?
Or is the main code compilation that is broken, I notice that ccc uses 'xor'
to do the compare whereas gcc uses 'cmpeq' ?
For the record, I am using Alpha RH6.1 with ccc (ccc-6.2.9.504-2) and gcc
(egcs-2.91.66)
Cheers,
Addy.
[-- Attachment #2: Type: text/html, Size: 8059 bytes --]
next reply other threads:[~2000-09-26 8:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-09-26 8:55 David Addison [this message]
2000-09-26 9:41 ` Weird Compaq CCC / GCC interaction ? Andrei A. Dergatchev
2000-09-26 10:12 ` Nikita Schmidt
2000-09-26 16:02 ` Michal Jaegermann
2000-09-26 12:23 ` Ivan Kokshaysky
2000-09-26 13:57 ` Ivan Kokshaysky
-- strict thread matches above, loose matches on Subject: below --
2000-09-26 13:59 David Addison
2000-09-26 15:36 ` Ivan Kokshaysky
2000-09-26 17:25 Larry Sendlosky
2000-09-26 18:01 ` Michal Jaegermann
2000-09-27 3:17 ` Richard Henderson
2000-09-26 17:47 David Addison
2000-09-26 18:52 Larry Sendlosky
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox