Skip to content

Commit 8f3c8a3

Browse files
committed
cmd/link: make DynlinkingGo a method
This will allow it to depend on whether plugin.Open is a symbol to be linked in. Change-Id: Ie9aa4216f2510fe8b10bc4665c8b19622b7122ea Reviewed-on: https://go-review.googlesource.com/27819 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 7f27f1d commit 8f3c8a3

16 files changed

Lines changed: 36 additions & 36 deletions

File tree

src/cmd/link/internal/amd64/asm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func Addcall(ctxt *ld.Link, s *ld.Symbol, t *ld.Symbol) int64 {
5555
}
5656

5757
func gentext(ctxt *ld.Link) {
58-
if !ld.DynlinkingGo() {
58+
if !ctxt.DynlinkingGo() {
5959
return
6060
}
6161
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0)
@@ -342,7 +342,7 @@ func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
342342
case obj.R_CALL:
343343
if r.Siz == 4 {
344344
if r.Xsym.Type == obj.SDYNIMPORT {
345-
if ld.DynlinkingGo() {
345+
if ctxt.DynlinkingGo() {
346346
ld.Thearch.Vput(ld.R_X86_64_PLT32 | uint64(elfsym)<<32)
347347
} else {
348348
ld.Thearch.Vput(ld.R_X86_64_GOTPCREL | uint64(elfsym)<<32)

src/cmd/link/internal/amd64/obj.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func archinit(ctxt *ld.Link) {
8989
ld.Linkmode = ld.LinkInternal
9090
}
9191

92-
if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ld.DynlinkingGo() {
92+
if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ctxt.DynlinkingGo() {
9393
ld.Linkmode = ld.LinkExternal
9494
}
9595

src/cmd/link/internal/arm/asm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import (
5959
// c: R_ARM_GOT_PREL local.moduledata
6060

6161
func gentext(ctxt *ld.Link) {
62-
if !ld.DynlinkingGo() {
62+
if !ctxt.DynlinkingGo() {
6363
return
6464
}
6565
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0)

src/cmd/link/internal/arm/obj.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func archinit(ctxt *ld.Link) {
8585
ld.Linkmode = ld.LinkInternal
8686
}
8787

88-
if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ld.DynlinkingGo() {
88+
if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ctxt.DynlinkingGo() {
8989
ld.Linkmode = ld.LinkExternal
9090
}
9191

src/cmd/link/internal/arm64/asm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
)
4040

4141
func gentext(ctxt *ld.Link) {
42-
if !ld.DynlinkingGo() {
42+
if !ctxt.DynlinkingGo() {
4343
return
4444
}
4545
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0)
@@ -249,7 +249,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
249249
// (https://sourceware.org/bugzilla/show_bug.cgi?id=18270). So
250250
// we convert the adrp; ld64 + R_ARM64_GOTPCREL into adrp;
251251
// add + R_ADDRARM64.
252-
if !(r.Sym.Version != 0 || (r.Sym.Type&obj.SHIDDEN != 0) || r.Sym.Attr.Local()) && r.Sym.Type == obj.STEXT && ld.DynlinkingGo() {
252+
if !(r.Sym.Version != 0 || (r.Sym.Type&obj.SHIDDEN != 0) || r.Sym.Attr.Local()) && r.Sym.Type == obj.STEXT && ctxt.DynlinkingGo() {
253253
if o2&0xffc00000 != 0xf9400000 {
254254
ctxt.Diag("R_ARM64_GOTPCREL against unexpected instruction %x", o2)
255255
}

src/cmd/link/internal/arm64/obj.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func archinit(ctxt *ld.Link) {
103103
break
104104
}
105105

106-
if ld.Buildmode == ld.BuildmodeCShared || ld.DynlinkingGo() {
106+
if ld.Buildmode == ld.BuildmodeCShared || ctxt.DynlinkingGo() {
107107
ld.Linkmode = ld.LinkExternal
108108
}
109109

src/cmd/link/internal/ld/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func relocsym(ctxt *Link, s *Symbol) {
360360

361361
// We need to be able to reference dynimport symbols when linking against
362362
// shared libraries, and Solaris needs it always
363-
if HEADTYPE != obj.Hsolaris && r.Sym != nil && r.Sym.Type == obj.SDYNIMPORT && !DynlinkingGo() {
363+
if HEADTYPE != obj.Hsolaris && r.Sym != nil && r.Sym.Type == obj.SDYNIMPORT && !ctxt.DynlinkingGo() {
364364
if !(SysArch.Family == sys.PPC64 && Linkmode == LinkExternal && r.Sym.Name == ".TOC.") {
365365
ctxt.Diag("unhandled relocation for %s (type %d rtype %d)", r.Sym.Name, r.Sym.Type, r.Type)
366366
}

src/cmd/link/internal/ld/deadcode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func deadcode(ctxt *Link) {
6363
methSym := Linkrlookup(ctxt, "reflect.Value.Method", 0)
6464
reflectSeen := false
6565

66-
if DynlinkingGo() {
66+
if ctxt.DynlinkingGo() {
6767
// Exported methods may satisfy interfaces we don't know
6868
// about yet when dynamically linking.
6969
reflectSeen = true

src/cmd/link/internal/ld/lib.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ type Section struct {
155155

156156
// DynlinkingGo returns whether we are producing Go code that can live
157157
// in separate shared libraries linked together at runtime.
158-
func DynlinkingGo() bool {
158+
func (ctxt *Link) DynlinkingGo() bool {
159159
return Buildmode == BuildmodeShared || *FlagLinkshared
160160
}
161161

@@ -307,7 +307,7 @@ func libinit(ctxt *Link) {
307307
}
308308
}
309309

310-
if !DynlinkingGo() {
310+
if !ctxt.DynlinkingGo() {
311311
Linklookup(ctxt, *flagEntrySymbol, 0).Type = obj.SXREF
312312
}
313313
}
@@ -466,7 +466,7 @@ func (ctxt *Link) loadlib() {
466466
if ctxt.Library[i].Shlib != "" {
467467
ldshlibsyms(ctxt, ctxt.Library[i].Shlib)
468468
} else {
469-
if DynlinkingGo() {
469+
if ctxt.DynlinkingGo() {
470470
Exitf("cannot implicitly include runtime/cgo in a shared library")
471471
}
472472
objfile(ctxt, ctxt.Library[i])
@@ -998,7 +998,7 @@ func (l *Link) hostlink() {
998998
argv = append(argv, "-shared")
999999
}
10001000

1001-
if Iself && DynlinkingGo() {
1001+
if Iself && l.DynlinkingGo() {
10021002
// We force all symbol resolution to be done at program startup
10031003
// because lazy PLT resolution can use large amounts of stack at
10041004
// times we cannot allow it to do so.
@@ -1639,7 +1639,7 @@ func stkcheck(ctxt *Link, up *chain, depth int) int {
16391639
// should never be called directly.
16401640
// onlyctxt.Diagnose the direct caller.
16411641
// TODO(mwhudson): actually think about this.
1642-
if depth == 1 && s.Type != obj.SXREF && !DynlinkingGo() &&
1642+
if depth == 1 && s.Type != obj.SXREF && !ctxt.DynlinkingGo() &&
16431643
Buildmode != BuildmodeCArchive && Buildmode != BuildmodePIE && Buildmode != BuildmodeCShared {
16441644
ctxt.Diag("call to external function %s", s.Name)
16451645
}

src/cmd/link/internal/ld/objfile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ func (r *objReader) readSymName() string {
585585
}
586586
r.rdBuf = adjName[:0] // in case 2*n wasn't enough
587587

588-
if DynlinkingGo() {
588+
if r.ctxt.DynlinkingGo() {
589589
// These types are included in the symbol
590590
// table when dynamically linking. To keep
591591
// binary size down, we replace the names

0 commit comments

Comments
 (0)