Subject: Re: i386 stand/lib/loadfile.c on pmax problems
To: Gordon W. Ross <gwr@netbsd.org>
From: Simon Burge <simonb@telstra.com.au>
List: tech-kern
Date: 03/25/1999 14:28:23
"Gordon W. Ross" wrote:

> Teee hee heee...   I wrote that (originally from the sun3).
> 
> The idea was to keep the header whether or not the file format
> of the kernel has the a.out header in the text segment or not,
> and always load it just before "_start".  When loading an old
> OMAGIC or NMAGIC (header not part of text) on the sun3, the
> header ends up at LOADADDR-sizeof(header).  I presume that on
> the pmax an OMAGIC header should end up at: 0x8002ffe0
> 
> Take a look at this file for details: 
> /sys/arch/sun3/stand/libsa/exec_sun.c

Ta.

How does the following look as an MI patch?  And are all i386 kernels
ZMAGIC?

It works OK on the pmax (which is OMAGIC).  However, the initialisation
stack on the pmax is set up immediately below "start".  I guess the
correct thing to do is subtract sizeof(struct aout) from "start" and
initialise the stack to that...

Simon.
--

Index: loadfile.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pmax/stand/lib/loadfile.c,v
retrieving revision 1.1
diff -c -r1.1 loadfile.c
*** loadfile.c	1999/03/24 23:51:26	1.1
--- loadfile.c	1999/03/25 00:19:06
***************
*** 467,477 ****
  	 * The kernel may use this to verify that the
  	 * symbols were loaded by this boot program.
  	 */
! 	if (flags & LOAD_HDR)
! 		BCOPY(x, maxp, sizeof(*x));
! 	if (flags & (LOAD_HDR|COUNT_HDR))
! 		maxp += sizeof(*x);
! 
  
  	/*
  	 * Read in the text segment.
--- 467,482 ----
  	 * The kernel may use this to verify that the
  	 * symbols were loaded by this boot program.
  	 */
! 	if (magic == OMAGIC) {
! 		if (flags & LOAD_HDR)
! 			BCOPY(x, maxp - sizeof(*x), sizeof(*x));
! 	}
! 	else {
! 		if (flags & LOAD_HDR)
! 			BCOPY(x, maxp, sizeof(*x));
! 		if (flags & (LOAD_HDR|COUNT_HDR))
! 			maxp += sizeof(*x);
! 	}
  
  	/*
  	 * Read in the text segment.