Skip to contentSkip to conversation

Fix booting some PPC32 machines

PATCH In review Tom Rini 3 participants 5 messages May 3, 2004 – May 4, 2004

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 Fix booting some PPC32 machines

Hello. The following patch fixes booting on some PPC32 machines with OpenFirmware, when booted without the aid of an additional bootloader. The problem is that the linker script for the 'zImage' type targets was put into the list of dependancies which objcopy would parse as a list of files to copy into the resulting image. The fix is to make the phony zImage targets depend on the linker script.

===== arch/ppc/boot/openfirmware/Makefile 1.22 vs edited =====

arch/ppc/boot/openfirmware/Makefile +10 -8
@@ -104,10 +104,10 @@
 			$(HACKCOFF) $@ && \
 			ln -sf $(notdir $@) $(images)/zImage$(initrd).pmac
 
-$(images)/vmlinux.coff: $(obj)/coffboot $(boot)/ld.script
+$(images)/vmlinux.coff: $(obj)/coffboot
 	$(call cmd,gen-coff)
 
-$(images)/vmlinux.initrd.coff: $(obj)/coffboot.initrd $(boot)/ld.script
+$(images)/vmlinux.initrd.coff: $(obj)/coffboot.initrd
 	$(call cmd,gen-coff)
 
 quiet_cmd_gen-elf-pmac = ELF     $@
@@ -116,19 +116,19 @@
 			$(OBJCOPY) $@ $@ --add-section=.note=$(obj)/note \
 					 -R .comment $(del-ramdisk-sec)
 
-$(images)/vmlinux.elf-pmac: $(obj)/image.o $(NEWWORLDOBJS) $(LIBS) $(obj)/note $(boot)/ld.script
+$(images)/vmlinux.elf-pmac: $(obj)/image.o $(NEWWORLDOBJS) $(LIBS) $(obj)/note
 	$(call cmd,gen-elf-pmac)
 $(images)/vmlinux.initrd.elf-pmac: $(obj)/image.initrd.o $(NEWWORLDOBJS) \
-				   $(LIBS) $(obj)/note $(boot)/ld.script
+				   $(LIBS) $(obj)/note
 	$(call cmd,gen-elf-pmac)
 
 quiet_cmd_gen-chrp = CHRP    $@
       cmd_gen-chrp = $(LD) $(CHRP_LD_ARGS) -o $@ $^ && \
 			$(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec)
 
-$(images)/zImage.chrp: $(CHRPOBJS) $(obj)/image.o $(LIBS) $(boot)/ld.script
+$(images)/zImage.chrp: $(CHRPOBJS) $(obj)/image.o $(LIBS)
 	$(call cmd,gen-chrp)
-$(images)/zImage.initrd.chrp: $(CHRPOBJS) $(obj)/image.initrd.o $(LIBS) $(boot)/ld.script
+$(images)/zImage.initrd.chrp: $(CHRPOBJS) $(obj)/image.initrd.o $(LIBS)
 	$(call cmd,gen-chrp)
 
 quiet_cmd_addnote = ADDNOTE $@
@@ -153,13 +153,15 @@
 		 $(images)/vmlinux.elf-pmac	\
 		 $(images)/zImage.chrp		\
 		 $(images)/zImage.chrp-rs6k	\
-		 $(images)/miboot.image
+		 $(images)/miboot.image		\
+		 $(boot)/ld.script
 	@echo '  kernel: $@ is ready ($<)'
 zImage.initrd:	 $(images)/vmlinux.initrd.coff 		\
 		 $(images)/vmlinux.initrd.elf-pmac	\
 		 $(images)/zImage.initrd.chrp		\
 		 $(images)/zImage.initrd.chrp-rs6k	\
-		 $(images)/miboot.initrd.image
+		 $(images)/miboot.initrd.image		\
+		 $(boot)/ld.script
 	@echo '  kernel: $@ is ready ($<)'
 
 TFTPIMAGE	:= /tftpboot/zImage
Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#1 lore raw
Quoted 6 lines · Tom Rini

Hello. The following patch fixes booting on some PPC32 machines with OpenFirmware, when booted without the aid of an additional bootloader. The problem is that the linker script for the 'zImage' type targets was put into the list of dependancies which objcopy would parse as a list of files to copy into the resulting image. The fix is to make the phony zImage targets depend on the linker script.

I don't like this part of the fix:

arch/ppc/boot/openfirmware/Makefile line 123

Quoted 4 lines

$(images)/vmlinux.initrd.elf-pmac: $(obj)/image.initrd.o $(NEWWORLDOBJS) \

arch/ppc/boot/openfirmware/Makefile +1 -1
-				   $(LIBS) $(obj)/note $(boot)/ld.script
+				   $(LIBS) $(obj)/note
 	$(call cmd,gen-elf-pmac)

because the linking process (gen-elf-pmac) really does depend on ld.script. Since gen-elf-pmac uses $<, not $^, it should be OK with the ld.script in the dependencies. Did you verify that there was a problem with this rule or did you just rip out all of the ld.script dependencies?

