assemblyfuchsia

Where is the first code run on Zircon (Fuchsia) kernel on this start.S file?


I'm reading the start.S assembly code for the Zircon Kernel (Fuchsia OS):

https://fuchsia.googlesource.com/fuchsia/+/master/zircon/kernel/arch/arm64/start.S

There's this line:

.text
FUNCTION(_start)

I think this is the first thing ever that get executed on the kernel. However, for it to be true, _start should be global. I couldn't determine if it is or not.

There's this other line:

// This symbol is used by image.S
.global IMAGE_ELF_ENTRY
IMAGE_ELF_ENTRY = _start

that suggests something like it.

What is FUNCTION on FUNCTION(_start)? I tried searching for "assembly FUNCTION macro" but found nothing related to this.

It looks like this is the first code run, but I could not determine where it branches to real kernel code (C++ code) so I'm in doubt.


Solution

  • The definition of these macros can be found in //zircon/kernel/include/asm.h, it's basically a wrapper that adds all the required annotations, including CFI directives.

    So FUNCTION(_start) would expand to:

    .global _start;
    .hidden _start;
    .type _start,STT_FUNC;
    _start:
      .cfi_startproc
    

    The branching to C++ code happens on the bl lk_main instruction.