Commit 63837092 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

cmd/link: remove now-unused ctxt arguments from a few functions

Specifically Addstring, Addbytes and Symgrow.

Change-Id: Ia74093bfcf9f360bf223accbc8feef54a7f059c9
Reviewed-on: https://go-review.googlesource.com/29348
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 25d09403
...@@ -45,7 +45,7 @@ func Addcall(ctxt *ld.Link, s *ld.Symbol, t *ld.Symbol) int64 { ...@@ -45,7 +45,7 @@ func Addcall(ctxt *ld.Link, s *ld.Symbol, t *ld.Symbol) int64 {
s.Attr |= ld.AttrReachable s.Attr |= ld.AttrReachable
i := s.Size i := s.Size
s.Size += 4 s.Size += 4
ld.Symgrow(ctxt, s, s.Size) ld.Symgrow(s, s.Size)
r := ld.Addrel(s) r := ld.Addrel(s)
r.Sym = t r.Sym = t
r.Off = int32(i) r.Off = int32(i)
......
...@@ -503,7 +503,7 @@ func addpltreloc(ctxt *ld.Link, plt *ld.Symbol, got *ld.Symbol, sym *ld.Symbol, ...@@ -503,7 +503,7 @@ func addpltreloc(ctxt *ld.Link, plt *ld.Symbol, got *ld.Symbol, sym *ld.Symbol,
plt.Attr |= ld.AttrReachable plt.Attr |= ld.AttrReachable
plt.Size += 4 plt.Size += 4
ld.Symgrow(ctxt, plt, plt.Size) ld.Symgrow(plt, plt.Size)
return r return r
} }
......
...@@ -44,7 +44,7 @@ import ( ...@@ -44,7 +44,7 @@ import (
"sync" "sync"
) )
func Symgrow(ctxt *Link, s *Symbol, siz int64) { func Symgrow(s *Symbol, siz int64) {
if int64(int(siz)) != siz { if int64(int(siz)) != siz {
log.Fatalf("symgrow size %d too long", siz) log.Fatalf("symgrow size %d too long", siz)
} }
...@@ -70,7 +70,7 @@ func setuintxx(ctxt *Link, s *Symbol, off int64, v uint64, wid int64) int64 { ...@@ -70,7 +70,7 @@ func setuintxx(ctxt *Link, s *Symbol, off int64, v uint64, wid int64) int64 {
s.Attr |= AttrReachable s.Attr |= AttrReachable
if s.Size < off+wid { if s.Size < off+wid {
s.Size = off + wid s.Size = off + wid
Symgrow(ctxt, s, s.Size) Symgrow(s, s.Size)
} }
switch wid { switch wid {
...@@ -87,7 +87,7 @@ func setuintxx(ctxt *Link, s *Symbol, off int64, v uint64, wid int64) int64 { ...@@ -87,7 +87,7 @@ func setuintxx(ctxt *Link, s *Symbol, off int64, v uint64, wid int64) int64 {
return off + wid return off + wid
} }
func Addbytes(ctxt *Link, s *Symbol, bytes []byte) int64 { func Addbytes(s *Symbol, bytes []byte) int64 {
if s.Type == 0 { if s.Type == 0 {
s.Type = obj.SDATA s.Type = obj.SDATA
} }
...@@ -147,7 +147,7 @@ func Addaddrplus(ctxt *Link, s *Symbol, t *Symbol, add int64) int64 { ...@@ -147,7 +147,7 @@ func Addaddrplus(ctxt *Link, s *Symbol, t *Symbol, add int64) int64 {
s.Attr |= AttrReachable s.Attr |= AttrReachable
i := s.Size i := s.Size
s.Size += int64(ctxt.Arch.PtrSize) s.Size += int64(ctxt.Arch.PtrSize)
Symgrow(ctxt, s, s.Size) Symgrow(s, s.Size)
r := Addrel(s) r := Addrel(s)
r.Sym = t r.Sym = t
r.Off = int32(i) r.Off = int32(i)
...@@ -164,7 +164,7 @@ func Addpcrelplus(ctxt *Link, s *Symbol, t *Symbol, add int64) int64 { ...@@ -164,7 +164,7 @@ func Addpcrelplus(ctxt *Link, s *Symbol, t *Symbol, add int64) int64 {
s.Attr |= AttrReachable s.Attr |= AttrReachable
i := s.Size i := s.Size
s.Size += 4 s.Size += 4
Symgrow(ctxt, s, s.Size) Symgrow(s, s.Size)
r := Addrel(s) r := Addrel(s)
r.Sym = t r.Sym = t
r.Off = int32(i) r.Off = int32(i)
...@@ -188,7 +188,7 @@ func setaddrplus(ctxt *Link, s *Symbol, off int64, t *Symbol, add int64) int64 { ...@@ -188,7 +188,7 @@ func setaddrplus(ctxt *Link, s *Symbol, off int64, t *Symbol, add int64) int64 {
s.Attr |= AttrReachable s.Attr |= AttrReachable
if off+int64(ctxt.Arch.PtrSize) > s.Size { if off+int64(ctxt.Arch.PtrSize) > s.Size {
s.Size = off + int64(ctxt.Arch.PtrSize) s.Size = off + int64(ctxt.Arch.PtrSize)
Symgrow(ctxt, s, s.Size) Symgrow(s, s.Size)
} }
r := Addrel(s) r := Addrel(s)
...@@ -211,7 +211,7 @@ func addsize(ctxt *Link, s *Symbol, t *Symbol) int64 { ...@@ -211,7 +211,7 @@ func addsize(ctxt *Link, s *Symbol, t *Symbol) int64 {
s.Attr |= AttrReachable s.Attr |= AttrReachable
i := s.Size i := s.Size
s.Size += int64(ctxt.Arch.PtrSize) s.Size += int64(ctxt.Arch.PtrSize)
Symgrow(ctxt, s, s.Size) Symgrow(s, s.Size)
r := Addrel(s) r := Addrel(s)
r.Sym = t r.Sym = t
r.Off = int32(i) r.Off = int32(i)
...@@ -227,7 +227,7 @@ func addaddrplus4(ctxt *Link, s *Symbol, t *Symbol, add int64) int64 { ...@@ -227,7 +227,7 @@ func addaddrplus4(ctxt *Link, s *Symbol, t *Symbol, add int64) int64 {
s.Attr |= AttrReachable s.Attr |= AttrReachable
i := s.Size i := s.Size
s.Size += 4 s.Size += 4
Symgrow(ctxt, s, s.Size) Symgrow(s, s.Size)
r := Addrel(s) r := Addrel(s)
r.Sym = t r.Sym = t
r.Off = int32(i) r.Off = int32(i)
...@@ -989,7 +989,7 @@ func addstrdata(ctxt *Link, name string, value string) { ...@@ -989,7 +989,7 @@ func addstrdata(ctxt *Link, name string, value string) {
p := fmt.Sprintf("%s.str", name) p := fmt.Sprintf("%s.str", name)
sp := ctxt.Syms.Lookup(p, 0) sp := ctxt.Syms.Lookup(p, 0)
Addstring(ctxt, sp, value) Addstring(sp, value)
sp.Type = obj.SRODATA sp.Type = obj.SRODATA
s := ctxt.Syms.Lookup(name, 0) s := ctxt.Syms.Lookup(name, 0)
...@@ -1019,7 +1019,7 @@ func (ctxt *Link) checkstrdata() { ...@@ -1019,7 +1019,7 @@ func (ctxt *Link) checkstrdata() {
} }
} }
func Addstring(ctxt *Link, s *Symbol, str string) int64 { func Addstring(s *Symbol, str string) int64 {
if s.Type == 0 { if s.Type == 0 {
s.Type = obj.SNOPTRDATA s.Type = obj.SNOPTRDATA
} }
......
...@@ -36,10 +36,10 @@ func (c dwctxt) AddInt(s dwarf.Sym, size int, i int64) { ...@@ -36,10 +36,10 @@ func (c dwctxt) AddInt(s dwarf.Sym, size int, i int64) {
} }
func (c dwctxt) AddBytes(s dwarf.Sym, b []byte) { func (c dwctxt) AddBytes(s dwarf.Sym, b []byte) {
ls := s.(*Symbol) ls := s.(*Symbol)
Addbytes(c.linkctxt, ls, b) Addbytes(ls, b)
} }
func (c dwctxt) AddString(s dwarf.Sym, v string) { func (c dwctxt) AddString(s dwarf.Sym, v string) {
Addstring(c.linkctxt, s.(*Symbol), v) Addstring(s.(*Symbol), v)
} }
func (c dwctxt) SymValue(s dwarf.Sym) int64 { func (c dwctxt) SymValue(s dwarf.Sym) int64 {
return s.(*Symbol).Value return s.(*Symbol).Value
...@@ -85,7 +85,7 @@ func writeabbrev(ctxt *Link, syms []*Symbol) []*Symbol { ...@@ -85,7 +85,7 @@ func writeabbrev(ctxt *Link, syms []*Symbol) []*Symbol {
s := ctxt.Syms.Lookup(".debug_abbrev", 0) s := ctxt.Syms.Lookup(".debug_abbrev", 0)
s.Type = obj.SDWARFSECT s.Type = obj.SDWARFSECT
abbrevsym = s abbrevsym = s
Addbytes(ctxt, s, dwarf.GetAbbrev()) Addbytes(s, dwarf.GetAbbrev())
return append(syms, s) return append(syms, s)
} }
...@@ -977,7 +977,7 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) { ...@@ -977,7 +977,7 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) {
Adduint8(ctxt, ls, 0) // include_directories (empty) Adduint8(ctxt, ls, 0) // include_directories (empty)
for _, f := range ctxt.Filesyms { for _, f := range ctxt.Filesyms {
Addstring(ctxt, ls, f.Name) Addstring(ls, f.Name)
Adduint8(ctxt, ls, 0) Adduint8(ctxt, ls, 0)
Adduint8(ctxt, ls, 0) Adduint8(ctxt, ls, 0)
Adduint8(ctxt, ls, 0) Adduint8(ctxt, ls, 0)
...@@ -1147,7 +1147,7 @@ func writeframes(ctxt *Link, syms []*Symbol) []*Symbol { ...@@ -1147,7 +1147,7 @@ func writeframes(ctxt *Link, syms []*Symbol) []*Symbol {
Exitf("dwarf: cieReserve too small by %d bytes.", -pad) Exitf("dwarf: cieReserve too small by %d bytes.", -pad)
} }
Addbytes(ctxt, fs, zeros[:pad]) Addbytes(fs, zeros[:pad])
var deltaBuf []byte var deltaBuf []byte
var pcsp Pciter var pcsp Pciter
...@@ -1208,7 +1208,7 @@ func writeframes(ctxt *Link, syms []*Symbol) []*Symbol { ...@@ -1208,7 +1208,7 @@ func writeframes(ctxt *Link, syms []*Symbol) []*Symbol {
} }
Addaddr(ctxt, fs, s) Addaddr(ctxt, fs, s)
adduintxx(ctxt, fs, uint64(s.Size), SysArch.PtrSize) // address range adduintxx(ctxt, fs, uint64(s.Size), SysArch.PtrSize) // address range
Addbytes(ctxt, fs, deltaBuf) Addbytes(fs, deltaBuf)
} }
return syms return syms
} }
...@@ -1314,7 +1314,7 @@ func writepub(ctxt *Link, sname string, ispub func(*dwarf.DWDie) bool, syms []*S ...@@ -1314,7 +1314,7 @@ func writepub(ctxt *Link, sname string, ispub func(*dwarf.DWDie) bool, syms []*S
fmt.Println("Missing sym for ", name) fmt.Println("Missing sym for ", name)
} }
adddwarfref(ctxt, s, dtolsym(die.Sym), 4) adddwarfref(ctxt, s, dtolsym(die.Sym), 4)
Addstring(ctxt, s, name) Addstring(s, name)
} }
Adduint32(ctxt, s, 0) Adduint32(ctxt, s, 0)
...@@ -1378,7 +1378,7 @@ func writegdbscript(ctxt *Link, syms []*Symbol) []*Symbol { ...@@ -1378,7 +1378,7 @@ func writegdbscript(ctxt *Link, syms []*Symbol) []*Symbol {
s.Type = obj.SDWARFSECT s.Type = obj.SDWARFSECT
syms = append(syms, s) syms = append(syms, s)
Adduint8(ctxt, s, 1) // magic 1 byte? Adduint8(ctxt, s, 1) // magic 1 byte?
Addstring(ctxt, s, gdbscript) Addstring(s, gdbscript)
} }
return syms return syms
...@@ -1485,21 +1485,21 @@ func dwarfaddshstrings(ctxt *Link, shstrtab *Symbol) { ...@@ -1485,21 +1485,21 @@ func dwarfaddshstrings(ctxt *Link, shstrtab *Symbol) {
return return
} }
Addstring(ctxt, shstrtab, ".debug_abbrev") Addstring(shstrtab, ".debug_abbrev")
Addstring(ctxt, shstrtab, ".debug_aranges") Addstring(shstrtab, ".debug_aranges")
Addstring(ctxt, shstrtab, ".debug_frame") Addstring(shstrtab, ".debug_frame")
Addstring(ctxt, shstrtab, ".debug_info") Addstring(shstrtab, ".debug_info")
Addstring(ctxt, shstrtab, ".debug_line") Addstring(shstrtab, ".debug_line")
Addstring(ctxt, shstrtab, ".debug_pubnames") Addstring(shstrtab, ".debug_pubnames")
Addstring(ctxt, shstrtab, ".debug_pubtypes") Addstring(shstrtab, ".debug_pubtypes")
Addstring(ctxt, shstrtab, ".debug_gdb_scripts") Addstring(shstrtab, ".debug_gdb_scripts")
if Linkmode == LinkExternal { if Linkmode == LinkExternal {
Addstring(ctxt, shstrtab, elfRelType+".debug_info") Addstring(shstrtab, elfRelType+".debug_info")
Addstring(ctxt, shstrtab, elfRelType+".debug_aranges") Addstring(shstrtab, elfRelType+".debug_aranges")
Addstring(ctxt, shstrtab, elfRelType+".debug_line") Addstring(shstrtab, elfRelType+".debug_line")
Addstring(ctxt, shstrtab, elfRelType+".debug_frame") Addstring(shstrtab, elfRelType+".debug_frame")
Addstring(ctxt, shstrtab, elfRelType+".debug_pubnames") Addstring(shstrtab, elfRelType+".debug_pubnames")
Addstring(ctxt, shstrtab, elfRelType+".debug_pubtypes") Addstring(shstrtab, elfRelType+".debug_pubtypes")
} }
} }
......
...@@ -1517,9 +1517,9 @@ func elfdynhash(ctxt *Link) { ...@@ -1517,9 +1517,9 @@ func elfdynhash(ctxt *Link) {
for x = l.aux; x != nil; x = x.next { for x = l.aux; x != nil; x = x.next {
j++ j++
} }
Adduint16(ctxt, s, uint16(j)) // aux count Adduint16(ctxt, s, uint16(j)) // aux count
Adduint32(ctxt, s, uint32(Addstring(ctxt, dynstr, l.file))) // file string offset Adduint32(ctxt, s, uint32(Addstring(dynstr, l.file))) // file string offset
Adduint32(ctxt, s, 16) // offset from header to first aux Adduint32(ctxt, s, 16) // offset from header to first aux
if l.next != nil { if l.next != nil {
Adduint32(ctxt, s, 16+uint32(j)*16) // offset from this header to next Adduint32(ctxt, s, 16+uint32(j)*16) // offset from this header to next
} else { } else {
...@@ -1531,10 +1531,10 @@ func elfdynhash(ctxt *Link) { ...@@ -1531,10 +1531,10 @@ func elfdynhash(ctxt *Link) {
i++ i++
// aux struct // aux struct
Adduint32(ctxt, s, elfhash(x.vers)) // hash Adduint32(ctxt, s, elfhash(x.vers)) // hash
Adduint16(ctxt, s, 0) // flags Adduint16(ctxt, s, 0) // flags
Adduint16(ctxt, s, uint16(x.num)) // other - index we refer to this by Adduint16(ctxt, s, uint16(x.num)) // other - index we refer to this by
Adduint32(ctxt, s, uint32(Addstring(ctxt, dynstr, x.vers))) // version string offset Adduint32(ctxt, s, uint32(Addstring(dynstr, x.vers))) // version string offset
if x.next != nil { if x.next != nil {
Adduint32(ctxt, s, 16) // offset from this aux to next Adduint32(ctxt, s, 16) // offset from this aux to next
} else { } else {
...@@ -1840,12 +1840,12 @@ func (ctxt *Link) doelf() { ...@@ -1840,12 +1840,12 @@ func (ctxt *Link) doelf() {
shstrtab.Type = obj.SELFROSECT shstrtab.Type = obj.SELFROSECT
shstrtab.Attr |= AttrReachable shstrtab.Attr |= AttrReachable
Addstring(ctxt, shstrtab, "") Addstring(shstrtab, "")
Addstring(ctxt, shstrtab, ".text") Addstring(shstrtab, ".text")
Addstring(ctxt, shstrtab, ".noptrdata") Addstring(shstrtab, ".noptrdata")
Addstring(ctxt, shstrtab, ".data") Addstring(shstrtab, ".data")
Addstring(ctxt, shstrtab, ".bss") Addstring(shstrtab, ".bss")
Addstring(ctxt, shstrtab, ".noptrbss") Addstring(shstrtab, ".noptrbss")
// generate .tbss section (except for OpenBSD where it's not supported) // generate .tbss section (except for OpenBSD where it's not supported)
// for dynamic internal linker or external linking, so that various // for dynamic internal linker or external linking, so that various
...@@ -1853,56 +1853,56 @@ func (ctxt *Link) doelf() { ...@@ -1853,56 +1853,56 @@ func (ctxt *Link) doelf() {
// see https://golang.org/issue/5200. // see https://golang.org/issue/5200.
if Headtype != obj.Hopenbsd { if Headtype != obj.Hopenbsd {
if !*FlagD || Linkmode == LinkExternal { if !*FlagD || Linkmode == LinkExternal {
Addstring(ctxt, shstrtab, ".tbss") Addstring(shstrtab, ".tbss")
} }
} }
if Headtype == obj.Hnetbsd { if Headtype == obj.Hnetbsd {
Addstring(ctxt, shstrtab, ".note.netbsd.ident") Addstring(shstrtab, ".note.netbsd.ident")
} }
if Headtype == obj.Hopenbsd { if Headtype == obj.Hopenbsd {
Addstring(ctxt, shstrtab, ".note.openbsd.ident") Addstring(shstrtab, ".note.openbsd.ident")
} }
if len(buildinfo) > 0 { if len(buildinfo) > 0 {
Addstring(ctxt, shstrtab, ".note.gnu.build-id") Addstring(shstrtab, ".note.gnu.build-id")
} }
if *flagBuildid != "" { if *flagBuildid != "" {
Addstring(ctxt, shstrtab, ".note.go.buildid") Addstring(shstrtab, ".note.go.buildid")
} }
Addstring(ctxt, shstrtab, ".elfdata") Addstring(shstrtab, ".elfdata")
Addstring(ctxt, shstrtab, ".rodata") Addstring(shstrtab, ".rodata")
// See the comment about data.rel.ro.FOO section names in data.go. // See the comment about data.rel.ro.FOO section names in data.go.
relro_prefix := "" relro_prefix := ""
if UseRelro() { if UseRelro() {
Addstring(ctxt, shstrtab, ".data.rel.ro") Addstring(shstrtab, ".data.rel.ro")
relro_prefix = ".data.rel.ro" relro_prefix = ".data.rel.ro"
} }
Addstring(ctxt, shstrtab, relro_prefix+".typelink") Addstring(shstrtab, relro_prefix+".typelink")
Addstring(ctxt, shstrtab, relro_prefix+".itablink") Addstring(shstrtab, relro_prefix+".itablink")
Addstring(ctxt, shstrtab, relro_prefix+".gosymtab") Addstring(shstrtab, relro_prefix+".gosymtab")
Addstring(ctxt, shstrtab, relro_prefix+".gopclntab") Addstring(shstrtab, relro_prefix+".gopclntab")
if Linkmode == LinkExternal { if Linkmode == LinkExternal {
*FlagD = true *FlagD = true
Addstring(ctxt, shstrtab, elfRelType+".text") Addstring(shstrtab, elfRelType+".text")
Addstring(ctxt, shstrtab, elfRelType+".rodata") Addstring(shstrtab, elfRelType+".rodata")
Addstring(ctxt, shstrtab, elfRelType+relro_prefix+".typelink") Addstring(shstrtab, elfRelType+relro_prefix+".typelink")
Addstring(ctxt, shstrtab, elfRelType+relro_prefix+".itablink") Addstring(shstrtab, elfRelType+relro_prefix+".itablink")
Addstring(ctxt, shstrtab, elfRelType+relro_prefix+".gosymtab") Addstring(shstrtab, elfRelType+relro_prefix+".gosymtab")
Addstring(ctxt, shstrtab, elfRelType+relro_prefix+".gopclntab") Addstring(shstrtab, elfRelType+relro_prefix+".gopclntab")
Addstring(ctxt, shstrtab, elfRelType+".noptrdata") Addstring(shstrtab, elfRelType+".noptrdata")
Addstring(ctxt, shstrtab, elfRelType+".data") Addstring(shstrtab, elfRelType+".data")
if UseRelro() { if UseRelro() {
Addstring(ctxt, shstrtab, elfRelType+".data.rel.ro") Addstring(shstrtab, elfRelType+".data.rel.ro")
} }
// add a .note.GNU-stack section to mark the stack as non-executable // add a .note.GNU-stack section to mark the stack as non-executable
Addstring(ctxt, shstrtab, ".note.GNU-stack") Addstring(shstrtab, ".note.GNU-stack")
if Buildmode == BuildmodeShared { if Buildmode == BuildmodeShared {
Addstring(ctxt, shstrtab, ".note.go.abihash") Addstring(shstrtab, ".note.go.abihash")
Addstring(ctxt, shstrtab, ".note.go.pkg-list") Addstring(shstrtab, ".note.go.pkg-list")
Addstring(ctxt, shstrtab, ".note.go.deps") Addstring(shstrtab, ".note.go.deps")
} }
} }
...@@ -1915,35 +1915,35 @@ func (ctxt *Link) doelf() { ...@@ -1915,35 +1915,35 @@ func (ctxt *Link) doelf() {
} }
if hasinitarr { if hasinitarr {
Addstring(ctxt, shstrtab, ".init_array") Addstring(shstrtab, ".init_array")
Addstring(ctxt, shstrtab, elfRelType+".init_array") Addstring(shstrtab, elfRelType+".init_array")
} }
if !*FlagS { if !*FlagS {
Addstring(ctxt, shstrtab, ".symtab") Addstring(shstrtab, ".symtab")
Addstring(ctxt, shstrtab, ".strtab") Addstring(shstrtab, ".strtab")
dwarfaddshstrings(ctxt, shstrtab) dwarfaddshstrings(ctxt, shstrtab)
} }
Addstring(ctxt, shstrtab, ".shstrtab") Addstring(shstrtab, ".shstrtab")
if !*FlagD { /* -d suppresses dynamic loader format */ if !*FlagD { /* -d suppresses dynamic loader format */
Addstring(ctxt, shstrtab, ".interp") Addstring(shstrtab, ".interp")
Addstring(ctxt, shstrtab, ".hash") Addstring(shstrtab, ".hash")
Addstring(ctxt, shstrtab, ".got") Addstring(shstrtab, ".got")
if SysArch.Family == sys.PPC64 { if SysArch.Family == sys.PPC64 {
Addstring(ctxt, shstrtab, ".glink") Addstring(shstrtab, ".glink")
} }
Addstring(ctxt, shstrtab, ".got.plt") Addstring(shstrtab, ".got.plt")
Addstring(ctxt, shstrtab, ".dynamic") Addstring(shstrtab, ".dynamic")
Addstring(ctxt, shstrtab, ".dynsym") Addstring(shstrtab, ".dynsym")
Addstring(ctxt, shstrtab, ".dynstr") Addstring(shstrtab, ".dynstr")
Addstring(ctxt, shstrtab, elfRelType) Addstring(shstrtab, elfRelType)
Addstring(ctxt, shstrtab, elfRelType+".plt") Addstring(shstrtab, elfRelType+".plt")
Addstring(ctxt, shstrtab, ".plt") Addstring(shstrtab, ".plt")
Addstring(ctxt, shstrtab, ".gnu.version") Addstring(shstrtab, ".gnu.version")
Addstring(ctxt, shstrtab, ".gnu.version_r") Addstring(shstrtab, ".gnu.version_r")
/* dynamic symbol table - first entry all zeros */ /* dynamic symbol table - first entry all zeros */
s := ctxt.Syms.Lookup(".dynsym", 0) s := ctxt.Syms.Lookup(".dynsym", 0)
...@@ -1962,7 +1962,7 @@ func (ctxt *Link) doelf() { ...@@ -1962,7 +1962,7 @@ func (ctxt *Link) doelf() {
s.Type = obj.SELFROSECT s.Type = obj.SELFROSECT
s.Attr |= AttrReachable s.Attr |= AttrReachable
if s.Size == 0 { if s.Size == 0 {
Addstring(ctxt, s, "") Addstring(s, "")
} }
dynstr := s dynstr := s
...@@ -2049,7 +2049,7 @@ func (ctxt *Link) doelf() { ...@@ -2049,7 +2049,7 @@ func (ctxt *Link) doelf() {
} }
if rpath.val != "" { if rpath.val != "" {
Elfwritedynent(ctxt, s, DT_RUNPATH, uint64(Addstring(ctxt, dynstr, rpath.val))) Elfwritedynent(ctxt, s, DT_RUNPATH, uint64(Addstring(dynstr, rpath.val)))
} }
if SysArch.Family == sys.PPC64 { if SysArch.Family == sys.PPC64 {
...@@ -2642,7 +2642,7 @@ func Elfadddynsym(ctxt *Link, s *Symbol) { ...@@ -2642,7 +2642,7 @@ func Elfadddynsym(ctxt *Link, s *Symbol) {
d := ctxt.Syms.Lookup(".dynsym", 0) d := ctxt.Syms.Lookup(".dynsym", 0)
name := s.Extname name := s.Extname
Adduint32(ctxt, d, uint32(Addstring(ctxt, ctxt.Syms.Lookup(".dynstr", 0), name))) Adduint32(ctxt, d, uint32(Addstring(ctxt.Syms.Lookup(".dynstr", 0), name)))
/* type */ /* type */
t := STB_GLOBAL << 4 t := STB_GLOBAL << 4
...@@ -2675,7 +2675,7 @@ func Elfadddynsym(ctxt *Link, s *Symbol) { ...@@ -2675,7 +2675,7 @@ func Elfadddynsym(ctxt *Link, s *Symbol) {
Adduint64(ctxt, d, uint64(s.Size)) Adduint64(ctxt, d, uint64(s.Size))
if SysArch.Family == sys.AMD64 && !s.Attr.CgoExportDynamic() && s.Dynimplib != "" && !seenlib[s.Dynimplib] { if SysArch.Family == sys.AMD64 && !s.Attr.CgoExportDynamic() && s.Dynimplib != "" && !seenlib[s.Dynimplib] {
Elfwritedynent(ctxt, ctxt.Syms.Lookup(".dynamic", 0), DT_NEEDED, uint64(Addstring(ctxt, ctxt.Syms.Lookup(".dynstr", 0), s.Dynimplib))) Elfwritedynent(ctxt, ctxt.Syms.Lookup(".dynamic", 0), DT_NEEDED, uint64(Addstring(ctxt.Syms.Lookup(".dynstr", 0), s.Dynimplib)))
} }
} else { } else {
s.Dynid = int32(Nelfsym) s.Dynid = int32(Nelfsym)
...@@ -2686,7 +2686,7 @@ func Elfadddynsym(ctxt *Link, s *Symbol) { ...@@ -2686,7 +2686,7 @@ func Elfadddynsym(ctxt *Link, s *Symbol) {
/* name */ /* name */
name := s.Extname name := s.Extname
Adduint32(ctxt, d, uint32(Addstring(ctxt, ctxt.Syms.Lookup(".dynstr", 0), name))) Adduint32(ctxt, d, uint32(Addstring(ctxt.Syms.Lookup(".dynstr", 0), name)))
/* value */ /* value */
if s.Type == obj.SDYNIMPORT { if s.Type == obj.SDYNIMPORT {
......
...@@ -307,9 +307,9 @@ func adddynlib(ctxt *Link, lib string) { ...@@ -307,9 +307,9 @@ func adddynlib(ctxt *Link, lib string) {
if Iself { if Iself {
s := ctxt.Syms.Lookup(".dynstr", 0) s := ctxt.Syms.Lookup(".dynstr", 0)
if s.Size == 0 { if s.Size == 0 {
Addstring(ctxt, s, "") Addstring(s, "")
} }
Elfwritedynent(ctxt, ctxt.Syms.Lookup(".dynamic", 0), DT_NEEDED, uint64(Addstring(ctxt, s, lib))) Elfwritedynent(ctxt, ctxt.Syms.Lookup(".dynamic", 0), DT_NEEDED, uint64(Addstring(s, lib)))
} else { } else {
Errorf(nil, "adddynlib: unsupported binary format") Errorf(nil, "adddynlib: unsupported binary format")
} }
......
...@@ -698,7 +698,7 @@ func machosymtab(ctxt *Link) { ...@@ -698,7 +698,7 @@ func machosymtab(ctxt *Link) {
} }
// replace "·" as ".", because DTrace cannot handle it. // replace "·" as ".", because DTrace cannot handle it.
Addstring(ctxt, symstr, strings.Replace(s.Extname, "·", ".", -1)) Addstring(symstr, strings.Replace(s.Extname, "·", ".", -1))
if s.Type == obj.SDYNIMPORT || s.Type == obj.SHOSTOBJ { if s.Type == obj.SDYNIMPORT || s.Type == obj.SHOSTOBJ {
Adduint8(ctxt, symtab, 0x01) // type N_EXT, external symbol Adduint8(ctxt, symtab, 0x01) // type N_EXT, external symbol
......
...@@ -126,7 +126,7 @@ func addpctab(ctxt *Link, ftab *Symbol, off int32, d *Pcdata) int32 { ...@@ -126,7 +126,7 @@ func addpctab(ctxt *Link, ftab *Symbol, off int32, d *Pcdata) int32 {
var start int32 var start int32
if len(d.P) > 0 { if len(d.P) > 0 {
start = int32(len(ftab.P)) start = int32(len(ftab.P))
Addbytes(ctxt, ftab, d.P) Addbytes(ftab, d.P)
} }
return int32(setuint32(ctxt, ftab, int64(off), uint32(start))) return int32(setuint32(ctxt, ftab, int64(off), uint32(start)))
} }
...@@ -134,7 +134,7 @@ func addpctab(ctxt *Link, ftab *Symbol, off int32, d *Pcdata) int32 { ...@@ -134,7 +134,7 @@ func addpctab(ctxt *Link, ftab *Symbol, off int32, d *Pcdata) int32 {
func ftabaddstring(ctxt *Link, ftab *Symbol, s string) int32 { func ftabaddstring(ctxt *Link, ftab *Symbol, s string) int32 {
n := int32(len(s)) + 1 n := int32(len(s)) + 1
start := int32(len(ftab.P)) start := int32(len(ftab.P))
Symgrow(ctxt, ftab, int64(start)+int64(n)+1) Symgrow(ftab, int64(start)+int64(n)+1)
copy(ftab.P[start:], s) copy(ftab.P[start:], s)
return start return start
} }
...@@ -234,7 +234,7 @@ func (ctxt *Link) pclntab() { ...@@ -234,7 +234,7 @@ func (ctxt *Link) pclntab() {
} }
pclntabNfunc = nfunc pclntabNfunc = nfunc
Symgrow(ctxt, ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize)+4) Symgrow(ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize)+4)
setuint32(ctxt, ftab, 0, 0xfffffffb) setuint32(ctxt, ftab, 0, 0xfffffffb)
setuint8(ctxt, ftab, 6, uint8(SysArch.MinLC)) setuint8(ctxt, ftab, 6, uint8(SysArch.MinLC))
setuint8(ctxt, ftab, 7, uint8(SysArch.PtrSize)) setuint8(ctxt, ftab, 7, uint8(SysArch.PtrSize))
...@@ -270,7 +270,7 @@ func (ctxt *Link) pclntab() { ...@@ -270,7 +270,7 @@ func (ctxt *Link) pclntab() {
if len(pcln.Funcdata) > 0 && (end&int32(SysArch.PtrSize-1) != 0) { if len(pcln.Funcdata) > 0 && (end&int32(SysArch.PtrSize-1) != 0) {
end += 4 end += 4
} }
Symgrow(ctxt, ftab, int64(end)) Symgrow(ftab, int64(end))
// entry uintptr // entry uintptr
off = int32(setaddr(ctxt, ftab, int64(off), s)) off = int32(setaddr(ctxt, ftab, int64(off), s))
...@@ -357,7 +357,7 @@ func (ctxt *Link) pclntab() { ...@@ -357,7 +357,7 @@ func (ctxt *Link) pclntab() {
pclntabFiletabOffset = start pclntabFiletabOffset = start
setuint32(ctxt, ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize), uint32(start)) setuint32(ctxt, ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize), uint32(start))
Symgrow(ctxt, ftab, int64(start)+(int64(len(ctxt.Filesyms))+1)*4) Symgrow(ftab, int64(start)+(int64(len(ctxt.Filesyms))+1)*4)
setuint32(ctxt, ftab, int64(start), uint32(len(ctxt.Filesyms)+1)) setuint32(ctxt, ftab, int64(start), uint32(len(ctxt.Filesyms)+1))
for i := len(ctxt.Filesyms) - 1; i >= 0; i-- { for i := len(ctxt.Filesyms) - 1; i >= 0; i-- {
s := ctxt.Filesyms[i] s := ctxt.Filesyms[i]
...@@ -451,7 +451,7 @@ func (ctxt *Link) findfunctab() { ...@@ -451,7 +451,7 @@ func (ctxt *Link) findfunctab() {
// allocate table // allocate table
nbuckets := int32((max - min + BUCKETSIZE - 1) / BUCKETSIZE) nbuckets := int32((max - min + BUCKETSIZE - 1) / BUCKETSIZE)
Symgrow(ctxt, t, 4*int64(nbuckets)+int64(n)) Symgrow(t, 4*int64(nbuckets)+int64(n))
// fill in table // fill in table
for i := int32(0); i < nbuckets; i++ { for i := int32(0); i < nbuckets; i++ {
......
...@@ -521,7 +521,7 @@ func initdynimport(ctxt *Link) *Dll { ...@@ -521,7 +521,7 @@ func initdynimport(ctxt *Link) *Dll {
for d := dr; d != nil; d = d.next { for d := dr; d != nil; d = d.next {
for m = d.ms; m != nil; m = m.next { for m = d.ms; m != nil; m = m.next {
m.s.Type = obj.SDATA m.s.Type = obj.SDATA
Symgrow(ctxt, m.s, int64(SysArch.PtrSize)) Symgrow(m.s, int64(SysArch.PtrSize))
dynName := m.s.Extname dynName := m.s.Extname
// only windows/386 requires stdcall decoration // only windows/386 requires stdcall decoration
if SysArch.Family == sys.I386 && m.argsize >= 0 { if SysArch.Family == sys.I386 && m.argsize >= 0 {
......
...@@ -594,7 +594,7 @@ func (ctxt *Link) symtab() { ...@@ -594,7 +594,7 @@ func (ctxt *Link) symtab() {
// compiler-provided size, so read it from the type data. // compiler-provided size, so read it from the type data.
moduledatatype := ctxt.Syms.ROLookup("type.runtime.moduledata", 0) moduledatatype := ctxt.Syms.ROLookup("type.runtime.moduledata", 0)
moduledata.Size = decodetypeSize(ctxt.Arch, moduledatatype) moduledata.Size = decodetypeSize(ctxt.Arch, moduledatatype)
Symgrow(ctxt, moduledata, moduledata.Size) Symgrow(moduledata, moduledata.Size)
lastmoduledatap := ctxt.Syms.Lookup("runtime.lastmoduledatap", 0) lastmoduledatap := ctxt.Syms.Lookup("runtime.lastmoduledatap", 0)
if lastmoduledatap.Type != obj.SDYNIMPORT { if lastmoduledatap.Type != obj.SDYNIMPORT {
......
...@@ -41,7 +41,7 @@ func addcall(ctxt *ld.Link, s *ld.Symbol, t *ld.Symbol) { ...@@ -41,7 +41,7 @@ func addcall(ctxt *ld.Link, s *ld.Symbol, t *ld.Symbol) {
s.Attr |= ld.AttrReachable s.Attr |= ld.AttrReachable
i := s.Size i := s.Size
s.Size += 4 s.Size += 4
ld.Symgrow(ctxt, s, s.Size) ld.Symgrow(s, s.Size)
r := ld.Addrel(s) r := ld.Addrel(s)
r.Sym = t r.Sym = t
r.Off = int32(i) r.Off = int32(i)
...@@ -136,7 +136,7 @@ func gentext(ctxt *ld.Link) { ...@@ -136,7 +136,7 @@ func gentext(ctxt *ld.Link) {
o(0x8d, 0x99) o(0x8d, 0x99)
i := initfunc.Size i := initfunc.Size
initfunc.Size += 4 initfunc.Size += 4
ld.Symgrow(ctxt, initfunc, initfunc.Size) ld.Symgrow(initfunc, initfunc.Size)
r := ld.Addrel(initfunc) r := ld.Addrel(initfunc)
r.Sym = ctxt.Syms.Lookup("_GLOBAL_OFFSET_TABLE_", 0) r.Sym = ctxt.Syms.Lookup("_GLOBAL_OFFSET_TABLE_", 0)
r.Off = int32(i) r.Off = int32(i)
......
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