Similarly we need the ld.script dependency in here:

arch/ppc/boot/openfirmware/Makefile line 132

Quoted 6 lines

-$(images)/zImage.chrp: $(CHRPOBJS) $(obj)/image.o $(LIBS) $(boot)/ld.script +$(images)/zImage.chrp: $(CHRPOBJS) $(obj)/image.o $(LIBS)

arch/ppc/boot/openfirmware/Makefile +1 -1
 	$(call cmd,gen-chrp)
-$(images)/zImage.initrd.chrp: $(CHRPOBJS) $(obj)/image.initrd.o $(LIBS) $(boot)/ld.script
+$(images)/zImage.initrd.chrp: $(CHRPOBJS) $(obj)/image.initrd.o $(LIBS)
 	$(call cmd,gen-chrp)

Here, gen-chrp does have a problem because it uses $^, but it looks to me that with a minor change it could just use $< and avoid the problem.

The other places where you have removed ld.script from the dependencies look OK to me.

Regards,
Paul.

author
#2 lore raw
Quoted 11 lines · Paul Mackerras
Quoted 6 lines · Tom Rini

Hello. The following patch fixes booting on some PPC32 machines with OpenFirmware, when booted without the aid of an additional bootloader. The problem is that the linker script for the 'zImage' type targets was put into the list of dependancies which objcopy would parse as a list of files to copy into the resulting image. The fix is to make the phony zImage targets depend on the linker script.

I don't like this part of the fix:

Quoted 10 lines

arch/ppc/boot/openfirmware/Makefile line 123

Quoted 4 lines

$(images)/vmlinux.initrd.elf-pmac: $(obj)/image.initrd.o $(NEWWORLDOBJS) \

arch/ppc/boot/openfirmware/Makefile +1 -1
-				   $(LIBS) $(obj)/note $(boot)/ld.script
+				   $(LIBS) $(obj)/note
 	$(call cmd,gen-elf-pmac)

because the linking process (gen-elf-pmac) really does depend on ld.script. Since gen-elf-pmac uses $<, not $^, it should be OK with the ld.script in the dependencies. Did you verify that there was a problem with this rule or did you just rip out all of the ld.script dependencies?

I did just remove all of the previous dependancies and place them on the zImage target (we don't mention that you can do 'make arch/ppc/boot/images/foo.image, and I don't know if that would work, so I don't think that'd be a problem).

Quoted 9 lines

Similarly we need the ld.script dependency in here:

arch/ppc/boot/openfirmware/Makefile line 132

Quoted 6 lines

-$(images)/zImage.chrp: $(CHRPOBJS) $(obj)/image.o $(LIBS) $(boot)/ld.script +$(images)/zImage.chrp: $(CHRPOBJS) $(obj)/image.o $(LIBS)

arch/ppc/boot/openfirmware/Makefile +1 -1
 	$(call cmd,gen-chrp)
-$(images)/zImage.initrd.chrp: $(CHRPOBJS) $(obj)/image.initrd.o $(LIBS) $(boot)/ld.script
+$(images)/zImage.initrd.chrp: $(CHRPOBJS) $(obj)/image.initrd.o $(LIBS)
 	$(call cmd,gen-chrp)
Quoted 3 lines

Here, gen-chrp does have a problem because it uses $^, but it looks to me that with a minor change it could just use $< and avoid the problem.

IIRC, changing to $< means we have to compilcate the rules a bit more, or thinking a bit harder, re-arrange the dependancies s.t. $(obj)/image*.o is first, and gen-chrp (and gen-pmac) both know to use $(CHRPOBJS) and $(LIBS).

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#3 lore raw
In reply to Tom Rini
Quoted 6 lines · Tom Rini

Hello. The following patch fixes booting on some PPC32 machines with OpenFirmware, when booted without the aid of an additional bootloader. The problem is that the linker script for the 'zImage' type targets was put into the list of dependancies which objcopy would parse as a list of files to copy into the resulting image. The fix is to make the phony zImage targets depend on the linker script.

This fixes netbooting on my B50. But it breaks the dependency to ld.script, which was the whole point of the previous patch.

Signature · 3 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG
author
#4 lore raw
Quoted 11 lines · Olaf Hering
Quoted 6 lines · Tom Rini

Hello. The following patch fixes booting on some PPC32 machines with OpenFirmware, when booted without the aid of an additional bootloader. The problem is that the linker script for the 'zImage' type targets was put into the list of dependancies which objcopy would parse as a list of files to copy into the resulting image. The fix is to make the phony zImage targets depend on the linker script.

This fixes netbooting on my B50. But it breaks the dependency to ld.script, which was the whole point of the previous patch.

As I mentioned on IRC, but don't have time ATM to verify, I don't think a 'touch' of the ld.script is sufficient a test in this case since it's a call-if-changed thing so you'd have to modify ld.script. Can you do that and see if it's really a change? Thanks.

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/