// is used to determine when the section can be split if it becomes too large, to ensure that
// the trampolines are in the same section as the function that uses them.
func maxSizeTrampolinesPPC64(s *sym.Symbol, isTramp bool) uint64 {
- // If Thearch.Trampoline is nil, then trampoline support is not available on this arch.
+ // If thearch.Trampoline is nil, then trampoline support is not available on this arch.
// A trampoline does not need any dependent trampolines.
- if Thearch.Trampoline == nil || isTramp {
+ if thearch.Trampoline == nil || isTramp {
return 0
}
// On PPC64 & PPC64LE the text sections might be split but will still insert trampolines
// where necessary.
func trampoline(ctxt *Link, s *sym.Symbol) {
- if Thearch.Trampoline == nil {
+ if thearch.Trampoline == nil {
return // no need or no support of trampolines on this arch
}
continue
}
- Thearch.Trampoline(ctxt, r, s)
+ thearch.Trampoline(ctxt, r, s)
}
}
case 8:
o = int64(ctxt.Arch.ByteOrder.Uint64(s.P[off:]))
}
- if !Thearch.Archreloc(ctxt, r, s, &o) {
+ if !thearch.Archreloc(ctxt, r, s, &o) {
Errorf(s, "unknown reloc to %v: %d (%s)", r.Sym.Name, r.Type, sym.RelocName(ctxt.Arch, r.Type))
}
case objabi.R_TLS_LE:
if ctxt.BuildMode == BuildModePIE && ctxt.IsELF {
// We are linking the final executable, so we
// can optimize any TLS IE relocation to LE.
- if Thearch.TLSIEtoLE == nil {
+ if thearch.TLSIEtoLE == nil {
log.Fatalf("internal linking of TLS IE not supported on %v", ctxt.Arch.Family)
}
- Thearch.TLSIEtoLE(s, int(off), int(r.Siz))
+ thearch.TLSIEtoLE(s, int(off), int(r.Siz))
o = int64(ctxt.Tlsoffset)
// TODO: o += r.Add when ctxt.Arch.Family != sys.AMD64?
// Why do we treat r.Add differently on AMD64?
}
if r.Variant != sym.RV_NONE {
- o = Thearch.Archrelocvariant(ctxt, r, s, o)
+ o = thearch.Archrelocvariant(ctxt, r, s, o)
}
if false {
// It's expected that some relocations will be done
// later by relocsym (R_TLS_LE, R_ADDROFF), so
// don't worry if Adddynrel returns false.
- Thearch.Adddynrel(ctxt, s, r)
+ thearch.Adddynrel(ctxt, s, r)
continue
}
if r.Sym != nil && r.Sym.Type == sym.SDYNIMPORT || r.Type >= 256 {
if r.Sym != nil && !r.Sym.Attr.Reachable() {
Errorf(s, "dynamic relocation to unreachable symbol %s", r.Sym.Name)
}
- if !Thearch.Adddynrel(ctxt, s, r) {
+ if !thearch.Adddynrel(ctxt, s, r) {
Errorf(s, "unsupported dynamic relocation for symbol %s (type=%d (%s) stype=%d (%s))", r.Sym.Name, r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Sym.Type, r.Sym.Type)
}
}
// symalign returns the required alignment for the given symbol s.
func symalign(s *sym.Symbol) int32 {
- min := int32(Thearch.Minalign)
+ min := int32(thearch.Minalign)
if s.Align >= min {
return s.Align
} else if s.Align != 0 {
// If we align it, we waste a lot of space to padding.
return min
}
- align := int32(Thearch.Maxalign)
+ align := int32(thearch.Maxalign)
for int64(align) > s.Size && align > min {
align >>= 1
}
fs.AddUint8(0) // augmentation ""
dwarf.Uleb128put(dwarfctxt, fs, 1) // code_alignment_factor
dwarf.Sleb128put(dwarfctxt, fs, dataAlignmentFactor) // all CFI offset calculations include multiplication with this factor
- dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfreglr)) // return_address_register
+ dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfreglr)) // return_address_register
fs.AddUint8(dwarf.DW_CFA_def_cfa) // Set the current frame address..
- dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfregsp)) // ...to use the value in the platform's SP register (defined in l.go)...
+ dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfregsp)) // ...to use the value in the platform's SP register (defined in l.go)...
if haslinkregister(ctxt) {
dwarf.Uleb128put(dwarfctxt, fs, int64(0)) // ...plus a 0 offset.
fs.AddUint8(dwarf.DW_CFA_same_value) // The platform's link register is unchanged during the prologue.
- dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfreglr))
+ dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfreglr))
fs.AddUint8(dwarf.DW_CFA_val_offset) // The previous value...
- dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfregsp)) // ...of the platform's SP register...
+ dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfregsp)) // ...of the platform's SP register...
dwarf.Uleb128put(dwarfctxt, fs, int64(0)) // ...is CFA+0.
} else {
dwarf.Uleb128put(dwarfctxt, fs, int64(ctxt.Arch.PtrSize)) // ...plus the word size (because the call instruction implicitly adds one word to the frame).
fs.AddUint8(dwarf.DW_CFA_offset_extended) // The previous value...
- dwarf.Uleb128put(dwarfctxt, fs, int64(Thearch.Dwarfreglr)) // ...of the return address...
+ dwarf.Uleb128put(dwarfctxt, fs, int64(thearch.Dwarfreglr)) // ...of the return address...
dwarf.Uleb128put(dwarfctxt, fs, int64(-ctxt.Arch.PtrSize)/dataAlignmentFactor) // ...is saved at [CFA - (PtrSize/4)].
}
// The return address is preserved at (CFA-frame_size)
// after a stack frame has been allocated.
deltaBuf = append(deltaBuf, dwarf.DW_CFA_offset_extended_sf)
- deltaBuf = dwarf.AppendUleb128(deltaBuf, uint64(Thearch.Dwarfreglr))
+ deltaBuf = dwarf.AppendUleb128(deltaBuf, uint64(thearch.Dwarfreglr))
deltaBuf = dwarf.AppendSleb128(deltaBuf, -int64(pcsp.value)/dataAlignmentFactor)
} else {
// The return address is restored into the link register
// when a stack frame has been de-allocated.
deltaBuf = append(deltaBuf, dwarf.DW_CFA_same_value)
- deltaBuf = dwarf.AppendUleb128(deltaBuf, uint64(Thearch.Dwarfreglr))
+ deltaBuf = dwarf.AppendUleb128(deltaBuf, uint64(thearch.Dwarfreglr))
}
deltaBuf = appendPCDeltaCFA(ctxt.Arch, deltaBuf, int64(nextpc)-int64(pcsp.pc), int64(pcsp.value))
} else {
if !r.Xsym.Attr.Reachable() {
Errorf(s, "unreachable reloc %d (%s) target %v", r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Xsym.Name)
}
- if !Thearch.Elfreloc1(ctxt, r, int64(uint64(s.Value+int64(r.Off))-sect.Vaddr)) {
+ if !thearch.Elfreloc1(ctxt, r, int64(uint64(s.Value+int64(r.Off))-sect.Vaddr)) {
Errorf(s, "unsupported obj reloc %d (%s)/%d to %s", r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Siz, r.Sym.Name)
}
}
s.Type = sym.SELFRXSECT
}
- Thearch.Elfsetupplt(ctxt)
+ thearch.Elfsetupplt(ctxt)
s = ctxt.Syms.Lookup(elfRelType+".plt", 0)
s.Attr |= sym.AttrReachable
if interpreter == "" {
switch ctxt.HeadType {
case objabi.Hlinux:
- interpreter = Thearch.Linuxdynld
+ interpreter = thearch.Linuxdynld
case objabi.Hfreebsd:
- interpreter = Thearch.Freebsddynld
+ interpreter = thearch.Freebsddynld
case objabi.Hnetbsd:
- interpreter = Thearch.Netbsddynld
+ interpreter = thearch.Netbsddynld
case objabi.Hopenbsd:
- interpreter = Thearch.Openbsddynld
+ interpreter = thearch.Openbsddynld
case objabi.Hdragonfly:
- interpreter = Thearch.Dragonflydynld
+ interpreter = thearch.Dragonflydynld
case objabi.Hsolaris:
- interpreter = Thearch.Solarisdynld
+ interpreter = thearch.Solarisdynld
}
}
}
var (
- Thearch Arch
+ thearch Arch
Lcsize int32
rpath Rpath
Spsize int32
}
func libinit(ctxt *Link) {
- Funcalign = Thearch.Funcalign
+ Funcalign = thearch.Funcalign
// add goroot to the end of the libdir list.
suffix := ""
if !r.Xsym.Attr.Reachable() {
Errorf(s, "unreachable reloc %d (%s) target %v", r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Xsym.Name)
}
- if !Thearch.Machoreloc1(ctxt.Arch, ctxt.Out, s, r, int64(uint64(s.Value+int64(r.Off))-sect.Vaddr)) {
+ if !thearch.Machoreloc1(ctxt.Arch, ctxt.Out, s, r, int64(uint64(s.Value+int64(r.Off))-sect.Vaddr)) {
Errorf(s, "unsupported obj reloc %d (%s)/%d to %s", r.Type, sym.RelocName(ctxt.Arch, r.Type), r.Siz, r.Sym.Name)
}
}
// Main is the main entry point for the linker code.
func Main(arch *sys.Arch, theArch Arch) {
- Thearch = theArch
+ thearch = theArch
ctxt := linknew(arch)
ctxt.Bso = bufio.NewWriter(os.Stdout)
}
ctxt.computeTLSOffset()
- Thearch.Archinit(ctxt)
+ thearch.Archinit(ctxt)
if ctxt.linkShared && !ctxt.IsELF {
Exitf("-linkshared can only be used on elf systems")
ctxt.dope()
}
ctxt.addexport()
- Thearch.Gentext(ctxt) // trampolines, call stubs, etc.
+ thearch.Gentext(ctxt) // trampolines, call stubs, etc.
ctxt.textbuildid()
ctxt.textaddress()
ctxt.pclntab()
ctxt.dodata()
ctxt.address()
ctxt.reloc()
- Thearch.Asmb(ctxt)
+ thearch.Asmb(ctxt)
ctxt.undef()
ctxt.hostlink()
ctxt.archive()
if r.Xsym.Dynid < 0 {
Errorf(sym, "reloc %d to non-coff symbol %s (outer=%s) %d", r.Type, r.Sym.Name, r.Xsym.Name, r.Sym.Type)
}
- if !Thearch.PEreloc1(ctxt.Arch, ctxt.Out, sym, r, int64(uint64(sym.Value+int64(r.Off))-base)) {
+ if !thearch.PEreloc1(ctxt.Arch, ctxt.Out, sym, r, int64(uint64(sym.Value+int64(r.Off))-base)) {
Errorf(sym, "unsupported obj reloc %d/%d to %s", r.Type, r.Siz, r.Sym.Name)
}
relocs++
// Then control flow passes to ld.Main, which parses flags, makes
// some configuration decisions, and then gives the architecture
// packages a second chance to modify the linker's configuration
-// via the ld.Thearch.Archinit function.
+// via the ld.Arch.Archinit function.
func main() {
var arch *sys.Arch