From 55bd193575152ea09db3a0bd33f9dda49725d8f4 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Thu, 26 Jan 2023 15:12:00 -0500 Subject: cmd/internal/obj: flag init functions in object file Introduce a flag in the object file indicating whether a given function corresponds to a compiler-generated (not user-written) init function, such as "os.init" or "syscall.init". Add code to the compiler to fill in the correct value for the flag, and add support to the loader package in the linker for testing the flag. The new loader API is currently unused, but will be needed in the next CL in this stack. Updates #2559. Updates #36021. Updates #14840. Change-Id: Iea7ad2adda487e4af7a44f062f9817977c53b394 Reviewed-on: https://go-review.googlesource.com/c/go/+/463855 Reviewed-by: Cherry Mui Run-TryBot: Than McIntosh TryBot-Result: Gopher Robot --- src/cmd/internal/obj/objfile.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cmd/internal/obj/objfile.go') diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go index 85e49e248c..73c29d9686 100644 --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@ -344,6 +344,9 @@ func (w *writer) Sym(s *LSym) { if strings.HasPrefix(s.Name, w.ctxt.Pkgpath) && strings.HasPrefix(s.Name[len(w.ctxt.Pkgpath):], ".") && strings.HasPrefix(s.Name[len(w.ctxt.Pkgpath)+1:], objabi.GlobalDictPrefix) { flag2 |= goobj.SymFlagDict } + if s.IsPkgInit() { + flag2 |= goobj.SymFlagPkgInit + } name := s.Name if strings.HasPrefix(name, "gofile..") { name = filepath.ToSlash(name) -- cgit v1.3-5-g9baa