NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-macppc/44895: ofwboot.xcf from current cannot boot system



The following reply was made to PR port-macppc/44895; it has been noted by GNATS.

From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: port-macppc/44895: ofwboot.xcf from current cannot boot system
Date: Mon, 17 Apr 2017 16:59:57 +0300

 I did a bit more research but my xcoff and powerpc fu is not enough.
 Here's what I've leared so far.
 
 If you want to be historically correct:
 
 - checkout trunk at -D 20100313
 - that gives you sys/lib/libsa/loadfile_elf32.c 1.24 (that works)
 - manually check out 1.25 of loadfile_elf32.c (that breaks xcoff)
 
 but you should probably just use current.
 
 
 - build.sh -m macppc ... tools
   nbmake-macppc obj
   # i also did nbmake-macppc do-distrib-dirs includes - but those are not
   # necessary to build the bootloader
 
 - cd sys/arch/macppc/stand/ofwboot
 
 - I used the following patch to make elf/xcoff comparison easier
   (patch against the old sources, but it should be obvious what it
   does to apply it to current):
 
 Index: Makefile
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/macppc/stand/ofwboot/Makefile,v
 retrieving revision 1.49
 diff -u -p -u -r1.49 Makefile
 --- Makefile	3 Apr 2009 10:38:13 -0000	1.49
 +++ Makefile	17 Apr 2017 13:44:25 -0000
 @@ -47,6 +47,7 @@ RELOC=		E00000
  ENTRY=		_start
  
  CLEANFILES+=	vers.c ${PROG}.elf ${PROG}.el1 ${PROG}.mrg ${PROG}.xcf
 +CLEANFILES+=	${PROG}.elm
  
  CPPFLAGS+=	-I. -I${.CURDIR} -I${.CURDIR}/../../.. -I${.CURDIR}/../../../..
  CPPFLAGS+=	-DRELOC=0x${RELOC} -DRELOC_FLATFILE=0x${RELOC_FLATFILE}
 @@ -79,7 +80,7 @@ cleanlibdir:
  vers.c: version
  	${HOST_SH} ${S}/conf/newvers_stand.sh ${.CURDIR}/version "macppc" ${NEWVERSWHAT}
  
 -all realall: ${PROG} ${PROG}.xcf ${PROG}.elf
 +all realall: ${PROG} ${PROG}.xcf ${PROG}.elf ${PROG}.elm
  
  ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} 
  	${_MKTARGET_LINK}
 @@ -98,8 +99,14 @@ ${PROG}.elf: ${OBJS} ${LIBSA} ${LIBZ} ${
  ${PROG}.xcf: ${OBJS} ${XCOFFXTRAOBJ} ${LIBSA} ${LIBZ} ${LIBKERN}
  	${_MKTARGET_LINK}
  	${LD} -s -N -T ${.CURDIR}/../fixcoff/elf32_powerpc_merge.x -e _entry \
 -	    -Ttext ${RELOC} -Bstatic -o ${PROG}.mrg  ${XCOFFXTRAOBJ} \
 -	    ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
 +	    -Ttext ${RELOC} -Bstatic -o ${PROG}.mrg \
 +	    ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${XCOFFXTRAOBJ}
  	${OBJCOPY} -O aixcoff-rs6000 -R .comment -R .note \
  	    ${PROG}.mrg ${PROG}.xcf
  	${TOOL_MACPPCFIXCOFF} ${PROG}.xcf
 +
 +${PROG}.elm: ${OBJS} ${XCOFFXTRAOBJ} ${LIBSA} ${LIBZ} ${LIBKERN}
 +	${_MKTARGET_LINK}
 +	${LD} -s -N -T ${.CURDIR}/../fixcoff/elf32_powerpc_merge.x \
 +	    -Ttext ${RELOC} -Bstatic -o ${PROG}.elm \
 +	    ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${XCOFFXTRAOBJ}
 
 
 
 
   The ofwboot.elm is an elf file with the same .text layout as the
   xcoff file.  It also uses the same linker script as the xcoff file.
   objdump -d on ofwboot.elm and ofwboot.xcf shows identical code.
 
 
 - nbmake-macppc dependall
 - copy ofwboot.elf and ofwboot.xcf to your boot partition (I used FAT
   on this test box, so this was trivial)
 
 You are now set up to test this.  Note that the ofwboot.elm works and
 ofwboot.xcf doesn't work.  It loads the kernel, but the kernel panics
 very early.  Adding some instrumentation to the kernel, I see that it
 fails in OF_peer(0) call in sys/arch/powerpc/oea/ofwoea_machdep.c in
 set_timebase() - we probably screw up memory mappings for the OFW.
 
 This is puzzling given that we use exactly the same code in elf and
 xcoff versions.
 
 That revision 1.25 doesn't have anything too suspicious (though I'm
 not sure why does it need to read .shstrtab twice).  Basically it just
 reads a few hundred bytes of .shstrtab section to the in-memory elf
 image.
 
 -uwe
 


Home | Main Index | Thread Index | Old Index