Subject: port-sparc/12548: sparc boot.net needs real a.out header for OpenFirmware machines.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <uwe@ptc.spbu.ru>
List: netbsd-bugs
Date: 04/04/2001 08:51:17
>Number:         12548
>Category:       port-sparc
>Synopsis:       sparc boot.net needs real a.out header for OpenFirmware machines.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-sparc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 04 08:52:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Valeriy Ushakov
>Release:        1.5
>Organization:
>Environment:
JavaStation-1 with OpenBoot v3, i.e. OpenFirmware.
Banner of mine says OpenBoot 3.11.2.

>Description:
OpenFirmware is picky about the a.out header of the program it loads,
boot.net in this case.  In stand/boot we conjure up a magic header but
OFW cannot start the image with this header, since the second word of
the conjured header is interpreted as ridiculously large text segment
size.

We need to provide real a.out header with correct sizes for text, data
and bss segments for OFW to correctly start the boot.net.

>How-To-Repeat:
Setup DHCP for JS1, arrange it to boot NetBSD boot.net.
Force JS1 to enter POST on serial console by shortening J0904 1-2 jumper.
Get to the 'ok' prompt.  Type: load load-base 4 + +bp go - this should
give you a breakpoint upon entering the loaded boot.net.
It fails with Data Access Exception.

You must(!) verify this with break point, as boot.net has other
problems that will cause it to fail with Data Access Exception
even if it started correctly.
>Fix:
I saved ELF boot.*.tmp and used elftoaout(1) to convert it to a.out.
This converted image correctly loads and starts.  For the example above
it will correctly stop on breakpoint at the second instruction.
elftoaout(1) folds .rodata and .data section into text, so I guess
it's not important to split hairs as to which elf section goes into
which a.out segment.

Unfortunately elftoaout(1) is a third-party tool.
Our objcopy(1) supports a.out but it cannot cope with .rodata section.
I guess we can construct the a.out header using numbers reported
by size(1), but I haven't tried it.
>Release-Note:
>Audit-Trail:
>Unformatted: