}
func gentext(ctxt *ld.Link) {
- if !ld.DynlinkingGo() {
+ if !ctxt.DynlinkingGo() {
return
}
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0)
case obj.R_CALL:
if r.Siz == 4 {
if r.Xsym.Type == obj.SDYNIMPORT {
- if ld.DynlinkingGo() {
+ if ctxt.DynlinkingGo() {
ld.Thearch.Vput(ld.R_X86_64_PLT32 | uint64(elfsym)<<32)
} else {
ld.Thearch.Vput(ld.R_X86_64_GOTPCREL | uint64(elfsym)<<32)
ld.Linkmode = ld.LinkInternal
}
- if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ld.DynlinkingGo() {
+ if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ctxt.DynlinkingGo() {
ld.Linkmode = ld.LinkExternal
}
// c: R_ARM_GOT_PREL local.moduledata
func gentext(ctxt *ld.Link) {
- if !ld.DynlinkingGo() {
+ if !ctxt.DynlinkingGo() {
return
}
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0)
ld.Linkmode = ld.LinkInternal
}
- if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ld.DynlinkingGo() {
+ if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ctxt.DynlinkingGo() {
ld.Linkmode = ld.LinkExternal
}
)
func gentext(ctxt *ld.Link) {
- if !ld.DynlinkingGo() {
+ if !ctxt.DynlinkingGo() {
return
}
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0)
// (https://sourceware.org/bugzilla/show_bug.cgi?id=18270). So
// we convert the adrp; ld64 + R_ARM64_GOTPCREL into adrp;
// 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 !(r.Sym.Version != 0 || (r.Sym.Type&obj.SHIDDEN != 0) || r.Sym.Attr.Local()) && r.Sym.Type == obj.STEXT && ctxt.DynlinkingGo() {
if o2&0xffc00000 != 0xf9400000 {
ctxt.Diag("R_ARM64_GOTPCREL against unexpected instruction %x", o2)
}
break
}
- if ld.Buildmode == ld.BuildmodeCShared || ld.DynlinkingGo() {
+ if ld.Buildmode == ld.BuildmodeCShared || ctxt.DynlinkingGo() {
ld.Linkmode = ld.LinkExternal
}
// We need to be able to reference dynimport symbols when linking against
// shared libraries, and Solaris needs it always
- if HEADTYPE != obj.Hsolaris && r.Sym != nil && r.Sym.Type == obj.SDYNIMPORT && !DynlinkingGo() {
+ if HEADTYPE != obj.Hsolaris && r.Sym != nil && r.Sym.Type == obj.SDYNIMPORT && !ctxt.DynlinkingGo() {
if !(SysArch.Family == sys.PPC64 && Linkmode == LinkExternal && r.Sym.Name == ".TOC.") {
ctxt.Diag("unhandled relocation for %s (type %d rtype %d)", r.Sym.Name, r.Sym.Type, r.Type)
}
methSym := Linkrlookup(ctxt, "reflect.Value.Method", 0)
reflectSeen := false
- if DynlinkingGo() {
+ if ctxt.DynlinkingGo() {
// Exported methods may satisfy interfaces we don't know
// about yet when dynamically linking.
reflectSeen = true
// DynlinkingGo returns whether we are producing Go code that can live
// in separate shared libraries linked together at runtime.
-func DynlinkingGo() bool {
+func (ctxt *Link) DynlinkingGo() bool {
return Buildmode == BuildmodeShared || *FlagLinkshared
}
}
}
- if !DynlinkingGo() {
+ if !ctxt.DynlinkingGo() {
Linklookup(ctxt, *flagEntrySymbol, 0).Type = obj.SXREF
}
}
if ctxt.Library[i].Shlib != "" {
ldshlibsyms(ctxt, ctxt.Library[i].Shlib)
} else {
- if DynlinkingGo() {
+ if ctxt.DynlinkingGo() {
Exitf("cannot implicitly include runtime/cgo in a shared library")
}
objfile(ctxt, ctxt.Library[i])
argv = append(argv, "-shared")
}
- if Iself && DynlinkingGo() {
+ if Iself && l.DynlinkingGo() {
// We force all symbol resolution to be done at program startup
// because lazy PLT resolution can use large amounts of stack at
// times we cannot allow it to do so.
// should never be called directly.
// onlyctxt.Diagnose the direct caller.
// TODO(mwhudson): actually think about this.
- if depth == 1 && s.Type != obj.SXREF && !DynlinkingGo() &&
+ if depth == 1 && s.Type != obj.SXREF && !ctxt.DynlinkingGo() &&
Buildmode != BuildmodeCArchive && Buildmode != BuildmodePIE && Buildmode != BuildmodeCShared {
ctxt.Diag("call to external function %s", s.Name)
}
}
r.rdBuf = adjName[:0] // in case 2*n wasn't enough
- if DynlinkingGo() {
+ if r.ctxt.DynlinkingGo() {
// These types are included in the symbol
// table when dynamically linking. To keep
// binary size down, we replace the names
putelfstr("")
}
- // When dynamically linking, we create Symbols by reading the names from
- // the symbol tables of the shared libraries and so the names need to
- // match exactly. Tools like DTrace will have to wait for now.
- if !DynlinkingGo() {
- // Rewrite · to . for ASCII-only tools like DTrace (sigh)
- s = strings.Replace(s, "·", ".", -1)
- }
-
off := len(Elfstrdat)
Elfstrdat = append(Elfstrdat, s...)
Elfstrdat = append(Elfstrdat, 0)
// To avoid filling the dynamic table with lots of unnecessary symbols,
// mark all Go symbols local (not global) in the final executable.
// But when we're dynamically linking, we need all those global symbols.
- if !DynlinkingGo() && Linkmode == LinkExternal && !x.Attr.CgoExportStatic() && elfshnum != SHN_UNDEF {
+ if !ctxt.DynlinkingGo() && Linkmode == LinkExternal && !x.Attr.CgoExportStatic() && elfshnum != SHN_UNDEF {
bind = STB_LOCAL
}
if x.Type&obj.SHIDDEN != 0 {
other = STV_HIDDEN
}
- if (Buildmode == BuildmodeCArchive || Buildmode == BuildmodePIE || DynlinkingGo()) && SysArch.Family == sys.PPC64 && type_ == STT_FUNC && x.Name != "runtime.duffzero" && x.Name != "runtime.duffcopy" {
+ if (Buildmode == BuildmodeCArchive || Buildmode == BuildmodePIE || ctxt.DynlinkingGo()) && SysArch.Family == sys.PPC64 && type_ == STT_FUNC && x.Name != "runtime.duffzero" && x.Name != "runtime.duffcopy" {
// On ppc64 the top three bits of the st_other field indicate how
// many instructions separate the global and local entry points. In
// our case it is two instructions, indicated by the value 3.
other |= 3 << 5
}
- if DynlinkingGo() && bind == STB_GLOBAL && elfbind == STB_LOCAL && x.Type == obj.STEXT {
+ // When dynamically linking, we create Symbols by reading the names from
+ // the symbol tables of the shared libraries and so the names need to
+ // match exactly. Tools like DTrace will have to wait for now.
+ if !ctxt.DynlinkingGo() {
+ // Rewrite · to . for ASCII-only tools like DTrace (sigh)
+ s = strings.Replace(s, "·", ".", -1)
+ }
+
+ if ctxt.DynlinkingGo() && bind == STB_GLOBAL && elfbind == STB_LOCAL && x.Type == obj.STEXT {
// When dynamically linking, we want references to functions defined
// in this module to always be to the function object, not to the
// PLT. We force this by writing an additional local symbol for every
s.Size = 0
s.Attr |= AttrReachable
symtyperel = s
- } else if !DynlinkingGo() {
+ } else if !ctxt.DynlinkingGo() {
s = Linklookup(ctxt, "type.*", 0)
s.Type = obj.STYPE
)
var symgofuncrel *Symbol
- if !DynlinkingGo() {
+ if !ctxt.DynlinkingGo() {
if UseRelro() {
symgofuncrel = groupSym("go.funcrel.*", obj.SGOFUNCRELRO)
} else {
switch {
case strings.HasPrefix(s.Name, "type."):
- if !DynlinkingGo() {
+ if !ctxt.DynlinkingGo() {
s.Attr |= AttrHidden
}
if UseRelro() {
s.Outer = symgcbits
case strings.HasSuffix(s.Name, "·f"):
- if !DynlinkingGo() {
+ if !ctxt.DynlinkingGo() {
s.Attr |= AttrHidden
}
if UseRelro() {
}
func gentext(ctxt *ld.Link) {
- if ld.DynlinkingGo() {
+ if ctxt.DynlinkingGo() {
genaddmoduledata(ctxt)
}
//
// The job of appending the moduledata is delegated to runtime.addmoduledata.
func gentext(ctxt *ld.Link) {
- if !ld.DynlinkingGo() {
+ if !ctxt.DynlinkingGo() {
return
}
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0)
ld.Linkmode = ld.LinkInternal
}
- if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ld.DynlinkingGo() {
+ if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ctxt.DynlinkingGo() {
ld.Linkmode = ld.LinkExternal
}
}
func gentext(ctxt *ld.Link) {
- if ld.DynlinkingGo() {
+ if ctxt.DynlinkingGo() {
// We need get_pc_thunk.
} else {
switch ld.Buildmode {
ld.Linkmode = ld.LinkInternal
}
- if (ld.Buildmode == ld.BuildmodeCArchive && ld.Iself) || ld.Buildmode == ld.BuildmodeCShared || ld.Buildmode == ld.BuildmodePIE || ld.DynlinkingGo() {
+ if (ld.Buildmode == ld.BuildmodeCArchive && ld.Iself) || ld.Buildmode == ld.BuildmodeCShared || ld.Buildmode == ld.BuildmodePIE || ctxt.DynlinkingGo() {
ld.Linkmode = ld.LinkExternal
got := ld.Linklookup(ctxt, "_GLOBAL_OFFSET_TABLE_", 0)
got.Type = obj.SDYNIMPORT