Subject: bin/2665: kvm_mkdb may not upgrade /var/db/kvm_netbsd.db on some archs
To: None <leo@dachau.marco.de>
From: Gordon W. Ross <gwr@mc.com>
List: netbsd-bugs
Date: 07/31/1996 12:28:16
> Date: Wed, 31 Jul 96 14:43 MET DST
> From: leo@marco.de

> >Number:         2665
> >Category:       bin
> >Synopsis:       kvm_mkdb may not upgrade /var/db/kvm_netbsd.db on some archs
> >Confidential:   no
> >Severity:       serious
> >Priority:       medium
> >Responsible:    bin-bug-people (Utility Bug People)
> >State:          open
> >Class:          sw-bug
> >Submitter-Id:   net
> >Arrival-Date:   Wed Jul 31 09:05:01 1996
> >Last-Modified:
> >Originator:     Matthias Pfaller
> >Organization:
> leo@dachau.marco.de			in real life: Matthias Pfaller
> marco GmbH, 85221 Dachau, Germany	tel: +49 8131 516142
> >Release:        1.2_BETA
> >Environment:
> 	
> System: NetBSD klondike 1.2_BETA NetBSD 1.2_BETA (KLONDIKE) #62: Sat Jul 20 01:29:59 MET DST 1996 leo@klondike:/usr/src/sys/arch/pc532/compile/KLONDIKE pc532
> 
> 
> >Description:
> 	The code in src/usr.sbin/kvm_mkdb/nlist.c tries to find the
> 	offset of the version[] array in the kernel binary. It
> 	relies on the fact that the symbol _kernel_text marks the
> 	start of the kernel text segment. On systems linking the
> 	kernel with -z (or -Q?), the kernel text segment starts at
> 	(_kernel_text - sizeof(struct exec)). When kvm_mkdb hits an
> 	empty string as the kernel version, the call to bcmp in
> 	dbtest.c will alway return success for future invocations
> 	of kvom_mkdb.
> 
> >How-To-Repeat:
> 	Get a kernel that has a null byte at (_version - sizeof(struct exec)),
> 	do a kvm_mkdb on a pc532 (or an i386?) and your kvm_netbsd.db will no
> 	longer get updated.

My intention when I asked for the new "_kernel_text" symbol was that
the symbol would represent the actual start of the text segment.
Therefore, I think I would rather see this fixed by changing the
way the symbol gets defined in locore.s to the following:

| This is for kvm_mkdb, and should be the address of the beginning
| of the kernel text segment (not necessarily the same as KERNBASE).
	.globl	_kernel_text
	.set	_kernel_text,0xFE002000