mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link/internal/loader: add SetRelocType symbolbuilder method
Clients may need to invoke the loader.Reloc2.SetType method to reset the type of a relocation from external flavor to internal flavor, meaning that the external type add-in needs to be zeroed (this is needed when adding dynsym entries). Add a new SymbolBuider method to support mutating the type of a reloc for an external symbol, so that the external type can be changed as well (Reloc2 doesn't have access to that). Also add similar methods for updating target symbol and addend, so as to have a consistent interface for ext reloc mutation. Change-Id: I8e26cdae0a0f353019acba5f9c8a0506e3970266 Reviewed-on: https://go-review.googlesource.com/c/go/+/229604 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
parent
adea6a90e3
commit
442fd182fb
2 changed files with 21 additions and 1 deletions
|
|
@ -143,6 +143,22 @@ func (sb *SymbolBuilder) SetRelocs(rslice []Reloc) {
|
|||
}
|
||||
}
|
||||
|
||||
// SetRelocType sets the type of the 'i'-th relocation on this sym to 't'
|
||||
func (sb *SymbolBuilder) SetRelocType(i int, t objabi.RelocType) {
|
||||
sb.relocs[i].SetType(0)
|
||||
sb.reltypes[i] = t
|
||||
}
|
||||
|
||||
// SetRelocSym sets the target sym of the 'i'-th relocation on this sym to 's'
|
||||
func (sb *SymbolBuilder) SetRelocSym(i int, tgt Sym) {
|
||||
sb.relocs[i].SetSym(goobj2.SymRef{PkgIdx: 0, SymIdx: uint32(tgt)})
|
||||
}
|
||||
|
||||
// SetRelocAdd sets the addend of the 'i'-th relocation on this sym to 'a'
|
||||
func (sb *SymbolBuilder) SetRelocAdd(i int, a int64) {
|
||||
sb.relocs[i].SetAdd(a)
|
||||
}
|
||||
|
||||
// Add n relocations, return a handle to the relocations.
|
||||
func (sb *SymbolBuilder) AddRelocs(n int) Relocs {
|
||||
sb.relocs = append(sb.relocs, make([]goobj2.Reloc, n)...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue