mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link/internal/loader: support 'variant' relocations
Add support to the loader for getting/setting the 'variant' property of a symbol relocation. The variant property handles unusual or infrequently used relocations that have both a type and a variant of that type (this is needed for S390). In the sym.Symbol world, a relocation variant is a field on the 'relocExt' extension that is part of sym.Reloc. In this new implementation for the loader, reloc variants are stored in a side table (a map) in the loader, and accessed via loader methods. Change-Id: I62bf54ae7ff6d500c0ea8d2dbe759b2431087378 Reviewed-on: https://go-review.googlesource.com/c/go/+/227018 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
8e457c865d
commit
6636b3f2fc
2 changed files with 49 additions and 5 deletions
|
|
@ -140,12 +140,17 @@ func (sb *SymbolBuilder) SetRelocs(rslice []Reloc) {
|
|||
}
|
||||
}
|
||||
|
||||
func (sb *SymbolBuilder) AddReloc(r Reloc) {
|
||||
// AddReloc appends the specified reloc to the symbols list of
|
||||
// relocations. Return value is the index of the newly created
|
||||
// reloc.
|
||||
func (sb *SymbolBuilder) AddReloc(r Reloc) uint32 {
|
||||
// Populate a goobj2.Reloc from external reloc record.
|
||||
rval := uint32(len(sb.relocs))
|
||||
var b goobj2.Reloc2
|
||||
b.Set(r.Off, r.Size, 0, r.Add, goobj2.SymRef{PkgIdx: 0, SymIdx: uint32(r.Sym)})
|
||||
sb.relocs = append(sb.relocs, b)
|
||||
sb.reltypes = append(sb.reltypes, r.Type)
|
||||
return rval
|
||||
}
|
||||
|
||||
// Update the j-th relocation in place.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue