From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 6966 invoked from network); 22 Jun 1999 10:53:34 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 22 Jun 1999 10:53:34 -0000 Received: from saturn.aladdin.de (saturn.aladdin.de [194.123.19.3]) by mail.redhat.com (8.8.7/8.8.7) with SMTP id FAA06634 for ; Tue, 22 Jun 1999 05:59:11 -0400 Received: by saturn.aladdin.de(Lotus SMTP MTA v4.6.2 (693.3 8-11-1998)) id 41256798.003CAEA5 ; Tue, 22 Jun 1999 12:02:48 +0100 X-Lotus-FromDomain: AKS From: "Christian Groessler" To: egcs@egcs.cygnus.com, axp-list@redhat.com Message-ID: <41256798.003CACD0.00@saturn.aladdin.de> Date: Tue, 22 Jun 1999 11:59:46 +0100 Subject: problem with unaligned access on Alpha Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Content-Disposition: inline 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 #include #include #include #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