delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2012/04/21/16:44:13

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX1/5MNEzEIn5JI9kgXZN7obzzTHw5p2/cdvf6sYJ3T
Bdp97C1chjGFSg
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
To: djgpp-workers AT delorie DOT com
Subject: Fixing errors in libc when compiling with gcc 4.7.0
Date: Sat, 21 Apr 2012 22:40:41 +0200
User-Agent: KMail/1.9.10
MIME-Version: 1.0
Message-Id: <201204212240.41412.juan.guerrero@gmx.de>
X-Y-GMX-Trusted: 0
Reply-To: djgpp-workers AT delorie DOT com

I have compiled libc sources using gcc 4.7.0 and I found some 
"dereferencing type-punned pointer will break strict-aliasing rules" issues.
See patch below.

Regards,
Juan M. Guerrero




diff -aprNU5 djgpp.orig/src/libc/compat/mntent/mntent.c djgpp/src/libc/compat/mntent/mntent.c
--- djgpp.orig/src/libc/compat/mntent/mntent.c	2011-09-17 01:29:56 +0000
+++ djgpp/src/libc/compat/mntent/mntent.c	2012-04-21 22:06:04 +0000
@@ -1,5 +1,6 @@
+/* Copyright (C) 2012 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
@@ -403,28 +403,39 @@ cdrom_drive_ready(int drive_num)
      I don't see any way out of this mess (anybody?).  Well, at
      least with data disks we don't screw up DOS operations anymore.
 
      Gosh, why is it always so tricky with Microsoft software??  */
 
-  unsigned char request_header[0x14];
+  union
+  {
+    struct 
+    {
+      unsigned int size   :16;
+      unsigned int command:16;
+      unsigned int offset :16;
+      unsigned int segment:16;
+      unsigned int bytes  :16;
+    } buffer_parts;
+    unsigned char buffer[0x14];
+  } request_header;
   int status;
   unsigned dev_status;
 
   /* Construct the request header for the CD-ROM device driver.  */
-  memset(request_header, 0, sizeof request_header);
-  request_header[0] = sizeof request_header;
-  request_header[2] = 3;	/* IOCTL READ command */
-  *(unsigned short *)&request_header[0xe]  = __tb_offset;
-  *(unsigned short *)&request_header[0x10] = __tb_segment;
-  request_header[0x12] = 5;	/* number of bytes to transfer */
+  memset(request_header.buffer, 0, sizeof request_header.buffer);
+  request_header.buffer[0] = sizeof request_header.buffer;
+  request_header.buffer[2] = 3;     /* IOCTL READ command */
+  request_header.buffer_parts.offset  = __tb_offset;
+  request_header.buffer_parts.segment = __tb_segment;
+  request_header.buffer[0x12] = 5;  /* number of bytes to transfer */
 
   /* Put control block into the transfer buffer.  */
   _farpokeb(_dos_ds, __tb, 6);	/* read device status */
   _farpokel(_dos_ds, __tb + 1, 0);	/* zero out the result field */
 
   /* Put request header into the transfer buffer and call the driver.  */
-  dosmemput(request_header, sizeof (request_header), __tb + 5);
+  dosmemput(request_header.buffer, sizeof (request_header.buffer), __tb + 5);
   r.x.ax = 0x1510;
   r.x.cx = drive_num - 1;
   r.x.es = __tb_segment;
   r.x.bx = __tb_offset + 5;
   __dpmi_int(0x2f, &r);
diff -aprNU5 djgpp.orig/src/libc/compat/sys/vfs/statfs.c djgpp/src/libc/compat/sys/vfs/statfs.c
--- djgpp.orig/src/libc/compat/sys/vfs/statfs.c	2012-03-11 14:41:48 +0000
+++ djgpp/src/libc/compat/sys/vfs/statfs.c	2012-04-21 21:48:26 +0000
@@ -35,30 +35,39 @@ use_AX0x1510( int drive_number, long *bl
   regs.x.ax = 0x150b; /* is this drive supported by CD-ROM driver? */
   regs.x.cx = drive_number;
   __dpmi_int(0x2f, &regs);
   if ((regs.x.flags & 1) == 0 && regs.x.bx == 0xadad && regs.x.ax != 0)
   {
-    unsigned char request_header[0x14];
+    union {
+      struct {
+        unsigned int size   :16;
+        unsigned int command:16;
+        unsigned int offset :16;
+        unsigned int segment:16;
+        unsigned int bytes  :16;
+      } buffer_parts;
+      unsigned char buffer[0x14];
+    } request_header;
     int status, i = 2;
 
     /* Construct the request header for the CD-ROM device driver.  */
-    memset (request_header, 0, sizeof request_header);
-    request_header[0] = sizeof request_header;
-    request_header[2] = 3; /* IOCTL READ command */
-    *(unsigned short *)&request_header[0xe]  = __tb_offset;
-    *(unsigned short *)&request_header[0x10] = __tb_segment;
-    request_header[0x12] = 4; /* number of bytes to transfer */
+    memset(request_header.buffer, 0, sizeof request_header.buffer);
+    request_header.buffer[0] = sizeof request_header.buffer;
+    request_header.buffer[2] = 3;     /* IOCTL READ command */
+    request_header.buffer_parts.offset  = __tb_offset;
+    request_header.buffer_parts.segment = __tb_segment;
+    request_header.buffer[0x12] = 4;  /* number of bytes to transfer */
 
     /* When the disk was just changed, we need to try twice.  */
     do {
       /* Put control block into the transfer buffer.  */
       _farpokeb (_dos_ds, __tb, 7); /* read sector size */
       _farpokeb (_dos_ds, __tb + 1, 0); /* cooked mode */
       _farpokew (_dos_ds, __tb + 2, 0); /* zero out the result field */
 
       /* Put request header into the transfer buffer and call the driver.  */
-      dosmemput (request_header, sizeof (request_header), __tb + 4);
+      dosmemput (request_header.buffer, sizeof (request_header.buffer), __tb + 4);
       regs.x.ax = 0x1510;
       regs.x.cx = drive_number;
       regs.x.es = __tb_segment;
       regs.x.bx = __tb_offset + 4;
       __dpmi_int (0x2f, &regs);
@@ -66,17 +75,17 @@ use_AX0x1510( int drive_number, long *bl
       *bsize  = _farpeekw (_dos_ds, __tb + 2);
     } while (--i && (status & 0x800f) == 0x800f); /* disk changed */
 
     if (status == 0x100 && _farpeekw (_dos_ds, __tb + 4 + 0x12) == 4)
     {
-      request_header[0x12] = 5; /* number of bytes to transfer */
+      request_header.buffer[0x12] = 5; /* number of bytes to transfer */
       /* Put control block into the transfer buffer.  */
       _farpokeb (_dos_ds, __tb, 8); /* read volume size */
       _farpokel (_dos_ds, __tb + 1, 0); /* zero out the result field */
 
       /* Put request header into the transfer buffer and call the driver.  */
-      dosmemput (request_header, sizeof (request_header), __tb + 5);
+      dosmemput (request_header.buffer, sizeof (request_header.buffer), __tb + 5);
       regs.x.ax = 0x1510;
       regs.x.cx = drive_number;
       regs.x.es = __tb_segment;
       regs.x.bx = __tb_offset + 5;
       __dpmi_int (0x2f, &regs);

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019