Skip to contentSkip to conversation

Tools miss-compile old kernel

DISCUSSION Brady Brown 3 participants 3 messages Mar 22, 2001 – Mar 28, 2001 MIPS

lore
Share & tools
lore
#0 lore raw

I recently upgraded to a newer Cross-compiler tool chain to try to get up to glibc2.2. I'm now at gcc-2.95.3-14 and binutils-2.10.91-2 (both from Maciej's site). I have built 2.4.0-test9 with this tool-chain, but is will not boot. It spews illegal instruction errors when init is launched.

Is this supposed to work, or are the new tools incompatible with older kernels?

I dumped out the disassembly of a newly compiled kernel and found some bad instructions in many of the routines. First one is from head.S

SNIP>> of bad disassembly
0000000080100280 <except_vec0_r4000>:
except_vec0_r4000():

    80100280:     401a4000      mfc0         $k0,$8
    80100284:     001ad582      srl             $k0,$k0,0x16
    80100288:     3c1b0000      lui             $k1,0x0
    8010028c:     677b0001      0x677b0001
    80100290:     001bdc38      0x1bdc38
    80100294:     677b8023      0x677b8023
    80100298:     001bdc38      0x1bdc38
    8010029c:     8f7bb250      lw                 $k1,-19888($k1)
    801002a0:     001ad080      sll                $k0,$k0,0x2
    801002a4:     037ad821      addu            $k1,$k1,$k0
    801002a8:     401a2000      mfc0           $k0,$4
    801002ac:     8f7b0000      lw                 $k1,0($k1)
    801002b0:     001ad042      srl                $k0,$k0,0x1
    801002b4:     335a0ff8      andi              $k0,$k0,0xff8
    801002b8:     037ad821      addu            $k1,$k1,$k0
    801002bc:     8f7a0000      lw                  $k0,0($k1)
    801002c0:     8f7b0004      lw                  $k1,4($k1)
    801002c4:     001ad182      srl                 $k0,$k0,0x6
    801002c8:     409a1000      mtc0            $k0,$2
    801002cc:     001bd982      srl                 $k1,$k1,0x6
    801002d0:     409b1800      mtc0            $k1,$3
    801002d4:     10000001      b                    ffffffff801002dc
<except_vec0_r4000+0x5c>
    801002d8:     42000006      tlbwr
    801002dc:     00000000      nop
    801002e0:     42000018      c0 0x18

<<SNIP

Quoted 1 line
Quoted 1 line

SNIP of good assembly from old tools

0000000080100280 <except_vec0_r4000>:
except_vec0_r4000():

    80100280:     401a4000     mfc0         $k0,$8
    80100284:     001ad582     srl              $k0,$k0,0x16
    80100288:     3c1b8023     lui              $k1,0x8023
    8010028c:     8f7bd210      lw               $k1,-11760($k1)
    80100290:     001ad080     sll               $k0,$k0,0x2
    80100294:     037ad821     addu          $k1,$k1,$k0
    80100298:     401a2000     mfc0         $k0,$4
    8010029c:     8f7b0000      lw                $k1,0($k1)
    801002a0:     001ad042     srl             $k0,$k0,0x1
    801002a4:     335a0ff8      andi           $k0,$k0,0xff8
    801002a8:     037ad821     addu         $k1,$k1,$k0
    801002ac:     8f7a0000      lw             $k0,0($k1)
    801002b0:     8f7b0004      lw             $k1,4($k1)
    801002b4:     001ad182      srl             $k0,$k0,0x6
    801002b8:     409a1000      mtc0         $k0,$2
    801002bc:     001bd982      srl             $k1,$k1,0x6
    801002c0:     409b1800      mtc0         $k1,$3
    801002c4:     10000001      b 801002cc <except_vec0_r4000+4c>
    801002c8:     42000006      tlbwr
    801002cc:     00000000      nop
    801002d0:     42000018      eret

<<SNIP

Looks like here the tools blow the lui/lw combination and also the eret. Any suggestions?

#1 lore raw
Quoted 2 lines · Brady Brown

Is this supposed to work, or are the new tools incompatible with older kernels?

That particular assembler is incompatible with sanity, older kernels, newer kernels, and anything you expect to actually function properly.

Quoted 2 lines

Looks like here the tools blow the lui/lw combination and also the eret. Any suggestions?

Upgrade to CVS binutils. The one Maciej has on his site is apparently broken. If you want a toolchain that is known to work at least in some cases, you can pull it from ftp://oss.sgi.com/pub/linux/mips/mips-linux/simple/crossdev/. That is the toolchain I use to build kernels -and- userland (yes, I know, everyone says it can't be done, but...) and thus it Works For Me (TM).

Signature · 3 lines
Keith M Wesolowski <[email protected]> http://foobazco.org/~wesolows
------(( Project Foobazco Coordinator and Network Administrator ))------
"I should have crushed his marketing-addled skull with a fucking bat."
#2 lore raw
Quoted 6 lines · Keith M Wesolowski

Upgrade to CVS binutils. The one Maciej has on his site is apparently broken. If you want a toolchain that is known to work at least in some cases, you can pull it from ftp://oss.sgi.com/pub/linux/mips/mips-linux/simple/crossdev/. That is the toolchain I use to build kernels -and- userland (yes, I know, everyone says it can't be done, but...) and thus it Works For Me (TM).

Weird, I've always used tools I packaged for both kernel and userland
builds and I had no troubles. The latest 2.10.91 version available at my site should be fine. I've only tested it with an R3k, though.

I'm actually going to upgrade it to 2.11 ASAP, but I won't do it until I
track down a weird kernel bug which is reproducibly triggered by a native mipsel-linux build -- the kernel crashes completely and silently after sed is invoked in a specific place upon running the libtool script in the ld directory. I suspect a corruption bug as the crash disappears if the script is modified a bit (e.g. some white space is added), so I'm actually glad I got bitten by the bug.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +