[dev.link] cmd: convert symbol "shared" flag to object file flag

For the new object file format, don't tag individual symbols with a
"shared" flag, since that characteristic is better off as an attribute
of the containing object file as opposed to the individual symbol. Add
a new flags field in the object file header and put a bit in the flags
if the shared flags is in effect during compilation.

Change-Id: I2cf6d33bf7bf2fd8a7614ae0cd6ef03914777498
Reviewed-on: https://go-review.googlesource.com/c/go/+/201398
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2019-10-16 08:54:58 -04:00
parent 2bbf2e0233
commit 15634a0230
3 changed files with 24 additions and 10 deletions

View file

@ -35,7 +35,11 @@ func WriteObjFile2(ctxt *Link, b *bio.Writer, pkgpath string) {
// Header
// We just reserve the space. We'll fill in the offsets later.
h := goobj2.Header{Magic: goobj2.Magic}
flags := uint32(0)
if ctxt.Flag_shared {
flags |= goobj2.ObjFlagShared
}
h := goobj2.Header{Magic: goobj2.Magic, Flags: flags}
h.Write(w.Writer)
// String table
@ -231,9 +235,6 @@ func (w *writer) Sym(s *LSym) {
if s.ReflectMethod() {
flag |= goobj2.SymFlagReflectMethod
}
if w.ctxt.Flag_shared { // This is really silly
flag |= goobj2.SymFlagShared
}
if s.TopFrame() {
flag |= goobj2.SymFlagTopFrame
}