Subject: Re: more on sparc svr4 emul problem
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Eduardo E. Horvath <eeh@one-o.com>
List: port-sparc
Date: 02/01/2000 10:15:13
> > I had noticed a while back that the problem only happens when the
> > kernel is ELF, a.out kernels work fine.  as a goofy experiment, I
> > tried converting an a.out kernel to ELF with objcopy, and I was
> > completely amazed to find that this produced a working kernel [...]
> > anyone have ideas on how to proceed from here?

It's been such a long time.  What were the details of the problem again?

> Well, here's how I'd approach it.
> 
> - objcopy all the .o files from your a.out kernel, then try linking
>    with the ELF ld.  If it fails, it's ld; if not, it's elsewhere.
> 
> - If it's ld, I'm not sure where to go from there.
> 
> - If it's elsewhere, then start recompiling, one file at a time.  (Or
>    if you're ambitious, save all the objcopied a.out .o files and do
>    binary search on the set of .o files.)  Once you find the file that
>    breaks, try a kernel that's ELF all the way except for that .o file.
> 
> - If you can narrow it down to a single .o file, then start using cc -S
>    and diff and the like, or possibly diff the disassembled .o files.
> 
> - If not...I'm not sure where to take it from there.
> 
> This is largely built on the hope that it's a codegen bug, somehow, as
> you can probably tell from which branches are "I'm not sure what to do".

That sounds like a good idea.

ELF is a much richer format than a.out, so when you convert something
from a.out to ELF you will have fewer segments than if you compiled
native ELF.  Make sure that important things like text or data aren't
stuffed into sections that the bootloader skips.

One interesting thing that I found was the `__aligned' directive used
on the `lock_data' field of the `simple_lock' structure caused the
data segment to be 64KB aligned in 64-bit mode, which resulted in a
separation between text and data segments, which prevented the kernel
from booting.  So check segment alignment, too.

I don't know if any of this will help.

=========================================================================
Eduardo Horvath				eeh@netbsd.org
	"I need to find a pithy new quote." -- me