linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: mikpe@csd.uu.se
To: linuxppc-dev@lists.linuxppc.org
Cc: linux-kernel@vger.kernel.org
Subject: gcc-2.95 broken on PPC?
Date: Thu, 10 Apr 2003 14:56:28 +0200 (MEST)	[thread overview]
Message-ID: <200304101256.h3ACuSw3022796@harpo.it.uu.se> (raw)

It seems gcc-2.95, specifically 2.95.4 as included in YDL2.3,
generates incorrect code for recent 2.4 standard kernels on PPC.

Background: Boot floppies made with 2.2 kernels work on my PM4400,
but ones made from recent standard 2.4 kernels fail with a CLAIM error
just after OF has loaded vmlinux.coff. To debug this, I've been slowly
moving forwards from older to newer kernels, making patches at each
point a new kernel version broke vmlinux.coff.

For the latest standard kernel, 2.4.21-pre7, I need three distinct
patches to make vmlinux.coff boot correctly. They are:

1. 2.4.19-pre4 changed arch/ppc/boot/zlib.c in what appears to be a
   reversal to an older version, causing a CLAIM error at the boot
   "clearing .bss" line; my patch reverts that change (but see below)
2. starting with 2.4.20, I get a CLAIM error at the "loading .data"
   line; a well-known patch posted to linuxppc-dev fixed that
   (change arch/ppc/boot/ld.script .data ALIGN(8) to ALIGN(4096))
3. 2.4.21-pre6 changed include/asm-ppc/div64.h to use long long
   arithmetic, again causing a CLAIM error at the "clearing .bss" line;
   my patch reverts that change (but see below)

However, bugs #1 (zlib.c) and #3 (div64.h) disappear if I compile
my kernels with gcc-3.2.2 instead of 2.95.4, which is a strong
indication that 2.95.4 is broken on PPC. Is this something that's
well-known to PPC people?

The patches are included below for reference.

/Mikael

--- linux-2.4.21-pre7/arch/ppc/boot/lib/zlib.c.~1~	Wed Apr  9 10:32:51 2003
+++ linux-2.4.21-pre7/arch/ppc/boot/lib/zlib.c	Wed Apr  9 10:39:41 2003
@@ -925,10 +925,7 @@
       {
         r = t;
         if (r == Z_DATA_ERROR)
-	{
-          ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
           s->mode = BADB;
-	}
         LEAVE
       }
       s->sub.trees.index = 0;
@@ -964,7 +961,6 @@
           if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
               (c == 16 && i < 1))
           {
-            ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
             s->mode = BADB;
             z->msg = "invalid bit length repeat";
             r = Z_DATA_ERROR;
@@ -992,10 +988,7 @@
         if (t != Z_OK)
         {
           if (t == (uInt)Z_DATA_ERROR)
-	  {
-            ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
             s->mode = BADB;
-	  }
           r = t;
           LEAVE
         }
--- linux-2.4.21-pre7/arch/ppc/boot/ld.script.~1~	Sat Nov 30 17:12:23 2002
+++ linux-2.4.21-pre7/arch/ppc/boot/ld.script	Wed Apr  9 10:38:43 2003
@@ -39,7 +39,7 @@
   PROVIDE (etext = .);
 
   /* Read-write section, merged into data segment: */
-  . = ALIGN(8);
+  . = ALIGN(4096);
   .data    :
   {
     *(.data)
--- linux-2.4.21-pre7/include/asm-ppc/div64.h.~1~	Wed Apr  9 10:34:58 2003
+++ linux-2.4.21-pre7/include/asm-ppc/div64.h	Wed Apr  9 10:38:11 2003
@@ -1,23 +1,10 @@
 #ifndef __PPC_DIV64
 #define __PPC_DIV64
 
-#include <linux/types.h>
-
-extern u32 __div64_32(u64 *dividend, u32 div);
-
-#define do_div(n, div)	({			\
-	u64 __n = (n);				\
-	u32 __d = (div);			\
-	u32 __q, __r;				\
-	if ((__n >> 32) == 0) {			\
-		__q = (u32)__n / __d;		\
-		__r = (u32)__n - __q * __d;	\
-		(n) = __q;			\
-	} else {				\
-		__r = __div64_32(&__n, __d);	\
-		(n) = __n;			\
-	}					\
-	__r;					\
-})
+#define do_div(n,base) ({ \
+int __res; \
+__res = ((unsigned long) n) % (unsigned) base; \
+n = ((unsigned long) n) / (unsigned) base; \
+__res; })
 
 #endif

             reply	other threads:[~2003-04-10 12:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-10 12:56 mikpe [this message]
2003-04-10 14:20 ` gcc-2.95 broken on PPC? Benjamin Herrenschmidt
2003-04-10 14:42 ` Wolfgang Denk
2003-04-10 17:52 Dan Kegel
2003-04-10 17:50 ` Daniel Jacobowitz
2003-04-10 21:20 ` Wolfgang Denk
2003-04-10 21:32 ` Jörn Engel
2003-04-11 15:01 mikpe
2003-04-12 15:36 Dan Kegel
2003-04-12 19:12 ` Peter Barada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200304101256.h3ACuSw3022796@harpo.it.uu.se \
    --to=mikpe@csd.uu.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.linuxppc.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).