}
}
-func asmb2(ctxt *ld.Link, _ *loader.Loader) {
- if ctxt.IsDarwin() {
- panic("darwin should be generic")
- }
- if ctxt.IsElf() {
- panic("elf should be generic")
- }
- if ctxt.IsWindows() {
- panic("pe should be generic")
- }
-
- switch ctxt.HeadType {
- default:
- ld.Errorf(nil, "unknown header type %v", ctxt.HeadType)
- fallthrough
-
- case objabi.Hplan9:
- break
- }
-
- ld.Symsize = 0
- ld.Spsize = 0
- ld.Lcsize = 0
- if !*ld.FlagS {
- *ld.FlagS = true
- symo := int64(ld.Segdata.Fileoff + ld.Segdata.Filelen)
- ctxt.Out.SeekSet(symo)
- ld.Asmplan9sym(ctxt)
- }
-
- ctxt.Out.SeekSet(0)
- magic := uint32(4*26*26 + 7)
- ld.WritePlan9Header(ctxt.Out, magic, ld.Entryvalue(ctxt), true)
-}
-
func tlsIEtoLE(P []byte, off, size int) {
// Transform the PC-relative instruction into a constant load.
// That is,
// 0xCC is INT $3 - breakpoint instruction
CodePad: []byte{0xCC},
+ Plan9Magic: uint32(4*26*26 + 7),
+ Plan9_64Bit: true,
+
Adddynrel: adddynrel,
Archinit: archinit,
Archreloc: archreloc,
Archrelocvariant: archrelocvariant,
- Asmb2: asmb2,
Elfreloc1: elfreloc1,
Elfsetupplt: elfsetupplt,
Gentext: gentext,
ldr.Errorf(s, "addgotsym: unsupported binary format")
}
}
-
-func asmb2(ctxt *ld.Link, _ *loader.Loader) {
- if ctxt.IsElf() {
- panic("elf should be generic")
- }
- if ctxt.IsWindows() {
- panic("pe should be generic")
- }
- /* output symbol table */
- ld.Symsize = 0
-
- ld.Lcsize = 0
- if !*ld.FlagS {
- symo := uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen)
- ctxt.Out.SeekSet(int64(symo))
- ld.Asmplan9sym(ctxt)
- }
-
- ld.WritePlan9Header(ctxt.Out, 0x647, ld.Entryvalue(ctxt), false)
-
- if *ld.FlagC {
- fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
- fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
- fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
- fmt.Printf("symsize=%d\n", ld.Symsize)
- fmt.Printf("lcsize=%d\n", ld.Lcsize)
- fmt.Printf("total=%d\n", ld.Segtext.Filelen+ld.Segdata.Length+uint64(ld.Symsize)+uint64(ld.Lcsize))
- }
-}
Dwarfregsp: dwarfRegSP,
Dwarfreglr: dwarfRegLR,
+ Plan9Magic: 0x647,
+
Adddynrel: adddynrel,
Archinit: archinit,
Archreloc: archreloc,
Archrelocvariant: archrelocvariant,
Trampoline: trampoline,
- Asmb2: asmb2,
Elfreloc1: elfreloc1,
Elfsetupplt: elfsetupplt,
Gentext: gentext,
import (
"cmd/link/internal/loader"
+ "fmt"
"sync"
)
// - writing out the architecture specific pieces.
// This function handles the second part.
func asmb2(ctxt *Link) bool {
- // TODO: Spsize is only used for plan9
+ if ctxt.IsAIX() || ctxt.IsWasm() {
+ return false
+ }
+
+ Symsize = 0
+ Spsize = 0
+ Lcsize = 0
+
if ctxt.IsDarwin() {
machlink := Domacholink(ctxt)
- Symsize = 0
- Spsize = 0
- Lcsize = 0
if !*FlagS && ctxt.IsExternal() {
symo := int64(Segdwarf.Fileoff + uint64(Rnd(int64(Segdwarf.Filelen), int64(*FlagRound))) + uint64(machlink))
ctxt.Out.SeekSet(symo)
}
ctxt.Out.SeekSet(0)
Asmbmacho(ctxt)
- return true
}
+
if ctxt.IsElf() {
- Symsize = 0
- Spsize = 0
- Lcsize = 0
var symo int64
if !*FlagS {
symo = int64(Segdwarf.Fileoff + Segdwarf.Filelen)
}
ctxt.Out.SeekSet(0)
Asmbelf(ctxt, symo)
- return true
}
+
if ctxt.IsWindows() {
- Symsize = 0
- Spsize = 0
- Lcsize = 0
Asmbpe(ctxt)
- return true
}
- return false
+
+ if ctxt.IsPlan9() {
+ if !*FlagS {
+ *FlagS = true
+ symo := int64(Segdata.Fileoff + Segdata.Filelen)
+ ctxt.Out.SeekSet(symo)
+ Asmplan9sym(ctxt)
+ }
+ ctxt.Out.SeekSet(0)
+ WritePlan9Header(ctxt.Out, thearch.Plan9Magic, Entryvalue(ctxt), thearch.Plan9_64Bit)
+ }
+
+ if *FlagC {
+ fmt.Printf("textsize=%d\n", Segtext.Filelen)
+ fmt.Printf("datsize=%d\n", Segdata.Filelen)
+ fmt.Printf("bsssize=%d\n", Segdata.Length-Segdata.Filelen)
+ fmt.Printf("symsize=%d\n", Symsize)
+ fmt.Printf("lcsize=%d\n", Lcsize)
+ fmt.Printf("total=%d\n", Segtext.Filelen+Segdata.Length+uint64(Symsize)+uint64(Lcsize))
+ }
+
+ return true
}
// WritePlan9Header writes out the plan9 header at the present position in the OutBuf.
// Set to true to write all text blocks in with CodeBlkWrite
WriteTextBlocks bool
+ // Plan 9 variables.
+ Plan9Magic uint32
+ Plan9_64Bit bool
+
Adddynrel func(*Target, *loader.Loader, *ArchSyms, loader.Sym, loader.Reloc2, int) bool
Archinit func(*Link)
// Archreloc is an arch-specific hook that assists in relocation processing
ldr.Errorf(s, "addgotsym: unsupported binary format")
}
}
-
-func asmb2(ctxt *ld.Link, _ *loader.Loader) {
- if ctxt.IsDarwin() {
- panic("darwin should be generic")
- }
- if ctxt.IsElf() {
- panic("elf should be generic")
- }
- if ctxt.IsWindows() {
- panic("pe should be generic")
- }
-
- ld.Symsize = 0
- ld.Spsize = 0
- ld.Lcsize = 0
- if !*ld.FlagS {
- symo := uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen)
- ctxt.Out.SeekSet(int64(symo))
- ld.Asmplan9sym(ctxt)
- }
-
- ctxt.Out.SeekSet(0)
- magic := uint32(4*11*11 + 7)
- ld.WritePlan9Header(ctxt.Out, magic, ld.Entryvalue(ctxt), false)
-}
// 0xCC is INT $3 - breakpoint instruction
CodePad: []byte{0xCC},
+ Plan9Magic: uint32(4*11*11 + 7),
+
Adddynrel: adddynrel,
Archinit: archinit,
Archreloc: archreloc,
Archrelocvariant: archrelocvariant,
- Asmb2: asmb2,
Elfreloc1: elfreloc1,
Elfsetupplt: elfsetupplt,
Gentext: gentext,