From: "Christian Groessler" <cpg@aladdin.de>
To: egcs@egcs.cygnus.com, axp-list@redhat.com
Subject: problem with unaligned access on Alpha
Date: Tue, 22 Jun 1999 11:59:46 +0100 [thread overview]
Message-ID: <41256798.003CACD0.00@saturn.aladdin.de> (raw)
Hello,
while fixing a (intel-) program to work on Alpha, I've encountered
something,
I think it's a compiler bug.
Consider the following example program:
-----------------------
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <errno.h>
#define READ_WORD(a) (*(unsigned short *)(a))
int main(void)
{
char * sepp,* xadr;
int fd;
int i;
unsigned short val;
fd=open("/dev/zero",O_RDWR);
if (fd == -1) {
xxx:
fprintf(stderr,"cannot open : %s\n",strerror(errno));
return(99);
}
sepp = mmap(0,0x10000,PROT_READ|PROT_WRITE,MAP_PRIVATE,fd,0);
if (sepp == -1) goto xxx;
printf("mapped at address %p\n",sepp);
xadr = sepp + 0x7bf;
for (i=0; i< 0x7d0; i++) *(sepp + i) = 0xcc;
printf("OK, now accessing %p....\n",xadr);
val = READ_WORD(xadr);
printf("val read = %04x\n",val);
return(1);
}
-----------------------
I would expect the "val=READ_WORD()" line to generate an unaligned access
exception,
but this doesn't happen. Instead, only one _byte_ at address xadr is read,
resulting
in val=0xcc. Val is 0xcccc on intel machines.
I looked at the generated assembler code (with my little only alpha
assembler knowledge),
and it seems that the compiler is generating code for unaligned access but
somehow
forgets to get the byte at (adress+1).
This was reproduced on RH Linux 5.2 with egcs-1.0.3 and NetBSD 1.4C with
egcs-1.1.2.
Any comments?
regards,
chris
next reply other threads:[~1999-06-22 10:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-22 10:59 Christian Groessler [this message]
1999-06-22 12:32 ` problem with unaligned access on Alpha Stefan Katzenbeisser
-- strict thread matches above, loose matches on Subject: below --
1999-06-23 10:23 Christian Groessler
1999-06-23 14:55 ` Maciej W. Rozycki
1999-06-23 14:56 ` Michal Jaegermann
1999-06-23 16:23 ` Maciej W. Rozycki
1999-06-24 7:02 ` Michal Jaegermann
1999-06-25 20:21 ` Maciej W. Rozycki
1999-06-24 8:29 Christian Groessler
1999-06-24 15:26 ` Michal Jaegermann
1999-06-24 8:54 Christian Groessler
1999-06-29 9:12 Wessels, Hans
1999-06-29 15:07 ` Michal Jaegermann
1999-07-05 17:23 ` Maciej W. Rozycki
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