Subject: Re: mips-ecoff deprecation
To: Jonathan Stone <jonathan@dsg.stanford.edu>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-toolchain
Date: 03/01/2005 13:37:48
On Tue, Feb 22, 2005 at 12:59:06PM -0800, Jonathan Stone wrote:

> In message <0e7f751fd4116f4773fc74b5379b73af@shagadelic.org>,
> Jason Thorpe writes:
> 
> >On Feb 21, 2005, at 5:01 PM, Eric Christopher wrote:
> >
> >> Thinking about deprecating the mips-ecoff target out of binutils. Not
> >> many people (incl. me) have been paying attention to it and I'd be
> >> surprised if it worked much at all. I believe the only question is
> >> whether or not you guys use it for anything. From talking to Matt you
> >> seem to have your own stuff for the boot loader, but I wanted to make
> >> sure it wasn't being used anywhere else.
> >
> >We have "our own thing" for the pmax boot loader.  But ARC systems 
> >still require ECOFF, and we use regular objcopy for that.
> 
> Hi  Eric,
> 
> ECOFF is a tricky animal when it comes to booting.

No argument there!

> [ ... ]
>
> If NetBSD is truly the only remaining users of binutils mips-ecoff,
> then I guess we should contemplate switching to our own
> ELF-to-ECOFF-loader converters?  Are you saying that's where we should
> be heading, or more that we should start thinking about it ASAP?

I would be quite happy to do away with our elf2ecoff and just use
binutils objcopy if it worked.

Using a kernel built with elf2ecoff:

  -tftp boot(3), bootp 192.168.0.42:mona.root/netbsd
  -tftp load 2948240+0+289708
  segment  0 start 00000000 size 18800000
  segment  1 start 1a000000 size 00800000
  Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
      The NetBSD Foundation, Inc.  All rights reserved.
      ...

objdump -h of this working kernel is:

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         002cfc90  0000000080030000  0000000080030000  00000140  2**4
                  CONTENTS, ALLOC, LOAD
  1 .data         00000000  00000000802ffc90  00000000802ffc90  002cfdd0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .bss          00046bac  00000000802ffc90  00000000802ffc90  00000000  2**4
                  ALLOC, LOAD
  3               00000000  0000000000000000  0000000000000000  00000000  2**4
                  ALLOC, LOAD, DATA
  4               00000000  0000000000000000  0000000000000000  00000000  2**4
                  ALLOC
  5               00000000  0000000000000000  0000000000000000  00000000  2**4


With just "mipsel--netbsd-objcopy -O ecoff-littlemips netbsd
netbsd.ecoff":

  -tftp boot(3), bootp 192.168.0.42:mona.root/netbsd 
  -tftp load 
  ?IO: 3/tftp, a.out (-6)
  >>

Here the kernel just fails to load.  We return to the PROM prompt very
quickly.  objdump -h of this kernel is:

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         002891b0  0000000080030000  0000000080030000  00001000  2**4
                  CONTENTS, ALLOC, LOAD, CODE
  1 .rodata       00039450  00000000802b91b0  00000000802b91b0  0028a1b0  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  2 link_set      00000018  00000000802f2600  00000000802f2600  002c3600  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  3 link_set      0000013c  00000000802f2618  00000000802f2618  002c3618  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  4 link_set      000000b0  00000000802f2754  00000000802f2754  002c3754  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  5 link_set      00000124  00000000802f2804  00000000802f2804  002c3804  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  6 link_set      00000004  00000000802f2928  00000000802f2928  002c3928  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  7 link_set      0000000c  00000000802f292c  00000000802f292c  002c392c  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  8 link_set      00000030  00000000802f2938  00000000802f2938  002c3938  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  9 .reginfo      00000018  00000000802f2968  00000000802f2968  002c3968  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 10 .data         0000d300  00000000802f2980  00000000802f2980  002c3980  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 11 .sdata        00000010  00000000802ffc80  00000000802ffc80  002d0c80  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 12 .bss          00046bb0  00000000802ffc90  00000000802ffc90  00000000  2**4
                  ALLOC
 13 .pdr          00033640  0000000000000000  0000000000000000  002d1000  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 14 .mdebug.      00000000  0000000000000000  0000000000000000  00304640  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 15 .comment      00005668  0000000000000000  0000000000000000  00304640  2**4
                  CONTENTS, NEVER_LOAD
 16 .ident        000079b2  0000000000000000  0000000000000000  00309ca8  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

With "mipsel--netbsd-objcopy --impure -O ecoff-littlemips -R .pdr -R
.mdebug.abi32 -R .comment -R .ident netbsd netbsd.ecoff" (as used by
sgimips right now):

  -tftp boot(3), bootp 192.168.0.42:mona.root/netbsd
  -tftp load 2658736+289504+289712

  KN05 V2.1k    (PC: 0xa002cab8, SP: 0x8002ff98)
  >> 

