curr := *list
var prev *dwarf.DWDie
for curr != nil {
- var next *dwarf.DWDie = curr.Link
+ next := curr.Link
curr.Link = prev
prev = curr
curr = next
continue
}
- epc = s.Value + s.Size
epcs = s
dsym := ctxt.Syms.Lookup(dwarf.InfoPrefix+s.Name, int(s.Version))
addralign uint64
entsize uint64
shnum int
- secsym *sym.Symbol
}
/*
var (
Iself bool
- Nelfsym int = 1
+ Nelfsym = 1
elf64 bool
// Either ".rel" or ".rela" depending on which type of relocation the
func elfshname(name string) *ElfShdr {
for i := 0; i < nelfstr; i++ {
- if name == elfstr[i].s {
- off := elfstr[i].off
- for i = 0; i < int(ehdr.shnum); i++ {
- sh := shdr[i]
- if sh.name == uint32(off) {
- return sh
- }
+ if name != elfstr[i].s {
+ continue
+ }
+ off := elfstr[i].off
+ for i = 0; i < int(ehdr.shnum); i++ {
+ sh := shdr[i]
+ if sh.name == uint32(off) {
+ return sh
}
- return newElfShdr(int64(off))
}
+ return newElfShdr(int64(off))
}
Exitf("cannot find elf name %s", name)
return nil
e binary.ByteOrder
sect []ElfSect
nsect uint
- shstrtab string
nsymtab int
symtab *ElfSect
symstr *ElfSect
subsectiondata := sectiondata[sz+4 : subsectionsize]
sectiondata = sectiondata[subsectionsize:]
- if subsectiontag == TagFile {
- attrList := elfAttributeList{data: subsectiondata}
- for !attrList.done() {
- attr := attrList.armAttr()
- if attr.tag == TagABIVFPArgs && attr.ival == 1 {
- ehdr.flags = 0x5000402 // has entry point, Version5 EABI, hard-float ABI
- }
- }
- if attrList.err != nil {
- // TODO(dfc) should this be ctxt.Diag ?
- ctxt.Logf("could not parse .ARM.attributes\n")
+ if subsectiontag != TagFile {
+ continue
+ }
+ attrList := elfAttributeList{data: subsectiondata}
+ for !attrList.done() {
+ attr := attrList.armAttr()
+ if attr.tag == TagABIVFPArgs && attr.ival == 1 {
+ ehdr.flags = 0x5000402 // has entry point, Version5 EABI, hard-float ABI
}
}
+ if attrList.err != nil {
+ // TODO(dfc) should this be ctxt.Diag ?
+ ctxt.Logf("could not parse .ARM.attributes\n")
+ }
}
}
}
if typeSymbolMangling(ctxt) {
*FlagW = true // disable DWARF generation
for _, s := range ctxt.Syms.Allsym {
- newName := typeSymbolMangle(ctxt.Syms, s.Name)
+ newName := typeSymbolMangle(s.Name)
if newName != s.Name {
ctxt.Syms.Rename(s.Name, newName, int(s.Version))
}
}
// typeSymbolMangle mangles the given symbol name into something shorter.
-func typeSymbolMangle(syms *sym.Symbols, name string) string {
+func typeSymbolMangle(name string) string {
if !strings.HasPrefix(name, "type.") {
return name
}
}
}
-func (l *Link) Logf(format string, args ...interface{}) {
- fmt.Fprintf(l.Bso, format, args...)
- l.Bso.Flush()
+func (ctxt *Link) Logf(format string, args ...interface{}) {
+ fmt.Fprintf(ctxt.Bso, format, args...)
+ ctxt.Bso.Flush()
}
func addImports(ctxt *Link, l *sym.Library, pn string) {
// "big enough" header size. The initial header is
// one page, the non-dynamic library stuff takes
// up about 1300 bytes; we overestimate that as 2k.
-var loadBudget int = INITIAL_MACHO_HEADR - 2*1024
+var loadBudget = INITIAL_MACHO_HEADR - 2*1024
func getMachoHdr() *MachoHdr {
return &machohdr
var realdwarf, linkseg *macho.Segment
var dwarfstart, linkstart int64
-var dwarfaddr, linkaddr int64
+var dwarfaddr int64
var linkoffset uint32
const (
}
}
-var numelfsym int = 1 // 0 is reserved
+var numelfsym = 1 // 0 is reserved
var elfbind int
// pkghashes[i].name
addgostring(ctxt, pkghashes, fmt.Sprintf("go.link.pkgname.%d", i), l.Pkg)
// pkghashes[i].linktimehash
- addgostring(ctxt, pkghashes, fmt.Sprintf("go.link.pkglinkhash.%d", i), string(l.Hash))
+ addgostring(ctxt, pkghashes, fmt.Sprintf("go.link.pkglinkhash.%d", i), l.Hash)
// pkghashes[i].runtimehash
hash := ctxt.Syms.ROLookup("go.link.pkghash."+l.Pkg, 0)
pkghashes.AddAddr(ctxt.Arch, hash)