mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link/internal/ld: camelCase a buch of snake_case names
I've also unexported a few symbols that weren't used outside the package. Updates #16818 Change-Id: I39d9d87b3eec30b88b4a17c1333cfbbfa6b3518f Reviewed-on: https://go-review.googlesource.com/27468 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
5e66ac9ac6
commit
24158644dd
13 changed files with 233 additions and 233 deletions
|
|
@ -1133,15 +1133,15 @@ func (p *GCProg) AddSym(s *Symbol) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ptrsize := int64(SysArch.PtrSize)
|
ptrsize := int64(SysArch.PtrSize)
|
||||||
nptr := decodetype_ptrdata(p.ctxt.Arch, typ) / ptrsize
|
nptr := decodetypePtrdata(p.ctxt.Arch, typ) / ptrsize
|
||||||
|
|
||||||
if debugGCProg {
|
if debugGCProg {
|
||||||
fmt.Fprintf(os.Stderr, "gcprog sym: %s at %d (ptr=%d+%d)\n", s.Name, s.Value, s.Value/ptrsize, nptr)
|
fmt.Fprintf(os.Stderr, "gcprog sym: %s at %d (ptr=%d+%d)\n", s.Name, s.Value, s.Value/ptrsize, nptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if decodetype_usegcprog(typ) == 0 {
|
if decodetypeUsegcprog(typ) == 0 {
|
||||||
// Copy pointers from mask into program.
|
// Copy pointers from mask into program.
|
||||||
mask := decodetype_gcmask(p.ctxt, typ)
|
mask := decodetypeGcmask(p.ctxt, typ)
|
||||||
for i := int64(0); i < nptr; i++ {
|
for i := int64(0); i < nptr; i++ {
|
||||||
if (mask[i/8]>>uint(i%8))&1 != 0 {
|
if (mask[i/8]>>uint(i%8))&1 != 0 {
|
||||||
p.w.Ptr(s.Value/ptrsize + i)
|
p.w.Ptr(s.Value/ptrsize + i)
|
||||||
|
|
@ -1151,7 +1151,7 @@ func (p *GCProg) AddSym(s *Symbol) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy program.
|
// Copy program.
|
||||||
prog := decodetype_gcprog(p.ctxt, typ)
|
prog := decodetypeGcprog(p.ctxt, typ)
|
||||||
p.w.ZeroUntil(s.Value / ptrsize)
|
p.w.ZeroUntil(s.Value / ptrsize)
|
||||||
p.w.Append(prog[4:], nptr)
|
p.w.Append(prog[4:], nptr)
|
||||||
}
|
}
|
||||||
|
|
@ -1539,12 +1539,12 @@ func (ctxt *Link) dodata() {
|
||||||
// situation.
|
// situation.
|
||||||
// TODO(mwhudson): It would make sense to do this more widely, but it makes
|
// TODO(mwhudson): It would make sense to do this more widely, but it makes
|
||||||
// the system linker segfault on darwin.
|
// the system linker segfault on darwin.
|
||||||
relro_perms := 04
|
relroPerms := 04
|
||||||
relro_prefix := ""
|
relroPrefix := ""
|
||||||
|
|
||||||
if UseRelro() {
|
if UseRelro() {
|
||||||
relro_perms = 06
|
relroPerms = 06
|
||||||
relro_prefix = ".data.rel.ro"
|
relroPrefix = ".data.rel.ro"
|
||||||
/* data only written by relocations */
|
/* data only written by relocations */
|
||||||
sect = addsection(segro, ".data.rel.ro", 06)
|
sect = addsection(segro, ".data.rel.ro", 06)
|
||||||
|
|
||||||
|
|
@ -1587,7 +1587,7 @@ func (ctxt *Link) dodata() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* typelink */
|
/* typelink */
|
||||||
sect = addsection(segro, relro_prefix+".typelink", relro_perms)
|
sect = addsection(segro, relroPrefix+".typelink", relroPerms)
|
||||||
sect.Align = dataMaxAlign[obj.STYPELINK]
|
sect.Align = dataMaxAlign[obj.STYPELINK]
|
||||||
datsize = Rnd(datsize, int64(sect.Align))
|
datsize = Rnd(datsize, int64(sect.Align))
|
||||||
sect.Vaddr = uint64(datsize)
|
sect.Vaddr = uint64(datsize)
|
||||||
|
|
@ -1604,7 +1604,7 @@ func (ctxt *Link) dodata() {
|
||||||
sect.Length = uint64(datsize) - sect.Vaddr
|
sect.Length = uint64(datsize) - sect.Vaddr
|
||||||
|
|
||||||
/* itablink */
|
/* itablink */
|
||||||
sect = addsection(segro, relro_prefix+".itablink", relro_perms)
|
sect = addsection(segro, relroPrefix+".itablink", relroPerms)
|
||||||
sect.Align = dataMaxAlign[obj.SITABLINK]
|
sect.Align = dataMaxAlign[obj.SITABLINK]
|
||||||
datsize = Rnd(datsize, int64(sect.Align))
|
datsize = Rnd(datsize, int64(sect.Align))
|
||||||
sect.Vaddr = uint64(datsize)
|
sect.Vaddr = uint64(datsize)
|
||||||
|
|
@ -1621,7 +1621,7 @@ func (ctxt *Link) dodata() {
|
||||||
sect.Length = uint64(datsize) - sect.Vaddr
|
sect.Length = uint64(datsize) - sect.Vaddr
|
||||||
|
|
||||||
/* gosymtab */
|
/* gosymtab */
|
||||||
sect = addsection(segro, relro_prefix+".gosymtab", relro_perms)
|
sect = addsection(segro, relroPrefix+".gosymtab", relroPerms)
|
||||||
sect.Align = dataMaxAlign[obj.SSYMTAB]
|
sect.Align = dataMaxAlign[obj.SSYMTAB]
|
||||||
datsize = Rnd(datsize, int64(sect.Align))
|
datsize = Rnd(datsize, int64(sect.Align))
|
||||||
sect.Vaddr = uint64(datsize)
|
sect.Vaddr = uint64(datsize)
|
||||||
|
|
@ -1638,7 +1638,7 @@ func (ctxt *Link) dodata() {
|
||||||
sect.Length = uint64(datsize) - sect.Vaddr
|
sect.Length = uint64(datsize) - sect.Vaddr
|
||||||
|
|
||||||
/* gopclntab */
|
/* gopclntab */
|
||||||
sect = addsection(segro, relro_prefix+".gopclntab", relro_perms)
|
sect = addsection(segro, relroPrefix+".gopclntab", relroPerms)
|
||||||
sect.Align = dataMaxAlign[obj.SPCLNTAB]
|
sect.Align = dataMaxAlign[obj.SPCLNTAB]
|
||||||
datsize = Rnd(datsize, int64(sect.Align))
|
datsize = Rnd(datsize, int64(sect.Align))
|
||||||
sect.Vaddr = uint64(datsize)
|
sect.Vaddr = uint64(datsize)
|
||||||
|
|
@ -1794,7 +1794,7 @@ func dodataSect(ctxt *Link, symn int, syms []*Symbol) (result []*Symbol, maxAlig
|
||||||
case obj.STYPELINK:
|
case obj.STYPELINK:
|
||||||
// Sort typelinks by the rtype.string field so the reflect
|
// Sort typelinks by the rtype.string field so the reflect
|
||||||
// package can binary search type links.
|
// package can binary search type links.
|
||||||
symsSort[i].name = string(decodetype_str(s.R[0].Sym))
|
symsSort[i].name = string(decodetypeStr(s.R[0].Sym))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -276,8 +276,8 @@ func (d *deadcodepass) flood() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(s.Name, "type.") && s.Name[5] != '.' {
|
if strings.HasPrefix(s.Name, "type.") && s.Name[5] != '.' {
|
||||||
if decodetype_kind(s)&kindMask == kindInterface {
|
if decodetypeKind(s)&kindMask == kindInterface {
|
||||||
for _, sig := range decodetype_ifacemethods(d.ctxt.Arch, s) {
|
for _, sig := range decodeIfaceMethods(d.ctxt.Arch, s) {
|
||||||
if d.ctxt.Debugvlog > 1 {
|
if d.ctxt.Debugvlog > 1 {
|
||||||
fmt.Fprintf(d.ctxt.Bso, "reached iface method: %s\n", sig)
|
fmt.Fprintf(d.ctxt.Bso, "reached iface method: %s\n", sig)
|
||||||
}
|
}
|
||||||
|
|
@ -315,7 +315,7 @@ func (d *deadcodepass) flood() {
|
||||||
// Decode runtime type information for type methods
|
// Decode runtime type information for type methods
|
||||||
// to help work out which methods can be called
|
// to help work out which methods can be called
|
||||||
// dynamically via interfaces.
|
// dynamically via interfaces.
|
||||||
methodsigs := decodetype_methods(d.ctxt.Arch, s)
|
methodsigs := decodetypeMethods(d.ctxt.Arch, s)
|
||||||
if len(methods) != len(methodsigs) {
|
if len(methods) != len(methodsigs) {
|
||||||
panic(fmt.Sprintf("%q has %d method relocations for %d methods", s.Name, len(methods), len(methodsigs)))
|
panic(fmt.Sprintf("%q has %d method relocations for %d methods", s.Name, len(methods), len(methodsigs)))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ const (
|
||||||
tflagExtraStar = 1 << 1
|
tflagExtraStar = 1 << 1
|
||||||
)
|
)
|
||||||
|
|
||||||
func decode_reloc(s *Symbol, off int32) *Reloc {
|
func decodeReloc(s *Symbol, off int32) *Reloc {
|
||||||
for i := range s.R {
|
for i := range s.R {
|
||||||
if s.R[i].Off == off {
|
if s.R[i].Off == off {
|
||||||
return &s.R[i]
|
return &s.R[i]
|
||||||
|
|
@ -37,15 +37,15 @@ func decode_reloc(s *Symbol, off int32) *Reloc {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decode_reloc_sym(s *Symbol, off int32) *Symbol {
|
func decodeRelocSym(s *Symbol, off int32) *Symbol {
|
||||||
r := decode_reloc(s, off)
|
r := decodeReloc(s, off)
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return r.Sym
|
return r.Sym
|
||||||
}
|
}
|
||||||
|
|
||||||
func decode_inuxi(arch *sys.Arch, p []byte, sz int) uint64 {
|
func decodeInuxi(arch *sys.Arch, p []byte, sz int) uint64 {
|
||||||
switch sz {
|
switch sz {
|
||||||
case 2:
|
case 2:
|
||||||
return uint64(arch.ByteOrder.Uint16(p))
|
return uint64(arch.ByteOrder.Uint16(p))
|
||||||
|
|
@ -64,27 +64,27 @@ func structfieldSize() int { return 3 * SysArch.PtrSize } // runtime.struc
|
||||||
func uncommonSize() int { return 4 + 2 + 2 + 4 + 4 } // runtime.uncommontype
|
func uncommonSize() int { return 4 + 2 + 2 + 4 + 4 } // runtime.uncommontype
|
||||||
|
|
||||||
// Type.commonType.kind
|
// Type.commonType.kind
|
||||||
func decodetype_kind(s *Symbol) uint8 {
|
func decodetypeKind(s *Symbol) uint8 {
|
||||||
return s.P[2*SysArch.PtrSize+7] & obj.KindMask // 0x13 / 0x1f
|
return s.P[2*SysArch.PtrSize+7] & obj.KindMask // 0x13 / 0x1f
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.commonType.kind
|
// Type.commonType.kind
|
||||||
func decodetype_usegcprog(s *Symbol) uint8 {
|
func decodetypeUsegcprog(s *Symbol) uint8 {
|
||||||
return s.P[2*SysArch.PtrSize+7] & obj.KindGCProg // 0x13 / 0x1f
|
return s.P[2*SysArch.PtrSize+7] & obj.KindGCProg // 0x13 / 0x1f
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.commonType.size
|
// Type.commonType.size
|
||||||
func decodetype_size(arch *sys.Arch, s *Symbol) int64 {
|
func decodetypeSize(arch *sys.Arch, s *Symbol) int64 {
|
||||||
return int64(decode_inuxi(arch, s.P, SysArch.PtrSize)) // 0x8 / 0x10
|
return int64(decodeInuxi(arch, s.P, SysArch.PtrSize)) // 0x8 / 0x10
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.commonType.ptrdata
|
// Type.commonType.ptrdata
|
||||||
func decodetype_ptrdata(arch *sys.Arch, s *Symbol) int64 {
|
func decodetypePtrdata(arch *sys.Arch, s *Symbol) int64 {
|
||||||
return int64(decode_inuxi(arch, s.P[SysArch.PtrSize:], SysArch.PtrSize)) // 0x8 / 0x10
|
return int64(decodeInuxi(arch, s.P[SysArch.PtrSize:], SysArch.PtrSize)) // 0x8 / 0x10
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.commonType.tflag
|
// Type.commonType.tflag
|
||||||
func decodetype_hasUncommon(s *Symbol) bool {
|
func decodetypeHasUncommon(s *Symbol) bool {
|
||||||
return s.P[2*SysArch.PtrSize+4]&tflagUncommon != 0
|
return s.P[2*SysArch.PtrSize+4]&tflagUncommon != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,9 +103,9 @@ func findShlibSection(ctxt *Link, path string, addr uint64) *elf.Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.commonType.gc
|
// Type.commonType.gc
|
||||||
func decodetype_gcprog(ctxt *Link, s *Symbol) []byte {
|
func decodetypeGcprog(ctxt *Link, s *Symbol) []byte {
|
||||||
if s.Type == obj.SDYNIMPORT {
|
if s.Type == obj.SDYNIMPORT {
|
||||||
addr := decodetype_gcprog_shlib(ctxt, s)
|
addr := decodetypeGcprogShlib(ctxt, s)
|
||||||
sect := findShlibSection(ctxt, s.File, addr)
|
sect := findShlibSection(ctxt, s.File, addr)
|
||||||
if sect != nil {
|
if sect != nil {
|
||||||
// A gcprog is a 4-byte uint32 indicating length, followed by
|
// A gcprog is a 4-byte uint32 indicating length, followed by
|
||||||
|
|
@ -119,25 +119,25 @@ func decodetype_gcprog(ctxt *Link, s *Symbol) []byte {
|
||||||
Exitf("cannot find gcprog for %s", s.Name)
|
Exitf("cannot find gcprog for %s", s.Name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return decode_reloc_sym(s, 2*int32(SysArch.PtrSize)+8+1*int32(SysArch.PtrSize)).P
|
return decodeRelocSym(s, 2*int32(SysArch.PtrSize)+8+1*int32(SysArch.PtrSize)).P
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_gcprog_shlib(ctxt *Link, s *Symbol) uint64 {
|
func decodetypeGcprogShlib(ctxt *Link, s *Symbol) uint64 {
|
||||||
if SysArch.Family == sys.ARM64 {
|
if SysArch.Family == sys.ARM64 {
|
||||||
for _, shlib := range ctxt.Shlibs {
|
for _, shlib := range ctxt.Shlibs {
|
||||||
if shlib.Path == s.File {
|
if shlib.Path == s.File {
|
||||||
return shlib.gcdata_addresses[s]
|
return shlib.gcdataAddresses[s]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return decode_inuxi(ctxt.Arch, s.P[2*int32(SysArch.PtrSize)+8+1*int32(SysArch.PtrSize):], SysArch.PtrSize)
|
return decodeInuxi(ctxt.Arch, s.P[2*int32(SysArch.PtrSize)+8+1*int32(SysArch.PtrSize):], SysArch.PtrSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_gcmask(ctxt *Link, s *Symbol) []byte {
|
func decodetypeGcmask(ctxt *Link, s *Symbol) []byte {
|
||||||
if s.Type == obj.SDYNIMPORT {
|
if s.Type == obj.SDYNIMPORT {
|
||||||
addr := decodetype_gcprog_shlib(ctxt, s)
|
addr := decodetypeGcprogShlib(ctxt, s)
|
||||||
ptrdata := decodetype_ptrdata(ctxt.Arch, s)
|
ptrdata := decodetypePtrdata(ctxt.Arch, s)
|
||||||
sect := findShlibSection(ctxt, s.File, addr)
|
sect := findShlibSection(ctxt, s.File, addr)
|
||||||
if sect != nil {
|
if sect != nil {
|
||||||
r := make([]byte, ptrdata/int64(SysArch.PtrSize))
|
r := make([]byte, ptrdata/int64(SysArch.PtrSize))
|
||||||
|
|
@ -147,93 +147,93 @@ func decodetype_gcmask(ctxt *Link, s *Symbol) []byte {
|
||||||
Exitf("cannot find gcmask for %s", s.Name)
|
Exitf("cannot find gcmask for %s", s.Name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
mask := decode_reloc_sym(s, 2*int32(SysArch.PtrSize)+8+1*int32(SysArch.PtrSize))
|
mask := decodeRelocSym(s, 2*int32(SysArch.PtrSize)+8+1*int32(SysArch.PtrSize))
|
||||||
return mask.P
|
return mask.P
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.ArrayType.elem and Type.SliceType.Elem
|
// Type.ArrayType.elem and Type.SliceType.Elem
|
||||||
func decodetype_arrayelem(s *Symbol) *Symbol {
|
func decodetypeArrayElem(s *Symbol) *Symbol {
|
||||||
return decode_reloc_sym(s, int32(commonsize())) // 0x1c / 0x30
|
return decodeRelocSym(s, int32(commonsize())) // 0x1c / 0x30
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_arraylen(arch *sys.Arch, s *Symbol) int64 {
|
func decodetypeArrayLen(arch *sys.Arch, s *Symbol) int64 {
|
||||||
return int64(decode_inuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.PtrSize))
|
return int64(decodeInuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.PtrSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.PtrType.elem
|
// Type.PtrType.elem
|
||||||
func decodetype_ptrelem(s *Symbol) *Symbol {
|
func decodetypePtrElem(s *Symbol) *Symbol {
|
||||||
return decode_reloc_sym(s, int32(commonsize())) // 0x1c / 0x30
|
return decodeRelocSym(s, int32(commonsize())) // 0x1c / 0x30
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.MapType.key, elem
|
// Type.MapType.key, elem
|
||||||
func decodetype_mapkey(s *Symbol) *Symbol {
|
func decodetypeMapKey(s *Symbol) *Symbol {
|
||||||
return decode_reloc_sym(s, int32(commonsize())) // 0x1c / 0x30
|
return decodeRelocSym(s, int32(commonsize())) // 0x1c / 0x30
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_mapvalue(s *Symbol) *Symbol {
|
func decodetypeMapValue(s *Symbol) *Symbol {
|
||||||
return decode_reloc_sym(s, int32(commonsize())+int32(SysArch.PtrSize)) // 0x20 / 0x38
|
return decodeRelocSym(s, int32(commonsize())+int32(SysArch.PtrSize)) // 0x20 / 0x38
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.ChanType.elem
|
// Type.ChanType.elem
|
||||||
func decodetype_chanelem(s *Symbol) *Symbol {
|
func decodetypeChanElem(s *Symbol) *Symbol {
|
||||||
return decode_reloc_sym(s, int32(commonsize())) // 0x1c / 0x30
|
return decodeRelocSym(s, int32(commonsize())) // 0x1c / 0x30
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.FuncType.dotdotdot
|
// Type.FuncType.dotdotdot
|
||||||
func decodetype_funcdotdotdot(arch *sys.Arch, s *Symbol) bool {
|
func decodetypeFuncDotdotdot(arch *sys.Arch, s *Symbol) bool {
|
||||||
return uint16(decode_inuxi(arch, s.P[commonsize()+2:], 2))&(1<<15) != 0
|
return uint16(decodeInuxi(arch, s.P[commonsize()+2:], 2))&(1<<15) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.FuncType.inCount
|
// Type.FuncType.inCount
|
||||||
func decodetype_funcincount(arch *sys.Arch, s *Symbol) int {
|
func decodetypeFuncInCount(arch *sys.Arch, s *Symbol) int {
|
||||||
return int(decode_inuxi(arch, s.P[commonsize():], 2))
|
return int(decodeInuxi(arch, s.P[commonsize():], 2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_funcoutcount(arch *sys.Arch, s *Symbol) int {
|
func decodetypeFuncOutCount(arch *sys.Arch, s *Symbol) int {
|
||||||
return int(uint16(decode_inuxi(arch, s.P[commonsize()+2:], 2)) & (1<<15 - 1))
|
return int(uint16(decodeInuxi(arch, s.P[commonsize()+2:], 2)) & (1<<15 - 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_funcintype(s *Symbol, i int) *Symbol {
|
func decodetypeFuncInType(s *Symbol, i int) *Symbol {
|
||||||
uadd := commonsize() + 4
|
uadd := commonsize() + 4
|
||||||
if SysArch.PtrSize == 8 {
|
if SysArch.PtrSize == 8 {
|
||||||
uadd += 4
|
uadd += 4
|
||||||
}
|
}
|
||||||
if decodetype_hasUncommon(s) {
|
if decodetypeHasUncommon(s) {
|
||||||
uadd += uncommonSize()
|
uadd += uncommonSize()
|
||||||
}
|
}
|
||||||
return decode_reloc_sym(s, int32(uadd+i*SysArch.PtrSize))
|
return decodeRelocSym(s, int32(uadd+i*SysArch.PtrSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_funcouttype(arch *sys.Arch, s *Symbol, i int) *Symbol {
|
func decodetypeFuncOutType(arch *sys.Arch, s *Symbol, i int) *Symbol {
|
||||||
return decodetype_funcintype(s, i+decodetype_funcincount(arch, s))
|
return decodetypeFuncInType(s, i+decodetypeFuncInCount(arch, s))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.StructType.fields.Slice::length
|
// Type.StructType.fields.Slice::length
|
||||||
func decodetype_structfieldcount(arch *sys.Arch, s *Symbol) int {
|
func decodetypeStructFieldCount(arch *sys.Arch, s *Symbol) int {
|
||||||
return int(decode_inuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.IntSize))
|
return int(decodeInuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.IntSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_structfieldarrayoff(s *Symbol, i int) int {
|
func decodetypeStructFieldArrayOff(s *Symbol, i int) int {
|
||||||
off := commonsize() + 2*SysArch.PtrSize + 2*SysArch.IntSize
|
off := commonsize() + 2*SysArch.PtrSize + 2*SysArch.IntSize
|
||||||
if decodetype_hasUncommon(s) {
|
if decodetypeHasUncommon(s) {
|
||||||
off += uncommonSize()
|
off += uncommonSize()
|
||||||
}
|
}
|
||||||
off += i * structfieldSize()
|
off += i * structfieldSize()
|
||||||
return off
|
return off
|
||||||
}
|
}
|
||||||
|
|
||||||
// decodetype_str returns the contents of an rtype's str field (a nameOff).
|
// decodetypeStr returns the contents of an rtype's str field (a nameOff).
|
||||||
func decodetype_str(s *Symbol) string {
|
func decodetypeStr(s *Symbol) string {
|
||||||
str := decodetype_name(s, 4*SysArch.PtrSize+8)
|
str := decodetypeName(s, 4*SysArch.PtrSize+8)
|
||||||
if s.P[2*SysArch.PtrSize+4]&tflagExtraStar != 0 {
|
if s.P[2*SysArch.PtrSize+4]&tflagExtraStar != 0 {
|
||||||
return str[1:]
|
return str[1:]
|
||||||
}
|
}
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
// decodetype_name decodes the name from a reflect.name.
|
// decodetypeName decodes the name from a reflect.name.
|
||||||
func decodetype_name(s *Symbol, off int) string {
|
func decodetypeName(s *Symbol, off int) string {
|
||||||
r := decode_reloc(s, int32(off))
|
r := decodeReloc(s, int32(off))
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
@ -243,24 +243,24 @@ func decodetype_name(s *Symbol, off int) string {
|
||||||
return string(data[3 : 3+namelen])
|
return string(data[3 : 3+namelen])
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_structfieldname(s *Symbol, i int) string {
|
func decodetypeStructFieldName(s *Symbol, i int) string {
|
||||||
off := decodetype_structfieldarrayoff(s, i)
|
off := decodetypeStructFieldArrayOff(s, i)
|
||||||
return decodetype_name(s, off)
|
return decodetypeName(s, off)
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_structfieldtype(s *Symbol, i int) *Symbol {
|
func decodetypeStructFieldType(s *Symbol, i int) *Symbol {
|
||||||
off := decodetype_structfieldarrayoff(s, i)
|
off := decodetypeStructFieldArrayOff(s, i)
|
||||||
return decode_reloc_sym(s, int32(off+SysArch.PtrSize))
|
return decodeRelocSym(s, int32(off+SysArch.PtrSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_structfieldoffs(arch *sys.Arch, s *Symbol, i int) int64 {
|
func decodetypeStructFieldOffs(arch *sys.Arch, s *Symbol, i int) int64 {
|
||||||
off := decodetype_structfieldarrayoff(s, i)
|
off := decodetypeStructFieldArrayOff(s, i)
|
||||||
return int64(decode_inuxi(arch, s.P[off+2*SysArch.PtrSize:], SysArch.IntSize))
|
return int64(decodeInuxi(arch, s.P[off+2*SysArch.PtrSize:], SysArch.IntSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
// InterfaceType.methods.length
|
// InterfaceType.methods.length
|
||||||
func decodetype_ifacemethodcount(arch *sys.Arch, s *Symbol) int64 {
|
func decodetypeIfaceMethodCount(arch *sys.Arch, s *Symbol) int64 {
|
||||||
return int64(decode_inuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.IntSize))
|
return int64(decodeInuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.IntSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
// methodsig is a fully qualified typed method signature, like
|
// methodsig is a fully qualified typed method signature, like
|
||||||
|
|
@ -280,34 +280,34 @@ const (
|
||||||
kindMask = (1 << 5) - 1
|
kindMask = (1 << 5) - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
// decode_methodsig decodes an array of method signature information.
|
// decodeMethodSig decodes an array of method signature information.
|
||||||
// Each element of the array is size bytes. The first 4 bytes is a
|
// Each element of the array is size bytes. The first 4 bytes is a
|
||||||
// nameOff for the method name, and the next 4 bytes is a typeOff for
|
// nameOff for the method name, and the next 4 bytes is a typeOff for
|
||||||
// the function type.
|
// the function type.
|
||||||
//
|
//
|
||||||
// Conveniently this is the layout of both runtime.method and runtime.imethod.
|
// Conveniently this is the layout of both runtime.method and runtime.imethod.
|
||||||
func decode_methodsig(arch *sys.Arch, s *Symbol, off, size, count int) []methodsig {
|
func decodeMethodSig(arch *sys.Arch, s *Symbol, off, size, count int) []methodsig {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
var methods []methodsig
|
var methods []methodsig
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
buf.WriteString(decodetype_name(s, off))
|
buf.WriteString(decodetypeName(s, off))
|
||||||
mtypSym := decode_reloc_sym(s, int32(off+4))
|
mtypSym := decodeRelocSym(s, int32(off+4))
|
||||||
|
|
||||||
buf.WriteRune('(')
|
buf.WriteRune('(')
|
||||||
inCount := decodetype_funcincount(arch, mtypSym)
|
inCount := decodetypeFuncInCount(arch, mtypSym)
|
||||||
for i := 0; i < inCount; i++ {
|
for i := 0; i < inCount; i++ {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
buf.WriteString(", ")
|
buf.WriteString(", ")
|
||||||
}
|
}
|
||||||
buf.WriteString(decodetype_funcintype(mtypSym, i).Name)
|
buf.WriteString(decodetypeFuncInType(mtypSym, i).Name)
|
||||||
}
|
}
|
||||||
buf.WriteString(") (")
|
buf.WriteString(") (")
|
||||||
outCount := decodetype_funcoutcount(arch, mtypSym)
|
outCount := decodetypeFuncOutCount(arch, mtypSym)
|
||||||
for i := 0; i < outCount; i++ {
|
for i := 0; i < outCount; i++ {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
buf.WriteString(", ")
|
buf.WriteString(", ")
|
||||||
}
|
}
|
||||||
buf.WriteString(decodetype_funcouttype(arch, mtypSym, i).Name)
|
buf.WriteString(decodetypeFuncOutType(arch, mtypSym, i).Name)
|
||||||
}
|
}
|
||||||
buf.WriteRune(')')
|
buf.WriteRune(')')
|
||||||
|
|
||||||
|
|
@ -318,11 +318,11 @@ func decode_methodsig(arch *sys.Arch, s *Symbol, off, size, count int) []methods
|
||||||
return methods
|
return methods
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_ifacemethods(arch *sys.Arch, s *Symbol) []methodsig {
|
func decodeIfaceMethods(arch *sys.Arch, s *Symbol) []methodsig {
|
||||||
if decodetype_kind(s)&kindMask != kindInterface {
|
if decodetypeKind(s)&kindMask != kindInterface {
|
||||||
panic(fmt.Sprintf("symbol %q is not an interface", s.Name))
|
panic(fmt.Sprintf("symbol %q is not an interface", s.Name))
|
||||||
}
|
}
|
||||||
r := decode_reloc(s, int32(commonsize()+SysArch.PtrSize))
|
r := decodeReloc(s, int32(commonsize()+SysArch.PtrSize))
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -330,17 +330,17 @@ func decodetype_ifacemethods(arch *sys.Arch, s *Symbol) []methodsig {
|
||||||
panic(fmt.Sprintf("imethod slice pointer in %q leads to a different symbol", s.Name))
|
panic(fmt.Sprintf("imethod slice pointer in %q leads to a different symbol", s.Name))
|
||||||
}
|
}
|
||||||
off := int(r.Add) // array of reflect.imethod values
|
off := int(r.Add) // array of reflect.imethod values
|
||||||
numMethods := int(decodetype_ifacemethodcount(arch, s))
|
numMethods := int(decodetypeIfaceMethodCount(arch, s))
|
||||||
sizeofIMethod := 4 + 4
|
sizeofIMethod := 4 + 4
|
||||||
return decode_methodsig(arch, s, off, sizeofIMethod, numMethods)
|
return decodeMethodSig(arch, s, off, sizeofIMethod, numMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodetype_methods(arch *sys.Arch, s *Symbol) []methodsig {
|
func decodetypeMethods(arch *sys.Arch, s *Symbol) []methodsig {
|
||||||
if !decodetype_hasUncommon(s) {
|
if !decodetypeHasUncommon(s) {
|
||||||
panic(fmt.Sprintf("no methods on %q", s.Name))
|
panic(fmt.Sprintf("no methods on %q", s.Name))
|
||||||
}
|
}
|
||||||
off := commonsize() // reflect.rtype
|
off := commonsize() // reflect.rtype
|
||||||
switch decodetype_kind(s) & kindMask {
|
switch decodetypeKind(s) & kindMask {
|
||||||
case kindStruct: // reflect.structType
|
case kindStruct: // reflect.structType
|
||||||
off += 2*SysArch.PtrSize + 2*SysArch.IntSize
|
off += 2*SysArch.PtrSize + 2*SysArch.IntSize
|
||||||
case kindPtr: // reflect.ptrType
|
case kindPtr: // reflect.ptrType
|
||||||
|
|
@ -361,9 +361,9 @@ func decodetype_methods(arch *sys.Arch, s *Symbol) []methodsig {
|
||||||
// just Sizeof(rtype)
|
// just Sizeof(rtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
mcount := int(decode_inuxi(arch, s.P[off+4:], 2))
|
mcount := int(decodeInuxi(arch, s.P[off+4:], 2))
|
||||||
moff := int(decode_inuxi(arch, s.P[off+4+2+2:], 4))
|
moff := int(decodeInuxi(arch, s.P[off+4+2+2:], 4))
|
||||||
off += moff // offset to array of reflect.method values
|
off += moff // offset to array of reflect.method values
|
||||||
const sizeofMethod = 4 * 4 // sizeof reflect.method in program
|
const sizeofMethod = 4 * 4 // sizeof reflect.method in program
|
||||||
return decode_methodsig(arch, s, off, sizeofMethod, mcount)
|
return decodeMethodSig(arch, s, off, sizeofMethod, mcount)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,7 @@ func newabslocexprattr(die *dwarf.DWDie, addr int64, sym *Symbol) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup predefined types
|
// Lookup predefined types
|
||||||
func lookup_or_diag(ctxt *Link, n string) *Symbol {
|
func lookupOrDiag(ctxt *Link, n string) *Symbol {
|
||||||
s := Linkrlookup(ctxt, n, 0)
|
s := Linkrlookup(ctxt, n, 0)
|
||||||
if s == nil || s.Size == 0 {
|
if s == nil || s.Size == 0 {
|
||||||
Exitf("dwarf: missing type: %s", n)
|
Exitf("dwarf: missing type: %s", n)
|
||||||
|
|
@ -376,8 +376,8 @@ func defgotype(ctxt *Link, gotype *Symbol) *Symbol {
|
||||||
|
|
||||||
func newtype(ctxt *Link, gotype *Symbol) *dwarf.DWDie {
|
func newtype(ctxt *Link, gotype *Symbol) *dwarf.DWDie {
|
||||||
name := gotype.Name[5:] // could also decode from Type.string
|
name := gotype.Name[5:] // could also decode from Type.string
|
||||||
kind := decodetype_kind(gotype)
|
kind := decodetypeKind(gotype)
|
||||||
bytesize := decodetype_size(ctxt.Arch, gotype)
|
bytesize := decodetypeSize(ctxt.Arch, gotype)
|
||||||
|
|
||||||
var die *dwarf.DWDie
|
var die *dwarf.DWDie
|
||||||
switch kind {
|
switch kind {
|
||||||
|
|
@ -421,19 +421,19 @@ func newtype(ctxt *Link, gotype *Symbol) *dwarf.DWDie {
|
||||||
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_ARRAYTYPE, name, 0)
|
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_ARRAYTYPE, name, 0)
|
||||||
dotypedef(ctxt, &dwtypes, name, die)
|
dotypedef(ctxt, &dwtypes, name, die)
|
||||||
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
||||||
s := decodetype_arrayelem(gotype)
|
s := decodetypeArrayElem(gotype)
|
||||||
newrefattr(die, dwarf.DW_AT_type, defgotype(ctxt, s))
|
newrefattr(die, dwarf.DW_AT_type, defgotype(ctxt, s))
|
||||||
fld := newdie(ctxt, die, dwarf.DW_ABRV_ARRAYRANGE, "range", 0)
|
fld := newdie(ctxt, die, dwarf.DW_ABRV_ARRAYRANGE, "range", 0)
|
||||||
|
|
||||||
// use actual length not upper bound; correct for 0-length arrays.
|
// use actual length not upper bound; correct for 0-length arrays.
|
||||||
newattr(fld, dwarf.DW_AT_count, dwarf.DW_CLS_CONSTANT, decodetype_arraylen(ctxt.Arch, gotype), 0)
|
newattr(fld, dwarf.DW_AT_count, dwarf.DW_CLS_CONSTANT, decodetypeArrayLen(ctxt.Arch, gotype), 0)
|
||||||
|
|
||||||
newrefattr(fld, dwarf.DW_AT_type, mustFind(ctxt, "uintptr"))
|
newrefattr(fld, dwarf.DW_AT_type, mustFind(ctxt, "uintptr"))
|
||||||
|
|
||||||
case obj.KindChan:
|
case obj.KindChan:
|
||||||
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_CHANTYPE, name, 0)
|
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_CHANTYPE, name, 0)
|
||||||
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
||||||
s := decodetype_chanelem(gotype)
|
s := decodetypeChanElem(gotype)
|
||||||
newrefattr(die, dwarf.DW_AT_go_elem, defgotype(ctxt, s))
|
newrefattr(die, dwarf.DW_AT_go_elem, defgotype(ctxt, s))
|
||||||
// Save elem type for synthesizechantypes. We could synthesize here
|
// Save elem type for synthesizechantypes. We could synthesize here
|
||||||
// but that would change the order of DIEs we output.
|
// but that would change the order of DIEs we output.
|
||||||
|
|
@ -443,21 +443,21 @@ func newtype(ctxt *Link, gotype *Symbol) *dwarf.DWDie {
|
||||||
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_FUNCTYPE, name, 0)
|
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_FUNCTYPE, name, 0)
|
||||||
dotypedef(ctxt, &dwtypes, name, die)
|
dotypedef(ctxt, &dwtypes, name, die)
|
||||||
newrefattr(die, dwarf.DW_AT_type, mustFind(ctxt, "void"))
|
newrefattr(die, dwarf.DW_AT_type, mustFind(ctxt, "void"))
|
||||||
nfields := decodetype_funcincount(ctxt.Arch, gotype)
|
nfields := decodetypeFuncInCount(ctxt.Arch, gotype)
|
||||||
var fld *dwarf.DWDie
|
var fld *dwarf.DWDie
|
||||||
var s *Symbol
|
var s *Symbol
|
||||||
for i := 0; i < nfields; i++ {
|
for i := 0; i < nfields; i++ {
|
||||||
s = decodetype_funcintype(gotype, i)
|
s = decodetypeFuncInType(gotype, i)
|
||||||
fld = newdie(ctxt, die, dwarf.DW_ABRV_FUNCTYPEPARAM, s.Name[5:], 0)
|
fld = newdie(ctxt, die, dwarf.DW_ABRV_FUNCTYPEPARAM, s.Name[5:], 0)
|
||||||
newrefattr(fld, dwarf.DW_AT_type, defgotype(ctxt, s))
|
newrefattr(fld, dwarf.DW_AT_type, defgotype(ctxt, s))
|
||||||
}
|
}
|
||||||
|
|
||||||
if decodetype_funcdotdotdot(ctxt.Arch, gotype) {
|
if decodetypeFuncDotdotdot(ctxt.Arch, gotype) {
|
||||||
newdie(ctxt, die, dwarf.DW_ABRV_DOTDOTDOT, "...", 0)
|
newdie(ctxt, die, dwarf.DW_ABRV_DOTDOTDOT, "...", 0)
|
||||||
}
|
}
|
||||||
nfields = decodetype_funcoutcount(ctxt.Arch, gotype)
|
nfields = decodetypeFuncOutCount(ctxt.Arch, gotype)
|
||||||
for i := 0; i < nfields; i++ {
|
for i := 0; i < nfields; i++ {
|
||||||
s = decodetype_funcouttype(ctxt.Arch, gotype, i)
|
s = decodetypeFuncOutType(ctxt.Arch, gotype, i)
|
||||||
fld = newdie(ctxt, die, dwarf.DW_ABRV_FUNCTYPEPARAM, s.Name[5:], 0)
|
fld = newdie(ctxt, die, dwarf.DW_ABRV_FUNCTYPEPARAM, s.Name[5:], 0)
|
||||||
newrefattr(fld, dwarf.DW_AT_type, defptrto(ctxt, defgotype(ctxt, s)))
|
newrefattr(fld, dwarf.DW_AT_type, defptrto(ctxt, defgotype(ctxt, s)))
|
||||||
}
|
}
|
||||||
|
|
@ -466,20 +466,20 @@ func newtype(ctxt *Link, gotype *Symbol) *dwarf.DWDie {
|
||||||
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_IFACETYPE, name, 0)
|
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_IFACETYPE, name, 0)
|
||||||
dotypedef(ctxt, &dwtypes, name, die)
|
dotypedef(ctxt, &dwtypes, name, die)
|
||||||
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
||||||
nfields := int(decodetype_ifacemethodcount(ctxt.Arch, gotype))
|
nfields := int(decodetypeIfaceMethodCount(ctxt.Arch, gotype))
|
||||||
var s *Symbol
|
var s *Symbol
|
||||||
if nfields == 0 {
|
if nfields == 0 {
|
||||||
s = lookup_or_diag(ctxt, "type.runtime.eface")
|
s = lookupOrDiag(ctxt, "type.runtime.eface")
|
||||||
} else {
|
} else {
|
||||||
s = lookup_or_diag(ctxt, "type.runtime.iface")
|
s = lookupOrDiag(ctxt, "type.runtime.iface")
|
||||||
}
|
}
|
||||||
newrefattr(die, dwarf.DW_AT_type, defgotype(ctxt, s))
|
newrefattr(die, dwarf.DW_AT_type, defgotype(ctxt, s))
|
||||||
|
|
||||||
case obj.KindMap:
|
case obj.KindMap:
|
||||||
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_MAPTYPE, name, 0)
|
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_MAPTYPE, name, 0)
|
||||||
s := decodetype_mapkey(gotype)
|
s := decodetypeMapKey(gotype)
|
||||||
newrefattr(die, dwarf.DW_AT_go_key, defgotype(ctxt, s))
|
newrefattr(die, dwarf.DW_AT_go_key, defgotype(ctxt, s))
|
||||||
s = decodetype_mapvalue(gotype)
|
s = decodetypeMapValue(gotype)
|
||||||
newrefattr(die, dwarf.DW_AT_go_elem, defgotype(ctxt, s))
|
newrefattr(die, dwarf.DW_AT_go_elem, defgotype(ctxt, s))
|
||||||
// Save gotype for use in synthesizemaptypes. We could synthesize here,
|
// Save gotype for use in synthesizemaptypes. We could synthesize here,
|
||||||
// but that would change the order of the DIEs.
|
// but that would change the order of the DIEs.
|
||||||
|
|
@ -488,14 +488,14 @@ func newtype(ctxt *Link, gotype *Symbol) *dwarf.DWDie {
|
||||||
case obj.KindPtr:
|
case obj.KindPtr:
|
||||||
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_PTRTYPE, name, 0)
|
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_PTRTYPE, name, 0)
|
||||||
dotypedef(ctxt, &dwtypes, name, die)
|
dotypedef(ctxt, &dwtypes, name, die)
|
||||||
s := decodetype_ptrelem(gotype)
|
s := decodetypePtrElem(gotype)
|
||||||
newrefattr(die, dwarf.DW_AT_type, defgotype(ctxt, s))
|
newrefattr(die, dwarf.DW_AT_type, defgotype(ctxt, s))
|
||||||
|
|
||||||
case obj.KindSlice:
|
case obj.KindSlice:
|
||||||
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_SLICETYPE, name, 0)
|
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_SLICETYPE, name, 0)
|
||||||
dotypedef(ctxt, &dwtypes, name, die)
|
dotypedef(ctxt, &dwtypes, name, die)
|
||||||
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
||||||
s := decodetype_arrayelem(gotype)
|
s := decodetypeArrayElem(gotype)
|
||||||
elem := defgotype(ctxt, s)
|
elem := defgotype(ctxt, s)
|
||||||
newrefattr(die, dwarf.DW_AT_go_elem, elem)
|
newrefattr(die, dwarf.DW_AT_go_elem, elem)
|
||||||
|
|
||||||
|
|
@ -507,19 +507,19 @@ func newtype(ctxt *Link, gotype *Symbol) *dwarf.DWDie {
|
||||||
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_STRUCTTYPE, name, 0)
|
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_STRUCTTYPE, name, 0)
|
||||||
dotypedef(ctxt, &dwtypes, name, die)
|
dotypedef(ctxt, &dwtypes, name, die)
|
||||||
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
|
||||||
nfields := decodetype_structfieldcount(ctxt.Arch, gotype)
|
nfields := decodetypeStructFieldCount(ctxt.Arch, gotype)
|
||||||
var f string
|
var f string
|
||||||
var fld *dwarf.DWDie
|
var fld *dwarf.DWDie
|
||||||
var s *Symbol
|
var s *Symbol
|
||||||
for i := 0; i < nfields; i++ {
|
for i := 0; i < nfields; i++ {
|
||||||
f = decodetype_structfieldname(gotype, i)
|
f = decodetypeStructFieldName(gotype, i)
|
||||||
s = decodetype_structfieldtype(gotype, i)
|
s = decodetypeStructFieldType(gotype, i)
|
||||||
if f == "" {
|
if f == "" {
|
||||||
f = s.Name[5:] // skip "type."
|
f = s.Name[5:] // skip "type."
|
||||||
}
|
}
|
||||||
fld = newdie(ctxt, die, dwarf.DW_ABRV_STRUCTFIELD, f, 0)
|
fld = newdie(ctxt, die, dwarf.DW_ABRV_STRUCTFIELD, f, 0)
|
||||||
newrefattr(fld, dwarf.DW_AT_type, defgotype(ctxt, s))
|
newrefattr(fld, dwarf.DW_AT_type, defgotype(ctxt, s))
|
||||||
newmemberoffsetattr(fld, int32(decodetype_structfieldoffs(ctxt.Arch, gotype, i)))
|
newmemberoffsetattr(fld, int32(decodetypeStructFieldOffs(ctxt.Arch, gotype, i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
case obj.KindUnsafePointer:
|
case obj.KindUnsafePointer:
|
||||||
|
|
@ -600,7 +600,7 @@ func substitutetype(structdie *dwarf.DWDie, field string, dwtype *Symbol) {
|
||||||
func findprotodie(ctxt *Link, name string) *dwarf.DWDie {
|
func findprotodie(ctxt *Link, name string) *dwarf.DWDie {
|
||||||
die, ok := prototypedies[name]
|
die, ok := prototypedies[name]
|
||||||
if ok && die == nil {
|
if ok && die == nil {
|
||||||
defgotype(ctxt, lookup_or_diag(ctxt, name))
|
defgotype(ctxt, lookupOrDiag(ctxt, name))
|
||||||
die = prototypedies[name]
|
die = prototypedies[name]
|
||||||
}
|
}
|
||||||
return die
|
return die
|
||||||
|
|
@ -680,20 +680,20 @@ func synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
gotype := getattr(die, dwarf.DW_AT_type).Data.(*Symbol)
|
gotype := getattr(die, dwarf.DW_AT_type).Data.(*Symbol)
|
||||||
keytype := decodetype_mapkey(gotype)
|
keytype := decodetypeMapKey(gotype)
|
||||||
valtype := decodetype_mapvalue(gotype)
|
valtype := decodetypeMapValue(gotype)
|
||||||
keysize, valsize := decodetype_size(ctxt.Arch, keytype), decodetype_size(ctxt.Arch, valtype)
|
keysize, valsize := decodetypeSize(ctxt.Arch, keytype), decodetypeSize(ctxt.Arch, valtype)
|
||||||
keytype, valtype = walksymtypedef(ctxt, defgotype(ctxt, keytype)), walksymtypedef(ctxt, defgotype(ctxt, valtype))
|
keytype, valtype = walksymtypedef(ctxt, defgotype(ctxt, keytype)), walksymtypedef(ctxt, defgotype(ctxt, valtype))
|
||||||
|
|
||||||
// compute size info like hashmap.c does.
|
// compute size info like hashmap.c does.
|
||||||
indirect_key, indirect_val := false, false
|
indirectKey, indirectVal := false, false
|
||||||
if keysize > MaxKeySize {
|
if keysize > MaxKeySize {
|
||||||
keysize = int64(SysArch.PtrSize)
|
keysize = int64(SysArch.PtrSize)
|
||||||
indirect_key = true
|
indirectKey = true
|
||||||
}
|
}
|
||||||
if valsize > MaxValSize {
|
if valsize > MaxValSize {
|
||||||
valsize = int64(SysArch.PtrSize)
|
valsize = int64(SysArch.PtrSize)
|
||||||
indirect_val = true
|
indirectVal = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct type to represent an array of BucketSize keys
|
// Construct type to represent an array of BucketSize keys
|
||||||
|
|
@ -701,7 +701,7 @@ func synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) {
|
||||||
dwhks := mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]key", keyname, "", func(dwhk *dwarf.DWDie) {
|
dwhks := mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]key", keyname, "", func(dwhk *dwarf.DWDie) {
|
||||||
newattr(dwhk, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, BucketSize*keysize, 0)
|
newattr(dwhk, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, BucketSize*keysize, 0)
|
||||||
t := keytype
|
t := keytype
|
||||||
if indirect_key {
|
if indirectKey {
|
||||||
t = defptrto(ctxt, keytype)
|
t = defptrto(ctxt, keytype)
|
||||||
}
|
}
|
||||||
newrefattr(dwhk, dwarf.DW_AT_type, t)
|
newrefattr(dwhk, dwarf.DW_AT_type, t)
|
||||||
|
|
@ -715,7 +715,7 @@ func synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) {
|
||||||
dwhvs := mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]val", valname, "", func(dwhv *dwarf.DWDie) {
|
dwhvs := mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]val", valname, "", func(dwhv *dwarf.DWDie) {
|
||||||
newattr(dwhv, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, BucketSize*valsize, 0)
|
newattr(dwhv, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, BucketSize*valsize, 0)
|
||||||
t := valtype
|
t := valtype
|
||||||
if indirect_val {
|
if indirectVal {
|
||||||
t = defptrto(ctxt, valtype)
|
t = defptrto(ctxt, valtype)
|
||||||
}
|
}
|
||||||
newrefattr(dwhv, dwarf.DW_AT_type, t)
|
newrefattr(dwhv, dwarf.DW_AT_type, t)
|
||||||
|
|
@ -776,7 +776,7 @@ func synthesizechantypes(ctxt *Link, die *dwarf.DWDie) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
elemgotype := getattr(die, dwarf.DW_AT_type).Data.(*Symbol)
|
elemgotype := getattr(die, dwarf.DW_AT_type).Data.(*Symbol)
|
||||||
elemsize := decodetype_size(ctxt.Arch, elemgotype)
|
elemsize := decodetypeSize(ctxt.Arch, elemgotype)
|
||||||
elemname := elemgotype.Name[5:]
|
elemname := elemgotype.Name[5:]
|
||||||
elemtype := walksymtypedef(ctxt, defgotype(ctxt, elemgotype))
|
elemtype := walksymtypedef(ctxt, defgotype(ctxt, elemgotype))
|
||||||
|
|
||||||
|
|
@ -888,22 +888,22 @@ const (
|
||||||
OPCODE_BASE = 10
|
OPCODE_BASE = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
func putpclcdelta(linkctxt *Link, ctxt dwarf.Context, s *Symbol, delta_pc int64, delta_lc int64) {
|
func putpclcdelta(linkctxt *Link, ctxt dwarf.Context, s *Symbol, deltaPC int64, deltaLC int64) {
|
||||||
if LINE_BASE <= delta_lc && delta_lc < LINE_BASE+LINE_RANGE {
|
if LINE_BASE <= deltaLC && deltaLC < LINE_BASE+LINE_RANGE {
|
||||||
var opcode int64 = OPCODE_BASE + (delta_lc - LINE_BASE) + (LINE_RANGE * delta_pc)
|
var opcode int64 = OPCODE_BASE + (deltaLC - LINE_BASE) + (LINE_RANGE * deltaPC)
|
||||||
if OPCODE_BASE <= opcode && opcode < 256 {
|
if OPCODE_BASE <= opcode && opcode < 256 {
|
||||||
Adduint8(linkctxt, s, uint8(opcode))
|
Adduint8(linkctxt, s, uint8(opcode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if delta_pc != 0 {
|
if deltaPC != 0 {
|
||||||
Adduint8(linkctxt, s, dwarf.DW_LNS_advance_pc)
|
Adduint8(linkctxt, s, dwarf.DW_LNS_advance_pc)
|
||||||
dwarf.Sleb128put(ctxt, s, delta_pc)
|
dwarf.Sleb128put(ctxt, s, deltaPC)
|
||||||
}
|
}
|
||||||
|
|
||||||
Adduint8(linkctxt, s, dwarf.DW_LNS_advance_line)
|
Adduint8(linkctxt, s, dwarf.DW_LNS_advance_line)
|
||||||
dwarf.Sleb128put(ctxt, s, delta_lc)
|
dwarf.Sleb128put(ctxt, s, deltaLC)
|
||||||
Adduint8(linkctxt, s, dwarf.DW_LNS_copy)
|
Adduint8(linkctxt, s, dwarf.DW_LNS_copy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -951,11 +951,11 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) {
|
||||||
|
|
||||||
// Write .debug_line Line Number Program Header (sec 6.2.4)
|
// Write .debug_line Line Number Program Header (sec 6.2.4)
|
||||||
// Fields marked with (*) must be changed for 64-bit dwarf
|
// Fields marked with (*) must be changed for 64-bit dwarf
|
||||||
unit_length_offset := ls.Size
|
unitLengthOffset := ls.Size
|
||||||
Adduint32(ctxt, ls, 0) // unit_length (*), filled in at end.
|
Adduint32(ctxt, ls, 0) // unit_length (*), filled in at end.
|
||||||
unitstart = ls.Size
|
unitstart = ls.Size
|
||||||
Adduint16(ctxt, ls, 2) // dwarf version (appendix F)
|
Adduint16(ctxt, ls, 2) // dwarf version (appendix F)
|
||||||
header_length_offset := ls.Size
|
headerLengthOffset := ls.Size
|
||||||
Adduint32(ctxt, ls, 0) // header_length (*), filled in at end.
|
Adduint32(ctxt, ls, 0) // header_length (*), filled in at end.
|
||||||
headerstart = ls.Size
|
headerstart = ls.Size
|
||||||
|
|
||||||
|
|
@ -1065,8 +1065,8 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) {
|
||||||
|
|
||||||
newattr(dwinfo, dwarf.DW_AT_high_pc, dwarf.DW_CLS_ADDRESS, epc+1, epcs)
|
newattr(dwinfo, dwarf.DW_AT_high_pc, dwarf.DW_CLS_ADDRESS, epc+1, epcs)
|
||||||
|
|
||||||
setuint32(ctxt, ls, unit_length_offset, uint32(ls.Size-unitstart))
|
setuint32(ctxt, ls, unitLengthOffset, uint32(ls.Size-unitstart))
|
||||||
setuint32(ctxt, ls, header_length_offset, uint32(headerend-headerstart))
|
setuint32(ctxt, ls, headerLengthOffset, uint32(headerend-headerstart))
|
||||||
|
|
||||||
return syms, funcs
|
return syms, funcs
|
||||||
}
|
}
|
||||||
|
|
@ -1444,10 +1444,10 @@ func dwarfgeneratedebugsyms(ctxt *Link) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed by the prettyprinter code for interface inspection.
|
// Needed by the prettyprinter code for interface inspection.
|
||||||
defgotype(ctxt, lookup_or_diag(ctxt, "type.runtime._type"))
|
defgotype(ctxt, lookupOrDiag(ctxt, "type.runtime._type"))
|
||||||
|
|
||||||
defgotype(ctxt, lookup_or_diag(ctxt, "type.runtime.interfacetype"))
|
defgotype(ctxt, lookupOrDiag(ctxt, "type.runtime.interfacetype"))
|
||||||
defgotype(ctxt, lookup_or_diag(ctxt, "type.runtime.itab"))
|
defgotype(ctxt, lookupOrDiag(ctxt, "type.runtime.itab"))
|
||||||
|
|
||||||
genasmsym(ctxt, defdwsymb)
|
genasmsym(ctxt, defdwsymb)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,10 @@ import (
|
||||||
* padded to a word boundary. The values of n_namesz and n_descsz do
|
* padded to a word boundary. The values of n_namesz and n_descsz do
|
||||||
* not include the padding.
|
* not include the padding.
|
||||||
*/
|
*/
|
||||||
type Elf_Note struct {
|
type elfNote struct {
|
||||||
n_namesz uint32
|
nNamesz uint32
|
||||||
n_descsz uint32
|
nDescsz uint32
|
||||||
n_type uint32
|
nType uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -309,13 +309,13 @@ type ElfSym struct {
|
||||||
var ElfMagic = [4]uint8{0x7F, 'E', 'L', 'F'}
|
var ElfMagic = [4]uint8{0x7F, 'E', 'L', 'F'}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Tag_file = 1
|
TagFile = 1
|
||||||
Tag_CPU_name = 4
|
TagCPUName = 4
|
||||||
Tag_CPU_raw_name = 5
|
TagCPURawName = 5
|
||||||
Tag_compatibility = 32
|
TagCompatibility = 32
|
||||||
Tag_nodefaults = 64
|
TagNoDefaults = 64
|
||||||
Tag_also_compatible_with = 65
|
TagAlsoCompatibleWith = 65
|
||||||
Tag_ABI_VFP_args = 28
|
TagABIVFPArgs = 28
|
||||||
)
|
)
|
||||||
|
|
||||||
type elfAttribute struct {
|
type elfAttribute struct {
|
||||||
|
|
@ -356,7 +356,7 @@ func (a *elfAttributeList) uleb128() uint64 {
|
||||||
func (a *elfAttributeList) armAttr() elfAttribute {
|
func (a *elfAttributeList) armAttr() elfAttribute {
|
||||||
attr := elfAttribute{tag: a.uleb128()}
|
attr := elfAttribute{tag: a.uleb128()}
|
||||||
switch {
|
switch {
|
||||||
case attr.tag == Tag_compatibility:
|
case attr.tag == TagCompatibility:
|
||||||
attr.ival = a.uleb128()
|
attr.ival = a.uleb128()
|
||||||
attr.sval = a.string()
|
attr.sval = a.string()
|
||||||
|
|
||||||
|
|
@ -367,7 +367,7 @@ func (a *elfAttributeList) armAttr() elfAttribute {
|
||||||
attr.sval = a.string()
|
attr.sval = a.string()
|
||||||
|
|
||||||
// Tag with string argument
|
// Tag with string argument
|
||||||
case attr.tag == Tag_CPU_name || attr.tag == Tag_CPU_raw_name || (attr.tag >= 32 && attr.tag&1 != 0):
|
case attr.tag == TagCPUName || attr.tag == TagCPURawName || (attr.tag >= 32 && attr.tag&1 != 0):
|
||||||
attr.sval = a.string()
|
attr.sval = a.string()
|
||||||
|
|
||||||
default: // Tag with integer argument
|
default: // Tag with integer argument
|
||||||
|
|
@ -421,11 +421,11 @@ func parseArmAttributes(ctxt *Link, e binary.ByteOrder, data []byte) {
|
||||||
subsectiondata := sectiondata[sz+4 : subsectionsize]
|
subsectiondata := sectiondata[sz+4 : subsectionsize]
|
||||||
sectiondata = sectiondata[subsectionsize:]
|
sectiondata = sectiondata[subsectionsize:]
|
||||||
|
|
||||||
if subsectiontag == Tag_file {
|
if subsectiontag == TagFile {
|
||||||
attrList := elfAttributeList{data: subsectiondata}
|
attrList := elfAttributeList{data: subsectiondata}
|
||||||
for !attrList.done() {
|
for !attrList.done() {
|
||||||
attr := attrList.armAttr()
|
attr := attrList.armAttr()
|
||||||
if attr.tag == Tag_ABI_VFP_args && attr.ival == 1 {
|
if attr.tag == TagABIVFPArgs && attr.ival == 1 {
|
||||||
ehdr.flags = 0x5000402 // has entry point, Version5 EABI, hard-float ABI
|
ehdr.flags = 0x5000402 // has entry point, Version5 EABI, hard-float ABI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ const (
|
||||||
N_STAB = 0xe0
|
N_STAB = 0xe0
|
||||||
)
|
)
|
||||||
|
|
||||||
type LdMachoObj struct {
|
type ldMachoObj struct {
|
||||||
f *bio.Reader
|
f *bio.Reader
|
||||||
base int64 // off in f where Mach-O begins
|
base int64 // off in f where Mach-O begins
|
||||||
length int64 // length of Mach-O
|
length int64 // length of Mach-O
|
||||||
|
|
@ -54,20 +54,20 @@ type LdMachoObj struct {
|
||||||
subcputype uint
|
subcputype uint
|
||||||
filetype uint32
|
filetype uint32
|
||||||
flags uint32
|
flags uint32
|
||||||
cmd []LdMachoCmd
|
cmd []ldMachoCmd
|
||||||
ncmd uint
|
ncmd uint
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdMachoCmd struct {
|
type ldMachoCmd struct {
|
||||||
type_ int
|
type_ int
|
||||||
off uint32
|
off uint32
|
||||||
size uint32
|
size uint32
|
||||||
seg LdMachoSeg
|
seg ldMachoSeg
|
||||||
sym LdMachoSymtab
|
sym ldMachoSymtab
|
||||||
dsym LdMachoDysymtab
|
dsym ldMachoDysymtab
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdMachoSeg struct {
|
type ldMachoSeg struct {
|
||||||
name string
|
name string
|
||||||
vmaddr uint64
|
vmaddr uint64
|
||||||
vmsize uint64
|
vmsize uint64
|
||||||
|
|
@ -77,10 +77,10 @@ type LdMachoSeg struct {
|
||||||
initprot uint32
|
initprot uint32
|
||||||
nsect uint32
|
nsect uint32
|
||||||
flags uint32
|
flags uint32
|
||||||
sect []LdMachoSect
|
sect []ldMachoSect
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdMachoSect struct {
|
type ldMachoSect struct {
|
||||||
name string
|
name string
|
||||||
segname string
|
segname string
|
||||||
addr uint64
|
addr uint64
|
||||||
|
|
@ -93,10 +93,10 @@ type LdMachoSect struct {
|
||||||
res1 uint32
|
res1 uint32
|
||||||
res2 uint32
|
res2 uint32
|
||||||
sym *Symbol
|
sym *Symbol
|
||||||
rel []LdMachoRel
|
rel []ldMachoRel
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdMachoRel struct {
|
type ldMachoRel struct {
|
||||||
addr uint32
|
addr uint32
|
||||||
symnum uint32
|
symnum uint32
|
||||||
pcrel uint8
|
pcrel uint8
|
||||||
|
|
@ -107,16 +107,16 @@ type LdMachoRel struct {
|
||||||
value uint32
|
value uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdMachoSymtab struct {
|
type ldMachoSymtab struct {
|
||||||
symoff uint32
|
symoff uint32
|
||||||
nsym uint32
|
nsym uint32
|
||||||
stroff uint32
|
stroff uint32
|
||||||
strsize uint32
|
strsize uint32
|
||||||
str []byte
|
str []byte
|
||||||
sym []LdMachoSym
|
sym []ldMachoSym
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdMachoSym struct {
|
type ldMachoSym struct {
|
||||||
name string
|
name string
|
||||||
type_ uint8
|
type_ uint8
|
||||||
sectnum uint8
|
sectnum uint8
|
||||||
|
|
@ -126,7 +126,7 @@ type LdMachoSym struct {
|
||||||
sym *Symbol
|
sym *Symbol
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdMachoDysymtab struct {
|
type ldMachoDysymtab struct {
|
||||||
ilocalsym uint32
|
ilocalsym uint32
|
||||||
nlocalsym uint32
|
nlocalsym uint32
|
||||||
iextdefsym uint32
|
iextdefsym uint32
|
||||||
|
|
@ -175,7 +175,7 @@ const (
|
||||||
LdMachoFilePreload = 5
|
LdMachoFilePreload = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
func unpackcmd(p []byte, m *LdMachoObj, c *LdMachoCmd, type_ uint, sz uint) int {
|
func unpackcmd(p []byte, m *ldMachoObj, c *ldMachoCmd, type_ uint, sz uint) int {
|
||||||
e4 := m.e.Uint32
|
e4 := m.e.Uint32
|
||||||
e8 := m.e.Uint64
|
e8 := m.e.Uint64
|
||||||
|
|
||||||
|
|
@ -198,12 +198,12 @@ func unpackcmd(p []byte, m *LdMachoObj, c *LdMachoCmd, type_ uint, sz uint) int
|
||||||
c.seg.initprot = e4(p[44:])
|
c.seg.initprot = e4(p[44:])
|
||||||
c.seg.nsect = e4(p[48:])
|
c.seg.nsect = e4(p[48:])
|
||||||
c.seg.flags = e4(p[52:])
|
c.seg.flags = e4(p[52:])
|
||||||
c.seg.sect = make([]LdMachoSect, c.seg.nsect)
|
c.seg.sect = make([]ldMachoSect, c.seg.nsect)
|
||||||
if uint32(sz) < 56+c.seg.nsect*68 {
|
if uint32(sz) < 56+c.seg.nsect*68 {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
p = p[56:]
|
p = p[56:]
|
||||||
var s *LdMachoSect
|
var s *ldMachoSect
|
||||||
for i := 0; uint32(i) < c.seg.nsect; i++ {
|
for i := 0; uint32(i) < c.seg.nsect; i++ {
|
||||||
s = &c.seg.sect[i]
|
s = &c.seg.sect[i]
|
||||||
s.name = cstring(p[0:16])
|
s.name = cstring(p[0:16])
|
||||||
|
|
@ -233,12 +233,12 @@ func unpackcmd(p []byte, m *LdMachoObj, c *LdMachoCmd, type_ uint, sz uint) int
|
||||||
c.seg.initprot = e4(p[60:])
|
c.seg.initprot = e4(p[60:])
|
||||||
c.seg.nsect = e4(p[64:])
|
c.seg.nsect = e4(p[64:])
|
||||||
c.seg.flags = e4(p[68:])
|
c.seg.flags = e4(p[68:])
|
||||||
c.seg.sect = make([]LdMachoSect, c.seg.nsect)
|
c.seg.sect = make([]ldMachoSect, c.seg.nsect)
|
||||||
if uint32(sz) < 72+c.seg.nsect*80 {
|
if uint32(sz) < 72+c.seg.nsect*80 {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
p = p[72:]
|
p = p[72:]
|
||||||
var s *LdMachoSect
|
var s *ldMachoSect
|
||||||
for i := 0; uint32(i) < c.seg.nsect; i++ {
|
for i := 0; uint32(i) < c.seg.nsect; i++ {
|
||||||
s = &c.seg.sect[i]
|
s = &c.seg.sect[i]
|
||||||
s.name = cstring(p[0:16])
|
s.name = cstring(p[0:16])
|
||||||
|
|
@ -293,11 +293,11 @@ func unpackcmd(p []byte, m *LdMachoObj, c *LdMachoCmd, type_ uint, sz uint) int
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func macholoadrel(m *LdMachoObj, sect *LdMachoSect) int {
|
func macholoadrel(m *ldMachoObj, sect *ldMachoSect) int {
|
||||||
if sect.rel != nil || sect.nreloc == 0 {
|
if sect.rel != nil || sect.nreloc == 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
rel := make([]LdMachoRel, sect.nreloc)
|
rel := make([]ldMachoRel, sect.nreloc)
|
||||||
n := int(sect.nreloc * 8)
|
n := int(sect.nreloc * 8)
|
||||||
buf := make([]byte, n)
|
buf := make([]byte, n)
|
||||||
if m.f.Seek(m.base+int64(sect.reloff), 0) < 0 {
|
if m.f.Seek(m.base+int64(sect.reloff), 0) < 0 {
|
||||||
|
|
@ -307,7 +307,7 @@ func macholoadrel(m *LdMachoObj, sect *LdMachoSect) int {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
var p []byte
|
var p []byte
|
||||||
var r *LdMachoRel
|
var r *ldMachoRel
|
||||||
var v uint32
|
var v uint32
|
||||||
for i := 0; uint32(i) < sect.nreloc; i++ {
|
for i := 0; uint32(i) < sect.nreloc; i++ {
|
||||||
r = &rel[i]
|
r = &rel[i]
|
||||||
|
|
@ -345,7 +345,7 @@ func macholoadrel(m *LdMachoObj, sect *LdMachoSect) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func macholoaddsym(m *LdMachoObj, d *LdMachoDysymtab) int {
|
func macholoaddsym(m *ldMachoObj, d *ldMachoDysymtab) int {
|
||||||
n := int(d.nindirectsyms)
|
n := int(d.nindirectsyms)
|
||||||
|
|
||||||
p := make([]byte, n*4)
|
p := make([]byte, n*4)
|
||||||
|
|
@ -363,7 +363,7 @@ func macholoaddsym(m *LdMachoObj, d *LdMachoDysymtab) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func macholoadsym(m *LdMachoObj, symtab *LdMachoSymtab) int {
|
func macholoadsym(m *ldMachoObj, symtab *ldMachoSymtab) int {
|
||||||
if symtab.sym != nil {
|
if symtab.sym != nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
@ -388,9 +388,9 @@ func macholoadsym(m *LdMachoObj, symtab *LdMachoSymtab) int {
|
||||||
if _, err := io.ReadFull(m.f, symbuf); err != nil {
|
if _, err := io.ReadFull(m.f, symbuf); err != nil {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
sym := make([]LdMachoSym, symtab.nsym)
|
sym := make([]ldMachoSym, symtab.nsym)
|
||||||
p := symbuf
|
p := symbuf
|
||||||
var s *LdMachoSym
|
var s *ldMachoSym
|
||||||
var v uint32
|
var v uint32
|
||||||
for i := 0; uint32(i) < symtab.nsym; i++ {
|
for i := 0; uint32(i) < symtab.nsym; i++ {
|
||||||
s = &sym[i]
|
s = &sym[i]
|
||||||
|
|
@ -428,18 +428,18 @@ func ldmacho(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
|
||||||
var ty uint32
|
var ty uint32
|
||||||
var sz uint32
|
var sz uint32
|
||||||
var off uint32
|
var off uint32
|
||||||
var m *LdMachoObj
|
var m *ldMachoObj
|
||||||
var e binary.ByteOrder
|
var e binary.ByteOrder
|
||||||
var sect *LdMachoSect
|
var sect *ldMachoSect
|
||||||
var rel *LdMachoRel
|
var rel *ldMachoRel
|
||||||
var rpi int
|
var rpi int
|
||||||
var s *Symbol
|
var s *Symbol
|
||||||
var s1 *Symbol
|
var s1 *Symbol
|
||||||
var outer *Symbol
|
var outer *Symbol
|
||||||
var c *LdMachoCmd
|
var c *ldMachoCmd
|
||||||
var symtab *LdMachoSymtab
|
var symtab *ldMachoSymtab
|
||||||
var dsymtab *LdMachoDysymtab
|
var dsymtab *ldMachoDysymtab
|
||||||
var sym *LdMachoSym
|
var sym *ldMachoSym
|
||||||
var r []Reloc
|
var r []Reloc
|
||||||
var rp *Reloc
|
var rp *Reloc
|
||||||
var name string
|
var name string
|
||||||
|
|
@ -471,7 +471,7 @@ func ldmacho(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
|
||||||
f.Seek(4, 1) // skip reserved word in header
|
f.Seek(4, 1) // skip reserved word in header
|
||||||
}
|
}
|
||||||
|
|
||||||
m = new(LdMachoObj)
|
m = new(ldMachoObj)
|
||||||
|
|
||||||
m.f = f
|
m.f = f
|
||||||
m.e = e
|
m.e = e
|
||||||
|
|
@ -503,7 +503,7 @@ func ldmacho(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.cmd = make([]LdMachoCmd, ncmd)
|
m.cmd = make([]ldMachoCmd, ncmd)
|
||||||
off = uint32(len(hdr))
|
off = uint32(len(hdr))
|
||||||
cmdp = make([]byte, cmdsz)
|
cmdp = make([]byte, cmdsz)
|
||||||
if _, err2 := io.ReadFull(f, cmdp); err2 != nil {
|
if _, err2 := io.ReadFull(f, cmdp); err2 != nil {
|
||||||
|
|
@ -778,7 +778,7 @@ func ldmacho(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
|
||||||
|
|
||||||
// now consider the desired symbol.
|
// now consider the desired symbol.
|
||||||
// find the section where it lives.
|
// find the section where it lives.
|
||||||
var ks *LdMachoSect
|
var ks *ldMachoSect
|
||||||
for k := 0; uint32(k) < c.seg.nsect; k++ {
|
for k := 0; uint32(k) < c.seg.nsect; k++ {
|
||||||
ks = &c.seg.sect[k]
|
ks = &c.seg.sect[k]
|
||||||
if ks.addr <= uint64(rel.value) && uint64(rel.value) < ks.addr+ks.size {
|
if ks.addr <= uint64(rel.value) && uint64(rel.value) < ks.addr+ks.size {
|
||||||
|
|
|
||||||
|
|
@ -1416,7 +1416,7 @@ func ldshlibsyms(ctxt *Link, shlib string) {
|
||||||
ctxt.Diag("cannot read symbols from shared library: %s", libpath)
|
ctxt.Diag("cannot read symbols from shared library: %s", libpath)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gcdata_locations := make(map[uint64]*Symbol)
|
gcdataLocations := make(map[uint64]*Symbol)
|
||||||
for _, elfsym := range syms {
|
for _, elfsym := range syms {
|
||||||
if elf.ST_TYPE(elfsym.Info) == elf.STT_NOTYPE || elf.ST_TYPE(elfsym.Info) == elf.STT_SECTION {
|
if elf.ST_TYPE(elfsym.Info) == elf.STT_NOTYPE || elf.ST_TYPE(elfsym.Info) == elf.STT_SECTION {
|
||||||
continue
|
continue
|
||||||
|
|
@ -1439,11 +1439,11 @@ func ldshlibsyms(ctxt *Link, shlib string) {
|
||||||
// the type data.
|
// the type data.
|
||||||
if strings.HasPrefix(lsym.Name, "type.") && !strings.HasPrefix(lsym.Name, "type..") {
|
if strings.HasPrefix(lsym.Name, "type.") && !strings.HasPrefix(lsym.Name, "type..") {
|
||||||
lsym.P = readelfsymboldata(ctxt, f, &elfsym)
|
lsym.P = readelfsymboldata(ctxt, f, &elfsym)
|
||||||
gcdata_locations[elfsym.Value+2*uint64(SysArch.PtrSize)+8+1*uint64(SysArch.PtrSize)] = lsym
|
gcdataLocations[elfsym.Value+2*uint64(SysArch.PtrSize)+8+1*uint64(SysArch.PtrSize)] = lsym
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gcdata_addresses := make(map[*Symbol]uint64)
|
gcdataAddresses := make(map[*Symbol]uint64)
|
||||||
if SysArch.Family == sys.ARM64 {
|
if SysArch.Family == sys.ARM64 {
|
||||||
for _, sect := range f.Sections {
|
for _, sect := range f.Sections {
|
||||||
if sect.Type == elf.SHT_RELA {
|
if sect.Type == elf.SHT_RELA {
|
||||||
|
|
@ -1461,8 +1461,8 @@ func ldshlibsyms(ctxt *Link, shlib string) {
|
||||||
if t != elf.R_AARCH64_RELATIVE {
|
if t != elf.R_AARCH64_RELATIVE {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if lsym, ok := gcdata_locations[rela.Off]; ok {
|
if lsym, ok := gcdataLocations[rela.Off]; ok {
|
||||||
gcdata_addresses[lsym] = uint64(rela.Addend)
|
gcdataAddresses[lsym] = uint64(rela.Addend)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1480,7 +1480,7 @@ func ldshlibsyms(ctxt *Link, shlib string) {
|
||||||
}
|
}
|
||||||
ctxt.Textp = textp
|
ctxt.Textp = textp
|
||||||
|
|
||||||
ctxt.Shlibs = append(ctxt.Shlibs, Shlib{Path: libpath, Hash: hash, Deps: deps, File: f, gcdata_addresses: gcdata_addresses})
|
ctxt.Shlibs = append(ctxt.Shlibs, Shlib{Path: libpath, Hash: hash, Deps: deps, File: f, gcdataAddresses: gcdataAddresses})
|
||||||
}
|
}
|
||||||
|
|
||||||
func mywhatsys() {
|
func mywhatsys() {
|
||||||
|
|
@ -1552,9 +1552,9 @@ func Be32(b []byte) uint32 {
|
||||||
return uint32(b[0])<<24 | uint32(b[1])<<16 | uint32(b[2])<<8 | uint32(b[3])
|
return uint32(b[0])<<24 | uint32(b[1])<<16 | uint32(b[2])<<8 | uint32(b[3])
|
||||||
}
|
}
|
||||||
|
|
||||||
type Chain struct {
|
type chain struct {
|
||||||
sym *Symbol
|
sym *Symbol
|
||||||
up *Chain
|
up *chain
|
||||||
limit int // limit on entry to sym
|
limit int // limit on entry to sym
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1575,7 +1575,7 @@ func callsize(ctxt *Link) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctxt *Link) dostkcheck() {
|
func (ctxt *Link) dostkcheck() {
|
||||||
var ch Chain
|
var ch chain
|
||||||
|
|
||||||
morestack = Linklookup(ctxt, "runtime.morestack", 0)
|
morestack = Linklookup(ctxt, "runtime.morestack", 0)
|
||||||
|
|
||||||
|
|
@ -1616,7 +1616,7 @@ func (ctxt *Link) dostkcheck() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func stkcheck(ctxt *Link, up *Chain, depth int) int {
|
func stkcheck(ctxt *Link, up *chain, depth int) int {
|
||||||
limit := up.limit
|
limit := up.limit
|
||||||
s := up.sym
|
s := up.sym
|
||||||
|
|
||||||
|
|
@ -1659,7 +1659,7 @@ func stkcheck(ctxt *Link, up *Chain, depth int) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var ch Chain
|
var ch chain
|
||||||
ch.up = up
|
ch.up = up
|
||||||
|
|
||||||
if !s.Attr.NoSplit() {
|
if !s.Attr.NoSplit() {
|
||||||
|
|
@ -1684,7 +1684,7 @@ func stkcheck(ctxt *Link, up *Chain, depth int) int {
|
||||||
ri := 0
|
ri := 0
|
||||||
|
|
||||||
endr := len(s.R)
|
endr := len(s.R)
|
||||||
var ch1 Chain
|
var ch1 chain
|
||||||
var pcsp Pciter
|
var pcsp Pciter
|
||||||
var r *Reloc
|
var r *Reloc
|
||||||
for pciterinit(ctxt, &pcsp, &s.FuncInfo.Pcsp); pcsp.done == 0; pciternext(&pcsp) {
|
for pciterinit(ctxt, &pcsp, &s.FuncInfo.Pcsp); pcsp.done == 0; pciternext(&pcsp) {
|
||||||
|
|
@ -1729,12 +1729,12 @@ func stkcheck(ctxt *Link, up *Chain, depth int) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func stkbroke(ctxt *Link, ch *Chain, limit int) {
|
func stkbroke(ctxt *Link, ch *chain, limit int) {
|
||||||
ctxt.Diag("nosplit stack overflow")
|
ctxt.Diag("nosplit stack overflow")
|
||||||
stkprint(ctxt, ch, limit)
|
stkprint(ctxt, ch, limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stkprint(ctxt *Link, ch *Chain, limit int) {
|
func stkprint(ctxt *Link, ch *chain, limit int) {
|
||||||
var name string
|
var name string
|
||||||
|
|
||||||
if ch.sym != nil {
|
if ch.sym != nil {
|
||||||
|
|
|
||||||
|
|
@ -151,11 +151,11 @@ type Auto struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Shlib struct {
|
type Shlib struct {
|
||||||
Path string
|
Path string
|
||||||
Hash []byte
|
Hash []byte
|
||||||
Deps []string
|
Deps []string
|
||||||
File *elf.File
|
File *elf.File
|
||||||
gcdata_addresses map[*Symbol]uint64
|
gcdataAddresses map[*Symbol]uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Link struct {
|
type Link struct {
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ var nsortsym int
|
||||||
// "big enough" header size. The initial header is
|
// "big enough" header size. The initial header is
|
||||||
// one page, the non-dynamic library stuff takes
|
// one page, the non-dynamic library stuff takes
|
||||||
// up about 1300 bytes; we overestimate that as 2k.
|
// up about 1300 bytes; we overestimate that as 2k.
|
||||||
var load_budget int = INITIAL_MACHO_HEADR - 2*1024
|
var loadBudget int = INITIAL_MACHO_HEADR - 2*1024
|
||||||
|
|
||||||
func Machoinit() {
|
func Machoinit() {
|
||||||
macho64 = SysArch.RegSize == 8
|
macho64 = SysArch.RegSize == 8
|
||||||
|
|
@ -336,12 +336,12 @@ func Machoadddynlib(lib string) {
|
||||||
// and 24 bytes of header metadata. If not enough
|
// and 24 bytes of header metadata. If not enough
|
||||||
// space, grab another page of initial space at the
|
// space, grab another page of initial space at the
|
||||||
// beginning of the output file.
|
// beginning of the output file.
|
||||||
load_budget -= (len(lib)+7)/8*8 + 24
|
loadBudget -= (len(lib)+7)/8*8 + 24
|
||||||
|
|
||||||
if load_budget < 0 {
|
if loadBudget < 0 {
|
||||||
HEADR += 4096
|
HEADR += 4096
|
||||||
*FlagTextAddr += 4096
|
*FlagTextAddr += 4096
|
||||||
load_budget += 4096
|
loadBudget += 4096
|
||||||
}
|
}
|
||||||
|
|
||||||
dylib = append(dylib, lib)
|
dylib = append(dylib, lib)
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ func container(s *Symbol) int {
|
||||||
// pclntab initializes the pclntab symbol with
|
// pclntab initializes the pclntab symbol with
|
||||||
// runtime function and file name information.
|
// runtime function and file name information.
|
||||||
|
|
||||||
var pclntab_zpcln FuncInfo
|
var pclntabZpcln FuncInfo
|
||||||
|
|
||||||
// These variables are used to initialize runtime.firstmoduledata, see symtab.go:symtab.
|
// These variables are used to initialize runtime.firstmoduledata, see symtab.go:symtab.
|
||||||
var pclntabNfunc int32
|
var pclntabNfunc int32
|
||||||
|
|
@ -208,7 +208,7 @@ var pclntabFirstFunc *Symbol
|
||||||
var pclntabLastFunc *Symbol
|
var pclntabLastFunc *Symbol
|
||||||
|
|
||||||
func (ctxt *Link) pclntab() {
|
func (ctxt *Link) pclntab() {
|
||||||
funcdata_bytes := int64(0)
|
funcdataBytes := int64(0)
|
||||||
ftab := Linklookup(ctxt, "runtime.pclntab", 0)
|
ftab := Linklookup(ctxt, "runtime.pclntab", 0)
|
||||||
ftab.Type = obj.SPCLNTAB
|
ftab.Type = obj.SPCLNTAB
|
||||||
ftab.Attr |= AttrReachable
|
ftab.Attr |= AttrReachable
|
||||||
|
|
@ -251,7 +251,7 @@ func (ctxt *Link) pclntab() {
|
||||||
}
|
}
|
||||||
pcln := ctxt.Cursym.FuncInfo
|
pcln := ctxt.Cursym.FuncInfo
|
||||||
if pcln == nil {
|
if pcln == nil {
|
||||||
pcln = &pclntab_zpcln
|
pcln = &pclntabZpcln
|
||||||
}
|
}
|
||||||
|
|
||||||
if pclntabFirstFunc == nil {
|
if pclntabFirstFunc == nil {
|
||||||
|
|
@ -294,7 +294,7 @@ func (ctxt *Link) pclntab() {
|
||||||
// TODO: Remove entirely.
|
// TODO: Remove entirely.
|
||||||
off = int32(setuint32(ctxt, ftab, int64(off), 0x1234567))
|
off = int32(setuint32(ctxt, ftab, int64(off), 0x1234567))
|
||||||
|
|
||||||
if pcln != &pclntab_zpcln {
|
if pcln != &pclntabZpcln {
|
||||||
renumberfiles(ctxt, pcln.File, &pcln.Pcfile)
|
renumberfiles(ctxt, pcln.File, &pcln.Pcfile)
|
||||||
if false {
|
if false {
|
||||||
// Sanity check the new numbering
|
// Sanity check the new numbering
|
||||||
|
|
@ -330,7 +330,7 @@ func (ctxt *Link) pclntab() {
|
||||||
setuintxx(ctxt, ftab, int64(off)+int64(SysArch.PtrSize)*int64(i), uint64(pcln.Funcdataoff[i]), int64(SysArch.PtrSize))
|
setuintxx(ctxt, ftab, int64(off)+int64(SysArch.PtrSize)*int64(i), uint64(pcln.Funcdataoff[i]), int64(SysArch.PtrSize))
|
||||||
} else {
|
} else {
|
||||||
// TODO: Dedup.
|
// TODO: Dedup.
|
||||||
funcdata_bytes += pcln.Funcdata[i].Size
|
funcdataBytes += pcln.Funcdata[i].Size
|
||||||
|
|
||||||
setaddrplus(ctxt, ftab, int64(off)+int64(SysArch.PtrSize)*int64(i), pcln.Funcdata[i], pcln.Funcdataoff[i])
|
setaddrplus(ctxt, ftab, int64(off)+int64(SysArch.PtrSize)*int64(i), pcln.Funcdata[i], pcln.Funcdataoff[i])
|
||||||
}
|
}
|
||||||
|
|
@ -368,7 +368,7 @@ func (ctxt *Link) pclntab() {
|
||||||
ftab.Size = int64(len(ftab.P))
|
ftab.Size = int64(len(ftab.P))
|
||||||
|
|
||||||
if ctxt.Debugvlog != 0 {
|
if ctxt.Debugvlog != 0 {
|
||||||
fmt.Fprintf(ctxt.Bso, "%5.2f pclntab=%d bytes, funcdata total %d bytes\n", obj.Cputime(), ftab.Size, funcdata_bytes)
|
fmt.Fprintf(ctxt.Bso, "%5.2f pclntab=%d bytes, funcdata total %d bytes\n", obj.Cputime(), ftab.Size, funcdataBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -717,9 +717,9 @@ func addexports(ctxt *Link) {
|
||||||
dd[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = uint32(va)
|
dd[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = uint32(va)
|
||||||
dd[IMAGE_DIRECTORY_ENTRY_EXPORT].Size = sect.VirtualSize
|
dd[IMAGE_DIRECTORY_ENTRY_EXPORT].Size = sect.VirtualSize
|
||||||
|
|
||||||
va_name := va + binary.Size(&e) + nexport*4
|
vaName := va + binary.Size(&e) + nexport*4
|
||||||
va_addr := va + binary.Size(&e)
|
vaAddr := va + binary.Size(&e)
|
||||||
va_na := va + binary.Size(&e) + nexport*8
|
vaNa := va + binary.Size(&e) + nexport*8
|
||||||
|
|
||||||
e.Characteristics = 0
|
e.Characteristics = 0
|
||||||
e.MajorVersion = 0
|
e.MajorVersion = 0
|
||||||
|
|
@ -728,9 +728,9 @@ func addexports(ctxt *Link) {
|
||||||
e.NumberOfNames = uint32(nexport)
|
e.NumberOfNames = uint32(nexport)
|
||||||
e.Name = uint32(va+binary.Size(&e)) + uint32(nexport)*10 // Program names.
|
e.Name = uint32(va+binary.Size(&e)) + uint32(nexport)*10 // Program names.
|
||||||
e.Base = 1
|
e.Base = 1
|
||||||
e.AddressOfFunctions = uint32(va_addr)
|
e.AddressOfFunctions = uint32(vaAddr)
|
||||||
e.AddressOfNames = uint32(va_name)
|
e.AddressOfNames = uint32(vaName)
|
||||||
e.AddressOfNameOrdinals = uint32(va_na)
|
e.AddressOfNameOrdinals = uint32(vaNa)
|
||||||
|
|
||||||
// put IMAGE_EXPORT_DIRECTORY
|
// put IMAGE_EXPORT_DIRECTORY
|
||||||
binary.Write(&coutbuf, binary.LittleEndian, &e)
|
binary.Write(&coutbuf, binary.LittleEndian, &e)
|
||||||
|
|
|
||||||
|
|
@ -576,7 +576,7 @@ func (ctxt *Link) symtab() {
|
||||||
// creating the moduledata from scratch and it does not have a
|
// creating the moduledata from scratch and it does not have a
|
||||||
// compiler-provided size, so read it from the type data.
|
// compiler-provided size, so read it from the type data.
|
||||||
moduledatatype := Linkrlookup(ctxt, "type.runtime.moduledata", 0)
|
moduledatatype := Linkrlookup(ctxt, "type.runtime.moduledata", 0)
|
||||||
moduledata.Size = decodetype_size(ctxt.Arch, moduledatatype)
|
moduledata.Size = decodetypeSize(ctxt.Arch, moduledatatype)
|
||||||
Symgrow(ctxt, moduledata, moduledata.Size)
|
Symgrow(ctxt, moduledata, moduledata.Size)
|
||||||
|
|
||||||
lastmoduledatap := Linklookup(ctxt, "runtime.lastmoduledatap", 0)
|
lastmoduledatap := Linklookup(ctxt, "runtime.lastmoduledatap", 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue