Subject: Re: why kvm_mkdb is screwed up
To: None <jfw@jfwhome.funhouse.com>
From: Gordon W. Ross <gwr@mc.com>
List: current-users
Date: 01/09/1997 14:31:45
> Date: Thu, 09 Jan 1997 14:16:11 -0500
> From: "John F. Woods" <jfw@jfwhome.funhouse.com>

> OK, I've looked at kvm_mkdb, and I think I understand why it's failing.
> 
> I was going to launch into a long rant about the inadequacies of a.out
> format causing this, but that's not actually true.  (Not, of course,
> that a.out isn't inadequate.)
> 
> Because the MID_I386 ZMAGIC format puts the first page of the text section
> in the first page of the executable file, the text section's first useful
> address is offset by 0x20 from its actual start.  What this means for the
> kernel image is that the symbol _kernel_start equals 0xf8100020 on the 386.
> (Other architectures' mileage may vary, but I'll bet some of them are subject
> to this same problem.)

It sounds to me like the i386 is getting the value of kernel_text wrong.
That value SHOULD come out to whatever you gave the linker, as shown in:
	arch/i386/conf/Makefile.i386
	LINKFLAGS=	-z -Ttext F8100000 -e start

In other words, the exec header is really PART OF the text segment.
If the boot loader did not load it, then it would not be.

> I would suggest changing nlist_aout.c from
> 	kerntextoff = get_kerntext(name);
> to
> 	kerntextoff = get_kerntext(name) & ~(N_PAGSIZ(ebuf) - 1);

The change should be in arch/i386/i386/locore.s:

*** locore.s.~1~	Mon Dec 30 15:20:00 1996
--- locore.s	Thu Jan  9 14:30:24 1997
***************
*** 191,199 ****
  #define	RELOC(x)	((x) - KERNBASE)
  
  	.text
! 	.globl	_C_LABEL(kernel_text)
  	.globl	start
- _C_LABEL(kernel_text):
  start:	movw	$0x1234,0x472			# warm boot
  
  	/*
--- 191,200 ----
  #define	RELOC(x)	((x) - KERNBASE)
  
  	.text
! 	.globl	_kernel_text
! 	.set	_kernel_text,KERNTEXTOFF
! 
  	.globl	start
  start:	movw	$0x1234,0x472			# warm boot
  
  	/*