]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: add dynimp, localentry attributes for loader.Sym
authorThan McIntosh <thanm@google.com>
Thu, 12 Dec 2019 13:08:40 +0000 (08:08 -0500)
committerThan McIntosh <thanm@google.com>
Fri, 20 Dec 2019 21:04:57 +0000 (21:04 +0000)
Add new methods to get/set the "dynimplib", "dynimpvers" and
"localentry" attributes for an external Sym in loader.Loader. These
attribute values are stored sparsely, since we expect that most
symbols will not need them; they are set when processing cgo
directives and when dealing with host object symbols.

Change-Id: If0b3c173307801d39cb576bb99c83b9081c42d9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/211298
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/link/internal/loader/loader.go

index 911fe69ec755c56e3bae0a371f112a89675851ef..d4f2ccba56733462ceea332ce1122974c804371f 100644 (file)
@@ -196,6 +196,11 @@ type Loader struct {
 
        align map[Sym]int32 // stores alignment for symbols
 
+       dynimplib  map[Sym]string // stores Dynimplib symbol attribute
+       dynimpvers map[Sym]string // stores Dynimpvers symbol attribute
+       localentry map[Sym]uint8  // stores Localentry symbol attribute
+       extname    map[Sym]string // stores Extname symbol attribute
+
        // Used to implement field tracking; created during deadcode if
        // field tracking is enabled. Reachparent[K] contains the index of
        // the symbol that triggered the marking of symbol K as live.
@@ -944,6 +949,84 @@ func (l *Loader) SetSymAlign(i Sym, align int32) {
        }
 }
 
+// SymDynImplib returns the "dynimplib" attribute for the specified
+// symbol, making up a portion of the info for a symbol specified
+// on a "cgo_import_dynamic" compiler directive.
+func (l *Loader) SymDynimplib(i Sym) string {
+       return l.dynimplib[i]
+}
+
+// SetSymDynimplib sets the "dynimplib" attribute for a symbol.
+func (l *Loader) SetSymDynimplib(i Sym, value string) {
+       // reject bad symbols
+       if i > l.max || i == 0 {
+               panic("bad symbol index in SetDynimplib")
+       }
+       if value == "" {
+               delete(l.dynimplib, i)
+       } else {
+               l.dynimplib[i] = value
+       }
+}
+
+// SymDynimpvers returns the "dynimpvers" attribute for the specified
+// symbol, making up a portion of the info for a symbol specified
+// on a "cgo_import_dynamic" compiler directive.
+func (l *Loader) SymDynimpvers(i Sym) string {
+       return l.dynimpvers[i]
+}
+
+// SetSymDynimpvers sets the "dynimpvers" attribute for a symbol.
+func (l *Loader) SetSymDynimpvers(i Sym, value string) {
+       // reject bad symbols
+       if i > l.max || i == 0 {
+               panic("bad symbol index in SetDynimpvers")
+       }
+       if value == "" {
+               delete(l.dynimpvers, i)
+       } else {
+               l.dynimpvers[i] = value
+       }
+}
+
+// SymExtname returns the "extname" value for the specified
+// symbol.
+func (l *Loader) SymExtname(i Sym) string {
+       return l.extname[i]
+}
+
+// SetSymExtname sets the  "extname" attribute for a symbol.
+func (l *Loader) SetSymExtname(i Sym, value string) {
+       // reject bad symbols
+       if i > l.max || i == 0 {
+               panic("bad symbol index in SetExtname")
+       }
+       if value == "" {
+               delete(l.extname, i)
+       } else {
+               l.extname[i] = value
+       }
+}
+
+// SymLocalentry returns the "local entry" value for the specified
+// symbol.
+func (l *Loader) SymLocalentry(i Sym) uint8 {
+       return l.localentry[i]
+}
+
+// SetSymExtname sets the "extname" attribute for a symbol.
+func (l *Loader) SetSymLocalentry(i Sym, value uint8) {
+       // reject bad symbols
+       if i > l.max || i == 0 {
+               panic("bad symbol index in SetExtname")
+       }
+       if value == 0 {
+               delete(l.localentry, i)
+       } else {
+               l.localentry[i] = value
+       }
+}
+
 // Returns the number of aux symbols given a global index.
 func (l *Loader) NAux(i Sym) int {
        if l.IsExternal(i) {