Here like the kernel loaded ok, but it looks like when the prom
transferred control to the kernel something bad happened and we got
something like a reset.  The "KN05 ..." message is the same as what
happens when you press the reset button.  objdump -h of this kernel
is:

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         002891b0  0000000080030000  0000000080030000  00000260  2**4
                  CONTENTS, ALLOC, LOAD, CODE
  1 .rodata       00039450  00000000802b91b0  00000000802b91b0  00289410  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  2 link_set      00000018  00000000802f2600  00000000802f2600  002c2860  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  3 link_set      0000013c  00000000802f2618  00000000802f2618  002c2878  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  4 link_set      000000b0  00000000802f2754  00000000802f2754  002c29b4  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  5 link_set      00000124  00000000802f2804  00000000802f2804  002c2a64  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  6 link_set      00000004  00000000802f2928  00000000802f2928  002c2b88  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  7 link_set      0000000c  00000000802f292c  00000000802f292c  002c2b8c  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  8 link_set      00000030  00000000802f2938  00000000802f2938  002c2b98  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  9 .reginfo      00000018  00000000802f2968  00000000802f2968  002c2bc8  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 10 .data         0000d300  00000000802f2980  00000000802f2980  002c2be0  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 11 .sdata        00000010  00000000802ffc80  00000000802ffc80  002cfee0  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 12 .bss          00046bb0  00000000802ffc90  00000000802ffc90  00000000  2**4
                  ALLOC

Here's the section from the original ELF kernel:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         002891b0  80030000  80030000  00010000  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .rodata       00039450  802b91b0  802b91b0  002991b0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 link_set_domains 00000018  802f2600  802f2600  002d2600  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 link_set_pools 0000013c  802f2618  802f2618  002d2618  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 link_set_sysctl_funcs 000000b0  802f2754  802f2754  002d2754  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 link_set_malloc_types 00000124  802f2804  802f2804  002d2804  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 link_set_dkwedge_methods 00000004  802f2928  802f2928  002d2928  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 link_set_bufq_strats 0000000c  802f292c  802f292c  002d292c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 link_set_evcnts 00000030  802f2938  802f2938  002d2938  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .reginfo      00000018  802f2968  802f2968  002d2968  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA, LINK_ONCE_SAME_SIZE
 10 .data         0000d300  802f2980  802f2980  002d2980  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 11 .sdata        00000010  802ffc80  802ffc80  002dfc80  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 12 .bss          00046bac  802ffc90  802ffc90  002dfc90  2**4
                  ALLOC
 13 .pdr          00033640  00000000  00000000  002dfc90  2**2
                  CONTENTS, READONLY
 14 .mdebug.abi32 00000000  00000000  00000000  003132d0  2**0
                  CONTENTS, READONLY
 15 .comment      00005668  00000000  00000000  003132d0  2**0
                  CONTENTS, READONLY
 16 .ident        000079b2  00000000  00000000  00318938  2**0
                  CONTENTS, READONLY

For reference, here's the last Ultrix kernel I regularly used:

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         000fc770  0000000080030000  0000000080030000  00000170  2**4
                  CONTENTS, ALLOC, LOAD, CODE
  1 .rdata        00001bb0  000000008012c770  000000008012c770  000fc8e0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .data         0001b930  000000008012e320  000000008012e320  000fe490  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  3 .sdata        00002720  0000000080149c50  0000000080149c50  00119dc0  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  4 .sbss         00000c90  000000008014c370  000000008014c370  00000000  2**4
                  ALLOC
  5 .bss          0005bdb0  000000008014d000  000000008014d000  00000000  2**4
                  ALLOC
  6 .comment      00000024  0000000000000000  0000000000000000  0011c540  2**4
                  CONTENTS, NEVER_LOAD

From the objcopy'd kernel that loads but doesn't run, we see:

  -tftp load 2658736+289504+289712

2658736 bytes takes us up to the end of .text (2658736 + 0x30000 =
20x2b91b0).

289504 bytes is the sum of .rodata, the link sets, .reginfo, 2.data and
.sdata.

289712 bytes is just 4 bytes more than .bss.

So at least all the sections we want to get loaded appear to be loaded,
but I'm not sure why it doesn't work from there.  I can load the kernel
with the firmware and not run it, but I haven't sifted through there yet
to see if I can see anything wrong.

Enough rambling on for now...

Simon.
--
Simon Burge                                   <simonb@wasabisystems.com>
NetBSD Development, Support and Service:   http://www.wasabisystems.com/