本文整理匯總了Golang中cmd/internal/obj.Getgoarch函數的典型用法代碼示例。如果您正苦於以下問題:Golang Getgoarch函數的具體用法?Golang Getgoarch怎麽用?Golang Getgoarch使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Getgoarch函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: addinitarray
func addinitarray() (c *IMAGE_SECTION_HEADER) {
// The size below was determined by the specification for array relocations,
// and by observing what GCC writes here. If the initarray section grows to
// contain more than one constructor entry, the size will need to be 8 * constructor_count.
// However, the entire Go runtime is initialized from just one function, so it is unlikely
// that this will need to grow in the future.
var size int
switch obj.Getgoarch() {
default:
fmt.Fprintf(os.Stderr, "link: unknown architecture for PE: %q\n", obj.Getgoarch())
os.Exit(2)
case "386":
size = 4
case "amd64":
size = 8
}
c = addpesection(".ctors", size, size)
c.Characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
c.SizeOfRawData = uint32(size)
Cseek(int64(c.PointerToRawData))
chksectoff(c, Cpos())
init_entry := Linklookup(Ctxt, INITENTRY, 0)
addr := uint64(init_entry.Value) - init_entry.Sect.Vaddr
switch obj.Getgoarch() {
case "386":
Lputl(uint32(addr))
case "amd64":
Vputl(addr)
}
return c
}
示例2: main
func main() {
// disable timestamps for reproducible output
log.SetFlags(0)
log.SetPrefix("compile: ")
switch obj.Getgoarch() {
default:
fmt.Fprintf(os.Stderr, "compile: unknown architecture %q\n", obj.Getgoarch())
os.Exit(2)
case "386":
x86.Main()
case "amd64", "amd64p32":
amd64.Main()
case "arm":
arm.Main()
case "arm64":
arm64.Main()
case "mips64", "mips64le":
mips64.Main()
case "ppc64", "ppc64le":
ppc64.Main()
case "s390x":
s390x.Main()
}
}
示例3: main
func main() {
log.SetFlags(0)
log.SetPrefix("asm: ")
GOARCH := obj.Getgoarch()
architecture := arch.Set(GOARCH)
if architecture == nil {
log.Fatalf("unrecognized architecture %s", GOARCH)
}
flags.Parse()
ctxt := obj.Linknew(architecture.LinkArch)
if *flags.PrintOut {
ctxt.Debugasm = 1
}
ctxt.LineHist.TrimPathPrefix = *flags.TrimPath
ctxt.Flag_dynlink = *flags.Dynlink
ctxt.Flag_shared = *flags.Shared || *flags.Dynlink
ctxt.Bso = bufio.NewWriter(os.Stdout)
defer ctxt.Bso.Flush()
// Create object file, write header.
out, err := os.Create(*flags.OutputFile)
if err != nil {
log.Fatal(err)
}
defer bio.MustClose(out)
buf := bufio.NewWriter(bio.MustWriter(out))
fmt.Fprintf(buf, "go object %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion())
fmt.Fprintf(buf, "!\n")
lexer := lex.NewLexer(flag.Arg(0), ctxt)
parser := asm.NewParser(ctxt, architecture, lexer)
diag := false
ctxt.DiagFunc = func(format string, args ...interface{}) {
diag = true
log.Printf(format, args...)
}
pList := obj.Linknewplist(ctxt)
var ok bool
pList.Firstpc, ok = parser.Parse()
if ok {
// reports errors to parser.Errorf
obj.Writeobjdirect(ctxt, buf)
}
if !ok || diag {
log.Printf("assembly of %s failed", flag.Arg(0))
os.Remove(*flags.OutputFile)
os.Exit(1)
}
buf.Flush()
}
示例4: linkarchinit
func linkarchinit() {
ld.Thestring = obj.Getgoarch()
ld.Thelinkarch = &ld.Linkarm64
ld.Thearch.Thechar = thechar
ld.Thearch.Ptrsize = ld.Thelinkarch.Ptrsize
ld.Thearch.Intsize = ld.Thelinkarch.Ptrsize
ld.Thearch.Regsize = ld.Thelinkarch.Regsize
ld.Thearch.Funcalign = FuncAlign
ld.Thearch.Maxalign = MaxAlign
ld.Thearch.Minlc = MINLC
ld.Thearch.Dwarfregsp = DWARFREGSP
ld.Thearch.Dwarfreglr = DWARFREGLR
ld.Thearch.Adddynrel = adddynrel
ld.Thearch.Archinit = archinit
ld.Thearch.Archreloc = archreloc
ld.Thearch.Archrelocvariant = archrelocvariant
ld.Thearch.Asmb = asmb
ld.Thearch.Elfreloc1 = elfreloc1
ld.Thearch.Elfsetupplt = elfsetupplt
ld.Thearch.Gentext = gentext
ld.Thearch.Machoreloc1 = machoreloc1
ld.Thearch.Lput = ld.Lputl
ld.Thearch.Wput = ld.Wputl
ld.Thearch.Vput = ld.Vputl
ld.Thearch.Linuxdynld = "/lib/ld-linux-aarch64.so.1"
ld.Thearch.Freebsddynld = "XXX"
ld.Thearch.Openbsddynld = "XXX"
ld.Thearch.Netbsddynld = "XXX"
ld.Thearch.Dragonflydynld = "XXX"
ld.Thearch.Solarisdynld = "XXX"
}
示例5: assemble
func assemble(file string) int {
if outfile == "" {
outfile = strings.TrimSuffix(filepath.Base(file), ".s") + "." + string(Thechar)
}
of, err := os.Create(outfile)
if err != nil {
Yyerror("%ca: cannot create %s", Thechar, outfile)
errorexit()
}
obuf = *obj.Binitw(of)
fmt.Fprintf(&obuf, "go object %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion())
fmt.Fprintf(&obuf, "!\n")
var i int
for Pass = 1; Pass <= 2; Pass++ {
pinit(file)
for i = 0; i < len(Dlist); i++ {
dodefine(Dlist[i])
}
Yyparse()
Cclean()
if nerrors != 0 {
return nerrors
}
}
obj.Writeobjdirect(Ctxt, &obuf)
obuf.Flush()
return 0
}
示例6: Main
func Main() {
gc.Thearch.LinkArch = &ppc64.Linkppc64
if obj.Getgoarch() == "ppc64le" {
gc.Thearch.LinkArch = &ppc64.Linkppc64le
}
gc.Thearch.REGSP = ppc64.REGSP
gc.Thearch.REGCTXT = ppc64.REGCTXT
gc.Thearch.REGCALLX = ppc64.REG_R3
gc.Thearch.REGCALLX2 = ppc64.REG_R4
gc.Thearch.REGRETURN = ppc64.REG_R3
gc.Thearch.REGMIN = ppc64.REG_R0
gc.Thearch.REGMAX = ppc64.REG_R31
gc.Thearch.FREGMIN = ppc64.REG_F0
gc.Thearch.FREGMAX = ppc64.REG_F31
gc.Thearch.MAXWIDTH = 1 << 50
gc.Thearch.ReservedRegs = resvd
gc.Thearch.Betypeinit = betypeinit
gc.Thearch.Cgen_hmul = cgen_hmul
gc.Thearch.Cgen_shift = cgen_shift
gc.Thearch.Clearfat = clearfat
gc.Thearch.Defframe = defframe
gc.Thearch.Dodiv = dodiv
gc.Thearch.Excise = excise
gc.Thearch.Expandchecks = expandchecks
gc.Thearch.Getg = getg
gc.Thearch.Gins = gins
gc.Thearch.Ginscmp = ginscmp
gc.Thearch.Ginscon = ginscon
gc.Thearch.Ginsnop = ginsnop
gc.Thearch.Gmove = gmove
gc.Thearch.Peep = peep
gc.Thearch.Proginfo = proginfo
gc.Thearch.Regtyp = regtyp
gc.Thearch.Sameaddr = sameaddr
gc.Thearch.Smallindir = smallindir
gc.Thearch.Stackaddr = stackaddr
gc.Thearch.Blockcopy = blockcopy
gc.Thearch.Sudoaddable = sudoaddable
gc.Thearch.Sudoclean = sudoclean
gc.Thearch.Excludedregs = excludedregs
gc.Thearch.RtoB = RtoB
gc.Thearch.FtoB = RtoB
gc.Thearch.BtoR = BtoR
gc.Thearch.BtoF = BtoF
gc.Thearch.Optoas = optoas
gc.Thearch.Doregbits = doregbits
gc.Thearch.Regnames = regnames
gc.Thearch.SSARegToReg = ssaRegToReg
gc.Thearch.SSAMarkMoves = ssaMarkMoves
gc.Thearch.SSAGenValue = ssaGenValue
gc.Thearch.SSAGenBlock = ssaGenBlock
initvariants()
initproginfo()
gc.Main()
gc.Exit(0)
}
示例7: Set
func (mode *BuildMode) Set(s string) error {
goos := obj.Getgoos()
goarch := obj.Getgoarch()
badmode := func() error {
return fmt.Errorf("buildmode %s not supported on %s/%s", s, goos, goarch)
}
switch s {
default:
return fmt.Errorf("invalid buildmode: %q", s)
case "exe":
*mode = BuildmodeExe
case "c-archive":
switch goos {
case "darwin", "linux":
default:
return badmode()
}
*mode = BuildmodeCArchive
case "c-shared":
if goarch != "amd64" && goarch != "arm" {
return badmode()
}
*mode = BuildmodeCShared
case "shared":
if goos != "linux" || goarch != "amd64" {
return badmode()
}
*mode = BuildmodeShared
}
return nil
}
示例8: main
func main() {
log.SetFlags(0)
log.SetPrefix("asm: ")
GOARCH := obj.Getgoarch()
architecture := arch.Set(GOARCH)
if architecture == nil {
log.Fatalf("asm: unrecognized architecture %s", GOARCH)
}
flags.Parse(architecture.Thechar)
// Create object file, write header.
fd, err := os.Create(*flags.OutputFile)
if err != nil {
log.Fatal(err)
}
ctxt := obj.Linknew(architecture.LinkArch)
if *flags.PrintOut {
ctxt.Debugasm = 1
}
ctxt.LineHist.TrimPathPrefix = *flags.TrimPath
ctxt.Flag_dynlink = *flags.Dynlink
if *flags.Shared || *flags.Dynlink {
ctxt.Flag_shared = 1
}
ctxt.Bso = obj.Binitw(os.Stdout)
defer ctxt.Bso.Flush()
ctxt.Diag = log.Fatalf
output := obj.Binitw(fd)
fmt.Fprintf(output, "go object %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion())
fmt.Fprintf(output, "!\n")
lexer := lex.NewLexer(flag.Arg(0), ctxt)
parser := asm.NewParser(ctxt, architecture, lexer)
pList := obj.Linknewplist(ctxt)
var ok bool
pList.Firstpc, ok = parser.Parse()
if !ok {
log.Printf("asm: assembly of %s failed", flag.Arg(0))
os.Remove(*flags.OutputFile)
os.Exit(1)
}
obj.Writeobjdirect(ctxt, output)
output.Flush()
}
示例9: Main
func Main() {
gc.Thearch.LinkArch = &x86.Linkamd64
if obj.Getgoarch() == "amd64p32" {
gc.Thearch.LinkArch = &x86.Linkamd64p32
}
gc.Thearch.REGSP = x86.REGSP
gc.Thearch.REGCTXT = x86.REGCTXT
gc.Thearch.REGCALLX = x86.REG_BX
gc.Thearch.REGCALLX2 = x86.REG_AX
gc.Thearch.REGRETURN = x86.REG_AX
gc.Thearch.REGMIN = x86.REG_AX
gc.Thearch.REGMAX = x86.REG_R15
gc.Thearch.FREGMIN = x86.REG_X0
gc.Thearch.FREGMAX = x86.REG_X15
gc.Thearch.MAXWIDTH = 1 << 50
gc.Thearch.AddIndex = addindex
gc.Thearch.Betypeinit = betypeinit
gc.Thearch.Cgen_bmul = cgen_bmul
gc.Thearch.Cgen_hmul = cgen_hmul
gc.Thearch.Cgen_shift = cgen_shift
gc.Thearch.Clearfat = clearfat
gc.Thearch.Defframe = defframe
gc.Thearch.Dodiv = dodiv
gc.Thearch.Excise = excise
gc.Thearch.Expandchecks = expandchecks
gc.Thearch.Getg = getg
gc.Thearch.Gins = gins
gc.Thearch.Ginsboolval = ginsboolval
gc.Thearch.Ginscmp = ginscmp
gc.Thearch.Ginscon = ginscon
gc.Thearch.Ginsnop = ginsnop
gc.Thearch.Gmove = gmove
gc.Thearch.Peep = peep
gc.Thearch.Proginfo = proginfo
gc.Thearch.Regtyp = regtyp
gc.Thearch.Sameaddr = sameaddr
gc.Thearch.Smallindir = smallindir
gc.Thearch.Stackaddr = stackaddr
gc.Thearch.Blockcopy = blockcopy
gc.Thearch.Sudoaddable = sudoaddable
gc.Thearch.Sudoclean = sudoclean
gc.Thearch.Excludedregs = excludedregs
gc.Thearch.RtoB = RtoB
gc.Thearch.FtoB = FtoB
gc.Thearch.BtoR = BtoR
gc.Thearch.BtoF = BtoF
gc.Thearch.Optoas = optoas
gc.Thearch.Doregbits = doregbits
gc.Thearch.Regnames = regnames
gc.Thearch.SSARegToReg = ssaRegToReg
gc.Thearch.SSAMarkMoves = ssaMarkMoves
gc.Thearch.SSAGenValue = ssaGenValue
gc.Thearch.SSAGenBlock = ssaGenBlock
gc.Main()
gc.Exit(0)
}
示例10: main
func main() {
switch obj.Getgoarch() {
default:
fmt.Fprintf(os.Stderr, "compile: unknown architecture %q\n", obj.Getgoarch())
os.Exit(2)
case "386":
x86.Main()
case "amd64", "amd64p32":
amd64.Main()
case "arm":
arm.Main()
case "arm64":
arm64.Main()
case "ppc64", "ppc64le":
ppc64.Main()
}
}
示例11: linkarchinit
func linkarchinit() {
if obj.Getgoarch() == "amd64p32" {
thelinkarch = &x86.Linkamd64p32
gc.Thearch.Thelinkarch = thelinkarch
thestring = "amd64p32"
gc.Thearch.Thestring = "amd64p32"
}
}
示例12: mywhatsys
func mywhatsys() {
goroot = obj.Getgoroot()
goos = obj.Getgoos()
goarch = obj.Getgoarch()
if !strings.HasPrefix(goarch, Thestring) {
log.Fatalf("cannot use %cc with GOARCH=%s", Thearch.Thechar, goarch)
}
}
示例13: linkarchinit
func linkarchinit() {
thestring = obj.Getgoarch()
gc.Thearch.Thestring = thestring
if thestring == "ppc64le" {
thelinkarch = &ppc64.Linkppc64le
} else {
thelinkarch = &ppc64.Linkppc64
}
gc.Thearch.Thelinkarch = thelinkarch
}
示例14: linkarchinit
func linkarchinit() {
thestring = obj.Getgoarch()
gc.Thearch.Thestring = thestring
if thestring == "mips64le" {
thelinkarch = &mips.Linkmips64le
} else {
thelinkarch = &mips.Linkmips64
}
gc.Thearch.Thelinkarch = thelinkarch
}
示例15: Main
func Main() {
gc.Thearch.Thechar = '0'
gc.Thearch.Thestring = "mips64"
gc.Thearch.Thelinkarch = &mips.Linkmips64
if obj.Getgoarch() == "mips64le" {
gc.Thearch.Thestring = "mips64le"
gc.Thearch.Thelinkarch = &mips.Linkmips64le
}
gc.Thearch.REGSP = mips.REGSP
gc.Thearch.REGCTXT = mips.REGCTXT
gc.Thearch.REGCALLX = mips.REG_R1
gc.Thearch.REGCALLX2 = mips.REG_R2
gc.Thearch.REGRETURN = mips.REGRET
gc.Thearch.REGMIN = mips.REG_R0
gc.Thearch.REGMAX = mips.REG_R31
gc.Thearch.FREGMIN = mips.REG_F0
gc.Thearch.FREGMAX = mips.REG_F31
gc.Thearch.MAXWIDTH = 1 << 50
gc.Thearch.ReservedRegs = resvd
gc.Thearch.Betypeinit = betypeinit
gc.Thearch.Cgen_hmul = cgen_hmul
gc.Thearch.Cgen_shift = cgen_shift
gc.Thearch.Clearfat = clearfat
gc.Thearch.Defframe = defframe
gc.Thearch.Dodiv = dodiv
gc.Thearch.Excise = excise
gc.Thearch.Expandchecks = expandchecks
gc.Thearch.Getg = getg
gc.Thearch.Gins = gins
gc.Thearch.Ginscmp = ginscmp
gc.Thearch.Ginscon = ginscon
gc.Thearch.Ginsnop = ginsnop
gc.Thearch.Gmove = gmove
gc.Thearch.Peep = peep
gc.Thearch.Proginfo = proginfo
gc.Thearch.Regtyp = regtyp
gc.Thearch.Sameaddr = sameaddr
gc.Thearch.Smallindir = smallindir
gc.Thearch.Stackaddr = stackaddr
gc.Thearch.Blockcopy = blockcopy
gc.Thearch.Sudoaddable = sudoaddable
gc.Thearch.Sudoclean = sudoclean
gc.Thearch.Excludedregs = excludedregs
gc.Thearch.RtoB = RtoB
gc.Thearch.FtoB = RtoB
gc.Thearch.BtoR = BtoR
gc.Thearch.BtoF = BtoF
gc.Thearch.Optoas = optoas
gc.Thearch.Doregbits = doregbits
gc.Thearch.Regnames = regnames
gc.Main()
gc.Exit(0)
}