Skip to contentSkip to conversation

powerpc/boot: Fix crt0.S current address branch form

PATCH Applied Nicholas Piggin 3 participants 4 messages Apr 7, 2023 – Apr 26, 2023 PowerPC

lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 1/1 powerpc/boot: Fix crt0.S current address branch form

Use the preferred form of branch-and-link for finding the current address so objtool doesn't think it is an unannotated intra-function call.

---
 arch/powerpc/boot/crt0.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/boot/crt0.S +2 -2
index 44544720daae..121cab9d579b 100644
@@ -51,7 +51,7 @@ _zimage_start:
 _zimage_start_lib:
 	/* Work out the offset between the address we were linked at
 	   and the address where we're running. */
-	bl	.+4
+	bcl	20,31,.+4
 p_base:	mflr	r10		/* r10 now points to runtime addr of p_base */
 #ifndef __powerpc64__
 	/* grab the link address of the dynamic section in r11 */
@@ -274,7 +274,7 @@ prom:
 	mtsrr1	r10
 
 	/* Load FW address, set LR to label 1, and jump to FW */
-	bl	0f
+	bcl	20,31,0f
 0:	mflr	r10
 	addi	r11,r10,(1f-0b)
 	mtlr	r11
Signature · 1 line
2.40.0
#1 lore raw
Quoted 3 lines · Nicholas Piggin

Use the preferred form of branch-and-link for finding the current address so objtool doesn't think it is an unannotated intra-function call.

We don't run objtool on this code in mainline AFAIK. Because BOOTAS doesn't call it.

Did you actually see a warning, or are you just anticipating that it would warn about it?

This diff would run it on boot asm and seems to build OK, so maybe we should do that.

arch/powerpc/boot/Makefile +1 -1
index 08071bac056d..5d3a4c5354d7 100644
@@ -223,7 +223,7 @@ quiet_cmd_bootcc = BOOTCC  $@
       cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
 
 quiet_cmd_bootas = BOOTAS  $@
-      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
+      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< $(cmd_objtool)
 
 quiet_cmd_bootar = BOOTAR  $@
       cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@

cheers

#2 lore raw
Quoted 7 lines · Michael Ellerman
Quoted 3 lines · Nicholas Piggin

Use the preferred form of branch-and-link for finding the current address so objtool doesn't think it is an unannotated intra-function call.

We don't run objtool on this code in mainline AFAIK. Because BOOTAS doesn't call it.

But as Nick pointed out, if you run:

 $ make arch/powerpc/boot/crt0.o

It does run objtool, because it uses the generic cmd_as_o_S rule instead of the BOOTAS rule.

cheers