Commit 24158644 authored by Michael Matloob's avatar Michael Matloob

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: default avatarDavid Crawshaw <crawshaw@golang.org>
parent 5e66ac9a
...@@ -1133,15 +1133,15 @@ func (p *GCProg) AddSym(s *Symbol) { ...@@ -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) { ...@@ -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() { ...@@ -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() { ...@@ -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() { ...@@ -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() { ...@@ -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() { ...@@ -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 ...@@ -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() { ...@@ -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() { ...@@ -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)))
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -66,10 +66,10 @@ import ( ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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) { ...@@ -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 ( ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 ( ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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 { ...@@ -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 { ...@@ -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() { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 ...@@ -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) { ...@@ -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 { ...@@ -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 ...@@ -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() { ...@@ -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() { ...@@ -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() { ...@@ -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() { ...@@ -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) { ...@@ -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) { ...@@ -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() { ...@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment