[OpenBIOS] [PATCH] a.out header copy

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Fri Feb 7 19:24:08 CET 2014

On 05/02/14 22:51, Olivier Danet wrote:

> Here is the beginning of the NextSTEP bootloader :
> Dump of assembler code from 0x4000 to 0x4100:
> => 0x00004000: tst %o0
> 0x00004004: be 0x404c
> 0x00004008: nop
> 0x0000400c: mov %o0, %g7
> 0x00004010: sethi %hi(0x4000), %o1
> 0x00004014: mov %o1, %o1 ! 0x4000
> 0x00004018: sub %o1, 0x1c, %o2
> 0x0000401c: ld [ %o2 ], %o2 <<<<<<< HERE : $O2=*(0x4000-0x1C)
> 0x00004020: add %o2, %o1, %o2
> 0x00004024: sethi %hi(0x5800), %g1
> 0x00004028: st %g7, [ %g1 + 0x110 ] ! 0x5910
> 0x0000402c: ld [ %o0 + 4 ], %o4
> 0x00004030: mov %o1, %l0
> 0x00004034: add %o1, 0x20, %l1
> 0x00004038: call 0x4088
> 0x0000403c: sub %o2, %o1, %l2
> 0x00004040: tst %o4
> 0x00004044: be 0x404c
> 0x00004048: nop
> 0x0000404c: save %o1, -96, %sp
> 0x00004050: call 0x432c
> Addresses are absolute. This code is directly copied from the ISO's
> sector 1
> It accesses the a.out header very early (which helped _a lot_
> to find the bug) to get the a_text field, which is the lenght of the
> TEXT segment.
> Sun's OpenBOOT copies the whole header at 0x3FE0, not the .a_text only.
> Are there SunOS version using a.out ?
> Of course, we could add #ifdef CONFIG_SPARC32 fences.

Hi Olivier,

Thanks for this. Checking the source here I see that only SPARC32 and 
SPARC64 define CONFIG_LOADER_AOUT, so it's a fairly limited audience.

I wonder if we need to control whether things are non-compliant or not 
through the CONFIG_QEMU switch?

Regardless, for this case I think just add a #define at the top of the 
file that controls whether or not to load the header beneath load-base. 
As a minor nit, would it be possible to rework the patch so that it 
optionally loads the header first before the payload? At the moment, it 
loads the payload and then seeks back to read in the header which seems 
slightly counter-intuitive.



More information about the OpenBIOS mailing list