The public root element identifies the package and provides references
for all exported objects it contains.
- PublicRoot = Relocs
+ PublicRoot = RefTable
[ Sync ]
PkgRef
[ HasInit ]
directive). Every base has a position, line, and column; these are
constant for file bases and hence not encoded.
- PosBase = Relocs
+ PosBase = RefTable
[ Sync ]
StringRef // the (absolute) file name for the base
Bool // true if a file base, else a line base
| "unsafe" | the compiler-known unsafe package |
+--------------+-----------------------------------+
- Pkg = Relocs
+ Pkg = RefTable
[ Sync ]
StringRef // path
// The below is ommitted for the special package paths
# References
A reference table precedes every element. Each entry in the table
-contains a section / index pair denoting the location of the referenced
-element.
-
- // TODO(markfreeman): Rename to RefTable.
- Relocs = [ Sync ]
- RelocCount
- { Reloc }
- .
- // TODO(markfreeman): Rename to RefTableEntryCount.
- RelocCount = Uint64 .
- // TODO(markfreeman): Rename to RefTableEntry.
- Reloc = [ Sync ]
- SectionKind
- RelIndex
- .
+contains a (section, index) pair denoting the location of the
+referenced element.
+
+ RefTable = [ Sync ]
+ Uint64 // the number of table entries
+ { RefTableEntry }
+ .
+ RefTableEntry = [ Sync ]
+ SectionKind
+ RelIndex
+ .
Elements encode references to other elements as an index in the
reference table — not the location of the referenced element directly.
// relocAll ensures that all elements specified by pr and relocs are
// copied into the output export data file, and returns the
// corresponding indices in the output.
-func (l *linker) relocAll(pr *pkgReader, relocs []pkgbits.RelocEnt) []pkgbits.RelocEnt {
- res := make([]pkgbits.RelocEnt, len(relocs))
+func (l *linker) relocAll(pr *pkgReader, relocs []pkgbits.RefTableEntry) []pkgbits.RefTableEntry {
+ res := make([]pkgbits.RefTableEntry, len(relocs))
for i, rent := range relocs {
rent.Idx = l.relocIdx(pr, rent.Kind, rent.Idx)
res[i] = rent
// (or 0, if K==0) and end at elemEndsEnds[K].
elemEndsEnds [numRelocs]uint32
- scratchRelocEnt []RelocEnt
+ scratchRelocEnt []RefTableEntry
}
// PkgPath returns the package path for the package
r.Data.Reset(pr.DataIdx(k, idx))
r.Sync(SyncRelocs)
- r.Relocs = make([]RelocEnt, r.Len())
+ r.Relocs = make([]RefTableEntry, r.Len())
for i := range r.Relocs {
r.Sync(SyncReloc)
- r.Relocs[i] = RelocEnt{SectionKind(r.Len()), RelIndex(r.Len())}
+ r.Relocs[i] = RefTableEntry{SectionKind(r.Len()), RelIndex(r.Len())}
}
return r
r.Relocs = pr.scratchRelocEnt[:l]
pr.scratchRelocEnt = nil
} else {
- r.Relocs = make([]RelocEnt, l)
+ r.Relocs = make([]RefTableEntry, l)
}
for i := range r.Relocs {
r.Sync(SyncReloc)
- r.Relocs[i] = RelocEnt{SectionKind(r.Len()), RelIndex(r.Len())}
+ r.Relocs[i] = RefTableEntry{SectionKind(r.Len()), RelIndex(r.Len())}
}
return r
type Decoder struct {
common *PkgDecoder
- Relocs []RelocEnt
+ Relocs []RefTableEntry
Data strings.Reader
k SectionKind
type Encoder struct {
p *PkgEncoder
- Relocs []RelocEnt
- RelocMap map[RelocEnt]uint32
+ Relocs []RefTableEntry
+ RelocMap map[RefTableEntry]uint32
Data bytes.Buffer // accumulated element bitstream data
encodingRelocHeader bool
}
func (w *Encoder) rawReloc(k SectionKind, idx RelIndex) int {
- e := RelocEnt{k, idx}
+ e := RefTableEntry{k, idx}
if w.RelocMap != nil {
if i, ok := w.RelocMap[e]; ok {
return int(i)
}
} else {
- w.RelocMap = make(map[RelocEnt]uint32)
+ w.RelocMap = make(map[RefTableEntry]uint32)
}
i := len(w.Relocs)
// references from Index to RelIndex.
type RelIndex = Index
-// A RelocEnt, or relocation entry, is an entry in an element's reference
-// table. All elements are preceded by a reference table which provides
-// locations for all dereferences that the element may use.
-type RelocEnt struct {
+// A RefTableEntry is an entry in an element's reference table. All
+// elements are preceded by a reference table which provides locations
+// for referenced elements.
+type RefTableEntry struct {
Kind SectionKind
Idx RelIndex
}