]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/link/internal/loader/loader.go
cmd/link/internal/loader: remove some dead code
[gostls13.git] / src / cmd / link / internal / loader / loader.go
index 455ef587d1c2934e5022bfc6642ceb5953f403df..5dd657b4d7fc7131a9c8bc8e0108f8654bd94d0b 100644 (file)
@@ -27,7 +27,7 @@ var _ = fmt.Print
 
 // Sym encapsulates a global symbol index, used to identify a specific
 // Go symbol. The 0-valued Sym is corresponds to an invalid symbol.
-type Sym uint32
+type Sym = sym.LoaderSym
 
 // Relocs encapsulates the set of relocations on a given symbol; an
 // instance of this type is returned by the Loader Relocs() method.
@@ -261,8 +261,6 @@ type Loader struct {
 
        strictDupMsgs int // number of strict-dup warning/errors, when FlagStrictDups is enabled
 
-       elfsetstring elfsetstringFunc
-
        errorReporter *ErrorReporter
 
        npkgsyms    int // number of package symbols, for accounting
@@ -284,8 +282,6 @@ const (
        goObjStart
 )
 
-type elfsetstringFunc func(str string, off int)
-
 // extSymPayload holds the payload (data + relocations) for linker-synthesized
 // external symbols (note that symbol value is stored in a separate slice).
 type extSymPayload struct {
@@ -304,7 +300,7 @@ const (
        FlagStrictDups = 1 << iota
 )
 
-func NewLoader(flags uint32, elfsetstring elfsetstringFunc, reporter *ErrorReporter) *Loader {
+func NewLoader(flags uint32, reporter *ErrorReporter) *Loader {
        nbuiltin := goobj.NBuiltin()
        extReader := &oReader{objidx: extObj}
        ldr := &Loader{
@@ -333,7 +329,6 @@ func NewLoader(flags uint32, elfsetstring elfsetstringFunc, reporter *ErrorRepor
                extStaticSyms:        make(map[nameVer]Sym),
                builtinSyms:          make([]Sym, nbuiltin),
                flags:                flags,
-               elfsetstring:         elfsetstring,
                errorReporter:        reporter,
                sects:                []*sym.Section{nil}, // reserve index 0 for nil section
        }
@@ -1041,7 +1036,7 @@ func (l *Loader) SetAttrCgoExportDynamic(i Sym, v bool) {
        }
 }
 
-// ForAllAttrCgoExportDynamic calls f for every symbol that has been
+// ForAllCgoExportDynamic calls f for every symbol that has been
 // marked with the "cgo_export_dynamic" compiler directive.
 func (l *Loader) ForAllCgoExportDynamic(f func(Sym)) {
        for s := range l.attrCgoExportDynamic {
@@ -1131,7 +1126,7 @@ func (l *Loader) SetAttrReadOnly(i Sym, v bool) {
 //
 // - Outer symbol covers the address ranges of its sub-symbols.
 //   Outer.Sub is set in this case.
-// - Outer symbol doesn't conver the address ranges. It is zero-sized
+// - Outer symbol doesn't cover the address ranges. It is zero-sized
 //   and doesn't have sub-symbols. In the case, the inner symbol is
 //   not actually a "SubSymbol". (Tricky!)
 //
@@ -1247,6 +1242,16 @@ func (l *Loader) Data(i Sym) []byte {
        return r.Data(li)
 }
 
+// Returns the symbol content of the i-th symbol as a string. i is global index.
+func (l *Loader) DataString(i Sym) string {
+       if l.IsExternal(i) {
+               pp := l.getPayload(i)
+               return string(pp.data)
+       }
+       r, li := l.toLocal(i)
+       return r.DataString(li)
+}
+
 // FreeData clears the symbol data of an external symbol, allowing the memory
 // to be freed earlier. No-op for non-external symbols.
 // i is global index.
@@ -1311,14 +1316,6 @@ func (l *Loader) SetSymSect(i Sym, sect *sym.Section) {
        l.symSects[i] = sect.Index
 }
 
-// growSects grows the slice used to store symbol sections.
-func (l *Loader) growSects(reqLen int) {
-       curLen := len(l.symSects)
-       if reqLen > curLen {
-               l.symSects = append(l.symSects, make([]uint16, reqLen+1-curLen)...)
-       }
-}
-
 // NewSection creates a new (output) section.
 func (l *Loader) NewSection() *sym.Section {
        sect := new(sym.Section)
@@ -1582,6 +1579,9 @@ func (l *Loader) SetSymPkg(i Sym, pkg string) {
 }
 
 // SymLocalentry returns an offset in bytes of the "local entry" of a symbol.
+//
+// On PPC64, a value of 1 indicates the symbol does not use or preserve a TOC
+// pointer in R2, nor does it have a distinct local entry.
 func (l *Loader) SymLocalentry(i Sym) uint8 {
        return l.localentry[i]
 }
@@ -1643,6 +1643,16 @@ func (l *Loader) WasmImportSym(fnSymIdx Sym) (Sym, bool) {
        return 0, false
 }
 
+// SEHUnwindSym returns the auxiliary SEH unwind symbol associated with
+// a given function symbol.
+func (l *Loader) SEHUnwindSym(fnSymIdx Sym) Sym {
+       if l.SymType(fnSymIdx) != sym.STEXT {
+               log.Fatalf("error: non-function sym %d/%s t=%s passed to SEHUnwindSym", fnSymIdx, l.SymName(fnSymIdx), l.SymType(fnSymIdx).String())
+       }
+
+       return l.aux1(fnSymIdx, goobj.AuxSehUnwindInfo)
+}
+
 // GetFuncDwarfAuxSyms collects and returns the auxiliary DWARF
 // symbols associated with a given function symbol.  Prior to the
 // introduction of the loader, this was done purely using name
@@ -1682,6 +1692,15 @@ func (l *Loader) GetFuncDwarfAuxSyms(fnSymIdx Sym) (auxDwarfInfo, auxDwarfLoc, a
        return
 }
 
+func (l *Loader) GetVarDwarfAuxSym(i Sym) Sym {
+       aux := l.aux1(i, goobj.AuxDwarfInfo)
+       if aux != 0 && l.SymType(aux) != sym.SDWARFVAR {
+               fmt.Println(l.SymName(i), l.SymType(i), l.SymType(aux), sym.SDWARFVAR)
+               panic("aux dwarf info sym with wrong type")
+       }
+       return aux
+}
+
 // AddInteriorSym sets up 'interior' as an interior symbol of
 // container/payload symbol 'container'. An interior symbol does not
 // itself have data, but gives a name to a subrange of the data in its