type int32Value int32
-func newIntValue(val int32, p *int32) *int32Value {
- *p = val
- return (*int32Value)(p)
-}
-
func (i *int32Value) Set(s string) error {
v, err := strconv.ParseInt(s, 0, 64)
*i = int32Value(v)
}
}
}
-
-// iteration over encoded pcdata tables.
-
-func getvarint(pp *[]byte) uint32 {
- v := uint32(0)
- p := *pp
- for shift := 0; ; shift += 7 {
- v |= uint32(p[0]&0x7F) << uint(shift)
- tmp7 := p
- p = p[1:]
- if tmp7[0]&0x80 == 0 {
- break
- }
- }
-
- *pp = p
- return v
-}
-
-func pciternext(it *Pciter) {
- it.pc = it.nextpc
- if it.done != 0 {
- return
- }
- if -cap(it.p) >= -cap(it.d.P[len(it.d.P):]) {
- it.done = 1
- return
- }
-
- // value delta
- v := getvarint(&it.p)
-
- if v == 0 && it.start == 0 {
- it.done = 1
- return
- }
-
- it.start = 0
- dv := int32(v>>1) ^ (int32(v<<31) >> 31)
- it.value += dv
-
- // pc delta
- v = getvarint(&it.p)
-
- it.nextpc = it.pc + v*it.pcscale
-}
-
-func pciterinit(ctxt *Link, it *Pciter, d *Pcdata) {
- it.d = *d
- it.p = it.d.P
- it.pc = 0
- it.nextpc = 0
- it.value = -1
- it.start = 1
- it.done = 0
- it.pcscale = uint32(ctxt.Arch.Minlc)
- pciternext(it)
-}
return ctxt
}
-func _lookup(ctxt *Link, symb string, v int, create bool) *LSym {
- s := ctxt.Hash[SymVer{symb, v}]
- if s != nil || !create {
+func Linklookup(ctxt *Link, name string, v int) *LSym {
+ s := ctxt.Hash[SymVer{name, v}]
+ if s != nil {
return s
}
s = &LSym{
- Name: symb,
+ Name: name,
Type: 0,
Version: int16(v),
Value: 0,
Size: 0,
}
- ctxt.Hash[SymVer{symb, v}] = s
-
+ ctxt.Hash[SymVer{name, v}] = s
return s
}
-func Linklookup(ctxt *Link, name string, v int) *LSym {
- return _lookup(ctxt, name, v, true)
-}
-
-// read-only lookup
-func linkrlookup(ctxt *Link, name string, v int) *LSym {
- return _lookup(ctxt, name, v, false)
-}
-
func Linksymfmt(s *LSym) string {
if s == nil {
return "<nil>"