Subject: boot code clobbering of initialised data
To: None <port-sgimips@netbsd.org>
From: sgimips NetBSD list <sgimips@mrynet.com>
List: port-sgimips
Date: 04/20/2002 12:09:00
I've just come across the following problem with the sgimips boot
code:

In the boot code (sys/arch/sgimips/boot/common/boot.c), the
first initalised code defined in the segment is being clobbered.
This was discovered when trying to reference the kernelnames
structured defined there:

char *kernelnames[] = {
        "Xnetbsd.sgimips", 
        "Xnetbsd",
        "Xnetbsd.gz",
        ...

References to kernelnames[0] returned garbage.  References
to [1] and further were fine.

The code was changed to "static const char * const ..." which
effectively moved it elsewhere, but then any following definitions
not declared static were then clobbered.  This was exhibited by
the ARCS routines not finding its devices:

Loading: scsi(0)disk(1)rdisk(0)partition(0)/abcd
devopen: scsi(0)disk(1)rdisk(0)partition(0) type scsi file /abcd
Unknown device 'scsi'
Known devices are: 
open scsi(0)disk(1)rdisk(0)partition(0)/abcd: Device not configured


The hack was to put a dummy allocation in its place:

char *hack[] = {
	"test1234567890",
	"test1234567890",
	"test1234567890",
	"test1234567890",
	"test1234567890",
	NULL};

        
Beats me what's really going on here, but it gets me what I want for now.

-scott