Subject: Re: xcoff files
To: Bill Studenmund <wrstuden@nas.nasa.gov>
From: Simon Burge <simonb@netbsd.org>
List: tech-toolchain
Date: 06/26/1999 08:53:46
Bill Studenmund wrote:

> Older macppc firmware can only reliably boot xcoff files. I'd like to be
> able to let people download files, throw them on a MacOS floppy, and then
> boot them. Thus for the older machines, they'd need to be xcoff files
> (well one of them).
> 
> So how can I make them? objcopy can turn an elf file into an xcoff one,
> but those files don't work - I get "bad o_magic" errors. Todd suggests
> that the problem's that objcopy can't merge sections. 
> 
> Suggestions? What's the difference between ecoff & xcoff? Could elf2ecoff
> be pressed into service?
> 
> For ref: 
> 
> The linuxppc installer.coff file has the following sections:
> 
> .text, .data, .bss, initrd, image
> 
> ofwboot.xcf (an objcopy --target==xcoff-powermac file) has:
> 
> .text, .rodata, .sdata2, .data, .got, .sdata, .sbss, .bss
> 
> Thoughts?
> 
> Take care,
> 
> Bill
> 

On the pmax I never figured out why "objcopy --target=ecoff-littlemips"
and elf2coff generated different files.  Take a look at the following to
confuse you just that extra little bit that you didn't need to be:

mona:/tmp 7> objcopy --target=ecoff-littlemips /netbsd /tmp/netbsd.objcopy
mona:/tmp 8> elf2ecoff /netbsd /tmp/netbsd.elf2ecoff
mona:/tmp 9> file netbsd*
	netbsd.elf2ecoff: MIPSEL-LE COFF executable (impure) - version 2.10
	netbsd.objcopy:   MIPSEL-LE COFF executable (paged) not stripped - version 0.0
mona:/tmp 10> size netbsd* 
	text    data    bss     dec     hex     filename
	59760   1488128 335300  1883188 1cbc34  netbsd.elf2ecoff
	1955237 135176  335312  2425725 25037d  netbsd.objcopy
mona:/tmp 11> objdump --headers netbsd* 

	netbsd.elf2ecoff:     file format ecoff-littlemips

	Sections:
	Idx Name          Size      VMA       LMA       File off  Algn
	  0 .text         0016b500  80030000  80030000  00000140  2**4
			  CONTENTS, ALLOC, LOAD
	  1 .data         0000e970  8019b500  8019b500  0016b640  2**4
			  CONTENTS, ALLOC, LOAD, READONLY, DATA
	  2 .bss          00051dc4  801a9e70  801a9e70  00000000  2**4
			  ALLOC, LOAD
	  3               00000000  00000000  00000000  00000000  2**4
			  ALLOC, LOAD, DATA
	  4               00000000  00000000  00000000  00000000  2**4
			  ALLOC
	  5               00000000  00000000  00000000  00000000  2**4
			  ALLOC, LOAD

	netbsd.objcopy:     file format ecoff-littlemips

	Sections:
	Idx Name          Size      VMA       LMA       File off  Algn
	  0 .text         00157e60  80030000  80030000  00001000  2**4
			  CONTENTS, ALLOC, LOAD, CODE
	  1 .rodata       00012680  80187e60  80187e60  00158e60  2**4
			  CONTENTS, ALLOC, LOAD, DATA
	  2 .reginfo      00000018  8019a4e0  8019a4e0  0016b4e0  2**4
			  CONTENTS, ALLOC, LOAD, DATA
	  3 .data         0000e930  8019b500  8019b500  0016b500  2**4
			  CONTENTS, ALLOC, LOAD, DATA
	  4 .sdata        00000040  801a9e30  801a9e30  00179e30  2**4
			  CONTENTS, ALLOC, LOAD, DATA
	  5 .sbss         00000000  801a9e70  801a9e70  00000000  2**4
			  ALLOC
	  6 .bss          00051dd0  801a9e70  801a9e70  00000000  2**4
			  ALLOC
	  7 .mdebug       00084ccc  801fbc34  801fbc34  0017a000  2**4
			  CONTENTS, ALLOC, LOAD, READONLY, DATA
	  8 .ident        00000a79  802dff8c  802dff8c  001feccc  2**4
			  CONTENTS, ALLOC, LOAD, READONLY, DATA

This probably doesn't help too much, but if you solve your problem with
objcopy you might solve mine too :-)

Simon.