]> Cypherpunks repositories - gostls13.git/commit
[dev.link] cmd/link/internal/objfile: new loader method for reloc queries
authorThan McIntosh <thanm@google.com>
Fri, 11 Oct 2019 12:56:19 +0000 (08:56 -0400)
committerThan McIntosh <thanm@google.com>
Fri, 11 Oct 2019 15:06:34 +0000 (15:06 +0000)
commit0b25ab5d96230b8ec5debbf9880527885e0c7573
tree4599d8f17ed6f2ca3f33d7b55cdc8b6aa1600d5e
parente44dfa1f2b322537ce3ee1f589af1082748accc5
[dev.link] cmd/link/internal/objfile: new loader method for reloc queries

Second change of several to update the loader API to reflect the final
consensus version of the loader API as described in Cherry's doc.
This piece:

 - define new loader.Relocs() method that returns a struct
   encapsulating a set of relocations on a global symbol

Old way of examining relocations:

  nreloc := loader.NReloc(someGlobalSymbolIndex)
  for i := 0; i < nreloc; i++ {
    tgtIdx := loader.RelocSym(someGlobalSymbolIndex, i))
    ... <do something with tgtIdx>
  }

New way of examining relocations:

  relocs := d.loader.Relocs(someGlobalSymbolIndex)
  for i := 0; i < relocs.Count; i++ {
    r := relocs.At(i).Sym
    ... <do something with r.Sym>
  }

Change-Id: I5bead1d729655ea13b3396647e53aafcd3e60f97
Reviewed-on: https://go-review.googlesource.com/c/go/+/200717
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/objfile/objfile2.go