# What is the entry point for loader.efi?



## kHacks (Jul 5, 2020)

Currently, I am reading a BSD OS kernel-code, and I started off with files related to boot process-- not reading the legacy boot codes, but UEFI related files.

I guess, in UEFI bootstrap approach, we will have two stages: first stage requires boot1.efi and the second requires loader.efi.

I've looked at the makefile that generates loader.efi-- which is, https://github.com/freebsd/freebsd/blob/master/stand/efi/loader/Makefile

As mentioned in that Makefile, the Linker script that's being used by loader.efi is....
https://github.com/freebsd/freebsd/blob/master/stand/efi/loader/arch/amd64/ldscript.amd64 (in-case of amd64 architecture).

And in the ldscript.amd64, I see "ENTRY(_start)" is being mentioned as an entry point, here is my issue with that...

1) The source files that are used to construct 'loader.efi' don't seem to have any file that defines a '_start' method -- I may be missing something, but I couldn't find it.

2) Secondly, this same linker script is what being used for 'boot1.efi' as well, and one of the source files that is being used to construct boot1.efi contains '_start' method in start.S....But it is for boot1.efi.

So, the help I need here is....What is the entry point / method for loader.efi when boot1.efi passes control to it?

Thanks!


----------



## Mjölnir (Jul 6, 2020)

_main()_ in stand/efi/loader/main.c?  __start_ is the standard linker symbol and that points to _main()_?


----------

