Page 1 of 1

Raspberry Pi | Error: backward ref to unknown label "1:"

Posted: Wed Jun 09, 2021 2:39 pm
by Sammyueru
Hello I am trying to make a raspberry pi OS from scratch but I get this error for the boot.s file when building with a makefile:

Code: Select all

..//src/kernel/boot.s: Assembler messages:
..//src/kernel/boot.s:32: Error: backward ref to unknown label "1:"
make: *** [Makefile:95: ..//build/objects/boot.o] Error 1
Whenever I look up the error it seems to be that the script cannot figure out that its supposed to be a number or something like that.
Sorry if this something only an asm noob could miss.


Boot.s Script:

Code: Select all

// AArch64 mode
 
// To keep this in the first portion of the binary.
.section ".text.boot"
 
// Make _start global.
.globl _start
 
    .org 0x80000
// Entry point for the kernel. Registers:
// x0 -> 32 bit pointer to DTB in memory (primary core only) / 0 (secondary cores)
// x1 -> 0
// x2 -> 0
// x3 -> 0
// x4 -> 32 bit kernel entry point, _start location
_start:
    // set stack before our code
    ldr     x5, =_start
    mov     sp, x5
 
    // clear bss
    ldr     x5, =__bss_start
    ldr     w6, =__bss_size
3:  cbz     w6, 4f
    str     xzr, [x5], #8
    sub     w6, w6, #1
    cbnz    w6, 3b
 
    // jump to C code, should not return
4:  bl      kernel_main
    // for failsafe, halt this core too
    b 1b 

Anyways thanks in advance.

Re: Raspberry Pi | Error: backward ref to unknown label "1:"

Posted: Wed Jun 09, 2021 3:14 pm
by Octocontrabass
Where did you get this code?

Re: Raspberry Pi | Error: backward ref to unknown label "1:"

Posted: Wed Jun 09, 2021 4:17 pm
by Sammyueru
Octocontrabass wrote:Where did you get this code?
I got it from Raspberry Pi bare bones on OSDev

Re: Raspberry Pi | Error: backward ref to unknown label "1:"

Posted: Wed Jun 09, 2021 4:51 pm
by Octocontrabass
It looks like someone put untested code on the wiki again.

I'm no Raspberry Pi expert, but I think adding one line of code should fix it:

Code: Select all

    // for failsafe, halt this core too
1:  wfe
    b 1b 

Re: Raspberry Pi | Error: backward ref to unknown label "1:"

Posted: Wed Jun 09, 2021 4:55 pm
by Sammyueru
Octocontrabass wrote:It looks like someone put untested code on the wiki again.

I'm no Raspberry Pi expert, but I think adding one line of code should fix it:

Code: Select all

    // for failsafe, halt this core too
1:  wfe
    b 1b 
Thank you I’ll try that