Using objdump, the actual program start is _rt0_amd64_linux
<https://github.com/golang/go/blob/0f02664666bb30e7cb4041dd0f8d7f739ffd54af/src/runtime/rt0_linux_amd64.s#L7>
(on that platform, obviously), which, if you follow it, pretty much does
nothing but call runtimeā€¢rt0_go
<https://github.com/golang/go/blob/0f02664666bb30e7cb4041dd0f8d7f739ffd54af/src/runtime/asm_amd64.s#L87>,
which seems to be doing the initialization you are talking about. For the
implementation of getg you have to look at the compiler
<https://github.com/golang/go/blob/0f02664666bb30e7cb4041dd0f8d7f739ffd54af/src/cmd/compile/internal/amd64/ssa.go#L925>
(found
by grepping in src/cmd/compile).

Hope this can serve as a starting point for further investigation - I'm not
actually familiar with this stuff myself, I'm afraid :)


On Tue, Nov 20, 2018 at 8:53 AM Fei Ding <fding...@gmail.com> wrote:

> Hi
>
> I am trying to figure out the process of creation of the very first
> g(goroutine), together with the very fist m, and p. It seems that the
> deepest code I can find is at proc.go
> <https://github.com/golang/go/blob/master/src/runtime/proc.go#L110>, and
> the getg() function is my dead end, which has no implementation written by
> golang. So, here is my q:
>
> 1. I guess before the user main() function be executed, a lot of work has
> already been finished, including creating the very first g/m/p, where the
> code is? It seems to be asm code? I do have some problem reading/digging
> asm code.
>
> 2. Could any one explain the whole process of creating the very first
> g/m/p?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to