Commit 4338e5a8 authored by Michael Matloob's avatar Michael Matloob

cmd/link/internal: remove global Ctxt variable

This change threads the *ld.Link Ctxt variable through
code in arch-specific packages. This removes all remaining
uses of Ctxt, so remove the global variable too.

This CL continues the work in golang.org/cl/27408

Updates #16818

Change-Id: I5f4536847a1825fd0b944824e8ae4e122ec0fb78
Reviewed-on: https://go-review.googlesource.com/27459
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent e2b30e90
This diff is collapsed.
......@@ -82,9 +82,7 @@ func linkarchinit() {
ld.Thearch.Solarisdynld = "/lib/amd64/ld.so.1"
}
func archinit() {
ctxt := ld.Ctxt
func archinit(ctxt *ld.Link) {
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
// Go was built; see ../../make.bash.
if ld.Linkmode == ld.LinkAuto && obj.Getgoextlinkenabled() == "0" {
......@@ -153,7 +151,7 @@ func archinit() {
obj.Hopenbsd, /* openbsd */
obj.Hdragonfly, /* dragonfly */
obj.Hsolaris: /* solaris */
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE
if ld.INITTEXT == -1 {
......@@ -167,7 +165,7 @@ func archinit() {
}
case obj.Hnacl:
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.Debug['w']++ // disable dwarf, which gets confused and is useless anyway
ld.HEADR = 0x10000
ld.Funcalign = 32
......
This diff is collapsed.
......@@ -78,7 +78,7 @@ func linkarchinit() {
ld.Thearch.Solarisdynld = "XXX"
}
func archinit() {
func archinit(ctxt *ld.Link) {
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
// Go was built; see ../../make.bash.
if ld.Linkmode == ld.LinkAuto && obj.Getgoextlinkenabled() == "0" {
......@@ -128,7 +128,7 @@ func archinit() {
obj.Hopenbsd:
ld.Debug['d'] = 0
// with dynamic linking
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE
if ld.INITTEXT == -1 {
ld.INITTEXT = 0x10000 + int64(ld.HEADR)
......@@ -141,7 +141,7 @@ func archinit() {
}
case obj.Hnacl:
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = 0x10000
ld.Funcalign = 16
if ld.INITTEXT == -1 {
......
......@@ -38,23 +38,23 @@ import (
"log"
)
func gentext() {
func gentext(ctxt *ld.Link) {
if !ld.DynlinkingGo() {
return
}
addmoduledata := ld.Linklookup(ld.Ctxt, "runtime.addmoduledata", 0)
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0)
if addmoduledata.Type == obj.STEXT {
// we're linking a module containing the runtime -> no need for
// an init function
return
}
addmoduledata.Attr |= ld.AttrReachable
initfunc := ld.Linklookup(ld.Ctxt, "go.link.addmoduledata", 0)
initfunc := ld.Linklookup(ctxt, "go.link.addmoduledata", 0)
initfunc.Type = obj.STEXT
initfunc.Attr |= ld.AttrLocal
initfunc.Attr |= ld.AttrReachable
o := func(op uint32) {
ld.Adduint32(ld.Ctxt, initfunc, op)
ld.Adduint32(ctxt, initfunc, op)
}
// 0000000000000000 <local.dso_init>:
// 0: 90000000 adrp x0, 0 <runtime.firstmoduledata>
......@@ -66,7 +66,7 @@ func gentext() {
rel := ld.Addrel(initfunc)
rel.Off = 0
rel.Siz = 8
rel.Sym = ld.Ctxt.Moduledata
rel.Sym = ctxt.Moduledata
rel.Type = obj.R_ADDRARM64
// 8: 14000000 bl 0 <runtime.addmoduledata>
......@@ -75,22 +75,22 @@ func gentext() {
rel = ld.Addrel(initfunc)
rel.Off = 8
rel.Siz = 4
rel.Sym = ld.Linklookup(ld.Ctxt, "runtime.addmoduledata", 0)
rel.Sym = ld.Linklookup(ctxt, "runtime.addmoduledata", 0)
rel.Type = obj.R_CALLARM64 // Really should be R_AARCH64_JUMP26 but doesn't seem to make any difference
ld.Ctxt.Textp = append(ld.Ctxt.Textp, initfunc)
initarray_entry := ld.Linklookup(ld.Ctxt, "go.link.addmoduledatainit", 0)
ctxt.Textp = append(ctxt.Textp, initfunc)
initarray_entry := ld.Linklookup(ctxt, "go.link.addmoduledatainit", 0)
initarray_entry.Attr |= ld.AttrReachable
initarray_entry.Attr |= ld.AttrLocal
initarray_entry.Type = obj.SINITARR
ld.Addaddr(ld.Ctxt, initarray_entry, initfunc)
ld.Addaddr(ctxt, initarray_entry, initfunc)
}
func adddynrel(s *ld.Symbol, r *ld.Reloc) {
func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) {
log.Fatalf("adddynrel not implemented")
}
func elfreloc1(r *ld.Reloc, sectoff int64) int {
func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
ld.Thearch.Vput(uint64(sectoff))
elfsym := r.Xsym.ElfsymForReloc()
......@@ -142,12 +142,12 @@ func elfreloc1(r *ld.Reloc, sectoff int64) int {
return 0
}
func elfsetupplt() {
func elfsetupplt(ctxt *ld.Link) {
// TODO(aram)
return
}
func machoreloc1(r *ld.Reloc, sectoff int64) int {
func machoreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
var v uint32
rs := r.Xsym
......@@ -157,7 +157,7 @@ func machoreloc1(r *ld.Reloc, sectoff int64) int {
// UNSIGNED relocation at all.
if rs.Type == obj.SHOSTOBJ || r.Type == obj.R_CALLARM64 || r.Type == obj.R_ADDRARM64 || r.Type == obj.R_ADDR {
if rs.Dynid < 0 {
ld.Ctxt.Diag("reloc %d to non-macho symbol %s type=%d", r.Type, rs.Name, rs.Type)
ctxt.Diag("reloc %d to non-macho symbol %s type=%d", r.Type, rs.Name, rs.Type)
return -1
}
......@@ -166,7 +166,7 @@ func machoreloc1(r *ld.Reloc, sectoff int64) int {
} else {
v = uint32(rs.Sect.Extnum)
if v == 0 {
ld.Ctxt.Diag("reloc %d to symbol %s in non-macho section %s type=%d", r.Type, rs.Name, rs.Sect.Name, rs.Type)
ctxt.Diag("reloc %d to symbol %s in non-macho section %s type=%d", r.Type, rs.Name, rs.Sect.Name, rs.Type)
return -1
}
}
......@@ -180,7 +180,7 @@ func machoreloc1(r *ld.Reloc, sectoff int64) int {
case obj.R_CALLARM64:
if r.Xadd != 0 {
ld.Ctxt.Diag("ld64 doesn't allow BR26 reloc with non-zero addend: %s+%d", rs.Name, r.Xadd)
ctxt.Diag("ld64 doesn't allow BR26 reloc with non-zero addend: %s+%d", rs.Name, r.Xadd)
}
v |= 1 << 24 // pc-relative bit
......@@ -226,8 +226,7 @@ func machoreloc1(r *ld.Reloc, sectoff int64) int {
return 0
}
func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
ctxt := ld.Ctxt
func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
if ld.Linkmode == ld.LinkExternal {
switch r.Type {
default:
......@@ -235,7 +234,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
case obj.R_ARM64_GOTPCREL:
var o1, o2 uint32
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
if ctxt.Arch.ByteOrder == binary.BigEndian {
o1 = uint32(*val >> 32)
o2 = uint32(*val)
} else {
......@@ -252,12 +251,12 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
// add + R_ADDRARM64.
if !(r.Sym.Version != 0 || (r.Sym.Type&obj.SHIDDEN != 0) || r.Sym.Attr.Local()) && r.Sym.Type == obj.STEXT && ld.DynlinkingGo() {
if o2&0xffc00000 != 0xf9400000 {
ld.Ctxt.Diag("R_ARM64_GOTPCREL against unexpected instruction %x", o2)
ctxt.Diag("R_ARM64_GOTPCREL against unexpected instruction %x", o2)
}
o2 = 0x91000000 | (o2 & 0x000003ff)
r.Type = obj.R_ADDRARM64
}
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
if ctxt.Arch.ByteOrder == binary.BigEndian {
*val = int64(o1)<<32 | int64(o2)
} else {
*val = int64(o2)<<32 | int64(o1)
......@@ -276,7 +275,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
}
if rs.Type != obj.SHOSTOBJ && rs.Type != obj.SDYNIMPORT && rs.Sect == nil {
ld.Ctxt.Diag("missing section for %s", rs.Name)
ctxt.Diag("missing section for %s", rs.Name)
}
r.Xsym = rs
......@@ -288,7 +287,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
if false && ld.HEADTYPE == obj.Hdarwin {
var o0, o1 uint32
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
if ctxt.Arch.ByteOrder == binary.BigEndian {
o0 = uint32(*val >> 32)
o1 = uint32(*val)
} else {
......@@ -305,7 +304,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
r.Xadd = 0
// when laid out, the instruction order must always be o1, o2.
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
if ctxt.Arch.ByteOrder == binary.BigEndian {
*val = int64(o0)<<32 | int64(o1)
} else {
*val = int64(o1)<<32 | int64(o0)
......@@ -330,18 +329,18 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
return 0
case obj.R_GOTOFF:
*val = ld.Symaddr(ctxt, r.Sym) + r.Add - ld.Symaddr(ctxt, ld.Linklookup(ld.Ctxt, ".got", 0))
*val = ld.Symaddr(ctxt, r.Sym) + r.Add - ld.Symaddr(ctxt, ld.Linklookup(ctxt, ".got", 0))
return 0
case obj.R_ADDRARM64:
t := ld.Symaddr(ctxt, r.Sym) + r.Add - ((s.Value + int64(r.Off)) &^ 0xfff)
if t >= 1<<32 || t < -1<<32 {
ld.Ctxt.Diag("program too large, address relocation distance = %d", t)
ctxt.Diag("program too large, address relocation distance = %d", t)
}
var o0, o1 uint32
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
if ctxt.Arch.ByteOrder == binary.BigEndian {
o0 = uint32(*val >> 32)
o1 = uint32(*val)
} else {
......@@ -353,7 +352,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
o1 |= uint32(t&0xfff) << 10
// when laid out, the instruction order must always be o1, o2.
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
if ctxt.Arch.ByteOrder == binary.BigEndian {
*val = int64(o0)<<32 | int64(o1)
} else {
*val = int64(o1)<<32 | int64(o0)
......@@ -363,13 +362,13 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
case obj.R_ARM64_TLS_LE:
r.Done = 0
if ld.HEADTYPE != obj.Hlinux {
ld.Ctxt.Diag("TLS reloc on unsupported OS %s", ld.Headstr(int(ld.HEADTYPE)))
ctxt.Diag("TLS reloc on unsupported OS %s", ld.Headstr(int(ld.HEADTYPE)))
}
// The TCB is two pointers. This is not documented anywhere, but is
// de facto part of the ABI.
v := r.Sym.Value + int64(2*ld.SysArch.PtrSize)
if v < 0 || v >= 32678 {
ld.Ctxt.Diag("TLS offset out of range %d", v)
ctxt.Diag("TLS offset out of range %d", v)
}
*val |= v << 5
return 0
......@@ -377,7 +376,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
case obj.R_CALLARM64:
t := (ld.Symaddr(ctxt, r.Sym) + r.Add) - (s.Value + int64(r.Off))
if t >= 1<<27 || t < -1<<27 {
ld.Ctxt.Diag("program too large, call relocation distance = %d", t)
ctxt.Diag("program too large, call relocation distance = %d", t)
}
*val |= (t >> 2) & 0x03ffffff
return 0
......@@ -386,7 +385,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
return -1
}
func archrelocvariant(r *ld.Reloc, s *ld.Symbol, t int64) int64 {
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
log.Fatalf("unexpected relocation variant")
return -1
}
......@@ -480,7 +479,7 @@ func asmb(ctxt *ld.Link) {
ld.Asmplan9sym(ctxt)
ld.Cflush()
sym := ld.Linklookup(ld.Ctxt, "pclntab", 0)
sym := ld.Linklookup(ctxt, "pclntab", 0)
if sym != nil {
ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ {
......@@ -497,7 +496,7 @@ func asmb(ctxt *ld.Link) {
}
}
ld.Ctxt.Cursym = nil
ctxt.Cursym = nil
if ld.Debug['v'] != 0 {
fmt.Fprintf(ld.Bso, "%5.2f header\n", obj.Cputime())
}
......
......@@ -79,7 +79,7 @@ func linkarchinit() {
ld.Thearch.Solarisdynld = "XXX"
}
func archinit() {
func archinit(ctxt *ld.Link) {
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
// Go was built; see ../../make.bash.
if ld.Linkmode == ld.LinkAuto && obj.Getgoextlinkenabled() == "0" {
......@@ -125,7 +125,7 @@ func archinit() {
}
case obj.Hlinux: /* arm64 elf */
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE
if ld.INITTEXT == -1 {
ld.INITTEXT = 0x10000 + int64(ld.HEADR)
......@@ -152,7 +152,7 @@ func archinit() {
}
case obj.Hnacl:
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = 0x10000
ld.Funcalign = 16
if ld.INITTEXT == -1 {
......
......@@ -399,7 +399,7 @@ func relocsym(ctxt *Link, s *Symbol) {
case 8:
o = int64(ctxt.Arch.ByteOrder.Uint64(s.P[off:]))
}
if Thearch.Archreloc(r, s, &o) < 0 {
if Thearch.Archreloc(ctxt, r, s, &o) < 0 {
ctxt.Diag("unknown reloc %d", r.Type)
}
......@@ -604,7 +604,7 @@ func relocsym(ctxt *Link, s *Symbol) {
}
if r.Variant != RV_NONE {
o = Thearch.Archrelocvariant(r, s, o)
o = Thearch.Archrelocvariant(ctxt, r, s, o)
}
if false {
......@@ -717,7 +717,7 @@ func dynrelocsym(ctxt *Link, s *Symbol) {
if r.Sym != nil && !r.Sym.Attr.Reachable() {
ctxt.Diag("internal inconsistency: dynamic symbol %s is not reachable.", r.Sym.Name)
}
Thearch.Adddynrel(s, r)
Thearch.Adddynrel(ctxt, s, r)
}
}
}
......
......@@ -1762,7 +1762,7 @@ func elfrelocsect(ctxt *Link, sect *Section, syms []*Symbol) {
if r.Xsym.ElfsymForReloc() == 0 {
ctxt.Diag("reloc %d to non-elf symbol %s (outer=%s) %d", r.Type, r.Sym.Name, r.Xsym.Name, r.Sym.Type)
}
if Thearch.Elfreloc1(r, int64(uint64(sym.Value+int64(r.Off))-sect.Vaddr)) < 0 {
if Thearch.Elfreloc1(ctxt, r, int64(uint64(sym.Value+int64(r.Off))-sect.Vaddr)) < 0 {
ctxt.Diag("unsupported obj reloc %d/%d to %s", r.Type, r.Siz, r.Sym.Name)
}
}
......@@ -1990,7 +1990,7 @@ func (ctxt *Link) doelf() {
s.Type = obj.SELFRXSECT
}
Thearch.Elfsetupplt()
Thearch.Elfsetupplt(ctxt)
s = Linklookup(ctxt, elfRelType+".plt", 0)
s.Attr |= AttrReachable
......
......@@ -95,16 +95,16 @@ type Arch struct {
Openbsddynld string
Dragonflydynld string
Solarisdynld string
Adddynrel func(*Symbol, *Reloc)
Archinit func()
Archreloc func(*Reloc, *Symbol, *int64) int
Archrelocvariant func(*Reloc, *Symbol, int64) int64
Adddynrel func(*Link, *Symbol, *Reloc)
Archinit func(*Link)
Archreloc func(*Link, *Reloc, *Symbol, *int64) int
Archrelocvariant func(*Link, *Reloc, *Symbol, int64) int64
Asmb func(*Link)
Elfreloc1 func(*Reloc, int64) int
Elfsetupplt func()
Gentext func()
Machoreloc1 func(*Reloc, int64) int
PEreloc1 func(*Reloc, int64) bool
Elfreloc1 func(*Link, *Reloc, int64) int
Elfsetupplt func(*Link)
Gentext func(*Link)
Machoreloc1 func(*Link, *Reloc, int64) int
PEreloc1 func(*Link, *Reloc, int64) bool
Wput func(uint16)
Lput func(uint32)
Vput func(uint64)
......@@ -209,8 +209,7 @@ var (
extldflags string
extar string
libgccfile string
debug_s int // backup old value of debug['s']
Ctxt *Link // Global pointer to ctxt used by arch-specific packages
debug_s int // backup old value of debug['s']
HEADR int32
HEADTYPE int32
INITRND int32
......
......@@ -841,7 +841,7 @@ func machorelocsect(ctxt *Link, sect *Section, syms []*Symbol) {
if r.Done != 0 {
continue
}
if Thearch.Machoreloc1(r, int64(uint64(sym.Value+int64(r.Off))-sect.Vaddr)) < 0 {
if Thearch.Machoreloc1(ctxt, r, int64(uint64(sym.Value+int64(r.Off))-sect.Vaddr)) < 0 {
ctxt.Diag("unsupported obj reloc %d/%d to %s", r.Type, r.Siz, r.Sym.Name)
}
}
......
......@@ -806,7 +806,7 @@ func perelocsect(ctxt *Link, sect *Section, syms []*Symbol) int {
if r.Xsym.Dynid < 0 {
ctxt.Diag("reloc %d to non-coff symbol %s (outer=%s) %d", r.Type, r.Sym.Name, r.Xsym.Name, r.Sym.Type)
}
if !Thearch.PEreloc1(r, int64(uint64(sym.Value+int64(r.Off))-PEBASE)) {
if !Thearch.PEreloc1(ctxt, r, int64(uint64(sym.Value+int64(r.Off))-PEBASE)) {
ctxt.Diag("unsupported obj reloc %d/%d to %s", r.Type, r.Siz, r.Sym.Name)
}
......
......@@ -49,7 +49,6 @@ func Ldmain() {
Bso = bufio.NewWriter(os.Stdout)
ctxt := linknew(SysArch)
Ctxt = ctxt // Export Ctxt because it's currently used by the arch-specific packages
ctxt.Bso = Bso
Debug = [128]int{}
......@@ -158,7 +157,7 @@ func Ldmain() {
headstring = Headstr(int(HEADTYPE))
}
Thearch.Archinit()
Thearch.Archinit(ctxt)
if Linkshared && !Iself {
Exitf("-linkshared can only be used on elf systems")
......@@ -202,7 +201,7 @@ func Ldmain() {
ctxt.dope()
}
ctxt.addexport()
Thearch.Gentext() // trampolines, call stubs, etc.
Thearch.Gentext(ctxt) // trampolines, call stubs, etc.
ctxt.textbuildid()
ctxt.textaddress()
ctxt.pclntab()
......
......@@ -38,13 +38,13 @@ import (
"log"
)
func gentext() {}
func gentext(ctxt *ld.Link) {}
func adddynrel(s *ld.Symbol, r *ld.Reloc) {
func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) {
log.Fatalf("adddynrel not implemented")
}
func elfreloc1(r *ld.Reloc, sectoff int64) int {
func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
// mips64 ELF relocation (endian neutral)
// offset uint64
// sym uint32
......@@ -93,16 +93,15 @@ func elfreloc1(r *ld.Reloc, sectoff int64) int {
return 0
}
func elfsetupplt() {
func elfsetupplt(ctxt *ld.Link) {
return
}
func machoreloc1(r *ld.Reloc, sectoff int64) int {
func machoreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
return -1
}
func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
ctxt := ld.Ctxt
func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
if ld.Linkmode == ld.LinkExternal {
switch r.Type {
default:
......@@ -121,7 +120,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
}
if rs.Type != obj.SHOSTOBJ && rs.Type != obj.SDYNIMPORT && rs.Sect == nil {
ld.Ctxt.Diag("missing section for %s", rs.Name)
ctxt.Diag("missing section for %s", rs.Name)
}
r.Xsym = rs
......@@ -143,7 +142,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
return 0
case obj.R_GOTOFF:
*val = ld.Symaddr(ctxt, r.Sym) + r.Add - ld.Symaddr(ctxt, ld.Linklookup(ld.Ctxt, ".got", 0))
*val = ld.Symaddr(ctxt, r.Sym) + r.Add - ld.Symaddr(ctxt, ld.Linklookup(ctxt, ".got", 0))
return 0
case obj.R_ADDRMIPS,
......@@ -161,7 +160,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
// thread pointer is at 0x7000 offset from the start of TLS data area
t := ld.Symaddr(ctxt, r.Sym) + r.Add - 0x7000
if t < -32768 || t >= 32678 {
ld.Ctxt.Diag("TLS offset out of range %d", t)
ctxt.Diag("TLS offset out of range %d", t)
}
o1 := ld.SysArch.ByteOrder.Uint32(s.P[r.Off:])
*val = int64(o1&0xffff0000 | uint32(t)&0xffff)
......@@ -179,7 +178,7 @@ func archreloc(r *ld.Reloc, s *ld.Symbol, val *int64) int {
return -1
}
func archrelocvariant(r *ld.Reloc, s *ld.Symbol, t int64) int64 {
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
return -1
}
......@@ -264,7 +263,7 @@ func asmb(ctxt *ld.Link) {
ld.Asmplan9sym(ctxt)
ld.Cflush()
sym := ld.Linklookup(ld.Ctxt, "pclntab", 0)
sym := ld.Linklookup(ctxt, "pclntab", 0)
if sym != nil {
ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ {
......@@ -276,7 +275,7 @@ func asmb(ctxt *ld.Link) {
}
}
ld.Ctxt.Cursym = nil
ctxt.Cursym = nil
if ld.Debug['v'] != 0 {
fmt.Fprintf(ld.Bso, "%5.2f header\n", obj.Cputime())
}
......
......@@ -92,7 +92,7 @@ func linkarchinit() {
ld.Thearch.Solarisdynld = "XXX"
}
func archinit() {
func archinit(ctxt *ld.Link) {
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
// Go was built; see ../../make.bash.
if ld.Linkmode == ld.LinkAuto && obj.Getgoextlinkenabled() == "0" {
......@@ -130,7 +130,7 @@ func archinit() {
}
case obj.Hlinux: /* mips64 elf */
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE
if ld.INITTEXT == -1 {
ld.INITTEXT = 0x10000 + int64(ld.HEADR)
......@@ -143,7 +143,7 @@ func archinit() {
}
case obj.Hnacl:
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = 0x10000
ld.Funcalign = 16
if ld.INITTEXT == -1 {
......
This diff is collapsed.
......@@ -93,7 +93,7 @@ func linkarchinit() {
ld.Thearch.Solarisdynld = "XXX"
}
func archinit() {
func archinit(ctxt *ld.Link) {
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
// Go was built; see ../../make.bash.
if ld.Linkmode == ld.LinkAuto && obj.Getgoextlinkenabled() == "0" {
......@@ -110,7 +110,7 @@ func archinit() {
}
if ld.Linkmode == ld.LinkExternal {
toc := ld.Linklookup(ld.Ctxt, ".TOC.", 0)
toc := ld.Linklookup(ctxt, ".TOC.", 0)
toc.Type = obj.SDYNIMPORT
}
......@@ -148,7 +148,7 @@ func archinit() {
if ld.SysArch == sys.ArchPPC64 {
ld.Debug['d'] = 1 // TODO(austin): ELF ABI v1 not supported yet
}
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE
if ld.INITTEXT == -1 {
ld.INITTEXT = 0x10000 + int64(ld.HEADR)
......@@ -161,7 +161,7 @@ func archinit() {
}
case obj.Hnacl:
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = 0x10000
ld.Funcalign = 16
if ld.INITTEXT == -1 {
......
This diff is collapsed.
......@@ -79,7 +79,7 @@ func linkarchinit() {
ld.Thearch.Solarisdynld = "XXX"
}
func archinit() {
func archinit(ctxt *ld.Link) {
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
// Go was built; see ../../make.bash.
if ld.Linkmode == ld.LinkAuto && obj.Getgoextlinkenabled() == "0" {
......@@ -95,7 +95,7 @@ func archinit() {
ld.Exitf("unknown -H option: %v", ld.HEADTYPE)
case obj.Hlinux: // s390x ELF
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE
if ld.INITTEXT == -1 {
ld.INITTEXT = 0x10000 + int64(ld.HEADR)
......
This diff is collapsed.
......@@ -78,7 +78,7 @@ func linkarchinit() {
ld.Thearch.Solarisdynld = "/lib/ld.so.1"
}
func archinit() {
func archinit(ctxt *ld.Link) {
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
// Go was built; see ../../make.bash.
if ld.Linkmode == ld.LinkAuto && obj.Getgoextlinkenabled() == "0" {
......@@ -87,7 +87,7 @@ func archinit() {
if ld.Buildmode == ld.BuildmodeCShared || ld.Buildmode == ld.BuildmodePIE || ld.DynlinkingGo() {
ld.Linkmode = ld.LinkExternal
got := ld.Linklookup(ld.Ctxt, "_GLOBAL_OFFSET_TABLE_", 0)
got := ld.Linklookup(ctxt, "_GLOBAL_OFFSET_TABLE_", 0)
got.Type = obj.SDYNIMPORT
got.Attr |= ld.AttrReachable
}
......@@ -145,7 +145,7 @@ func archinit() {
obj.Hfreebsd,
obj.Hnetbsd,
obj.Hopenbsd:
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE
if ld.INITTEXT == -1 {
......@@ -159,7 +159,7 @@ func archinit() {
}
case obj.Hnacl:
ld.Elfinit(ld.Ctxt)
ld.Elfinit(ctxt)
ld.HEADR = 0x10000
ld.Funcalign = 32
if ld.INITTEXT == -1 {
......@@ -173,7 +173,7 @@ func archinit() {
}
case obj.Hwindows: /* PE executable */
ld.Peinit(ld.Ctxt)
ld.Peinit(ctxt)
ld.HEADR = ld.PEFILEHEADR
if ld.INITTEXT == -1 {
......
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