diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c index 601acf5e7eb..1c9f233097b 100644 --- a/src/cmd/gc/dcl.c +++ b/src/cmd/gc/dcl.c @@ -914,11 +914,13 @@ fninit(Node *n) maxarg = 0; stksize = 0; - vargen++; - h = vargen; + snprint(namebuf, sizeof(namebuf), "init_%s_function", filename); + + // this is a botch since we need a known name to + // call the top level init function out of rt0 if(strcmp(package, "main") == 0) - h = 999; - snprint(namebuf, sizeof(namebuf), "init_%.3ld_function", h); + snprint(namebuf, sizeof(namebuf), "init_function"); + b = nod(ODCLFUNC, N, N); b->nname = newname(lookup(namebuf)); b->type = functype(N, N, N); diff --git a/src/runtime/rt0_amd64.s b/src/runtime/rt0_amd64.s index 5544833e4b6..20761464fb7 100644 --- a/src/runtime/rt0_amd64.s +++ b/src/runtime/rt0_amd64.s @@ -33,7 +33,7 @@ TEXT _rt0_amd64(SB),7,$-8 MOVQ 24(SP), AX // copy argv MOVQ AX, 8(SP) CALL args(SB) - CALL mainĀ·init_999_function(SB) // initialization + CALL mainĀ·init_function(SB) // initialization // create a new goroutine to start program