1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 "cmd/link/internal/amd64"
10 "cmd/link/internal/arm"
11 "cmd/link/internal/arm64"
12 "cmd/link/internal/ld"
13 "cmd/link/internal/mips"
14 "cmd/link/internal/mips64"
15 "cmd/link/internal/ppc64"
16 "cmd/link/internal/riscv64"
17 "cmd/link/internal/s390x"
18 "cmd/link/internal/wasm"
19 "cmd/link/internal/x86"
25 // The bulk of the linker implementation lives in cmd/link/internal/ld.
26 // Architecture-specific code lives in cmd/link/internal/GOARCH.
28 // Program initialization:
30 // Before any argument parsing is done, the Init function of relevant
31 // architecture package is called. The only job done in Init is
32 // configuration of the architecture-specific variables.
34 // Then control flow passes to ld.Main, which parses flags, makes
35 // some configuration decisions, and then gives the architecture
36 // packages a second chance to modify the linker's configuration
37 // via the ld.Arch.Archinit function.
44 switch buildcfg.GOARCH {
46 fmt.Fprintf(os.Stderr, "link: unknown architecture %q\n", buildcfg.GOARCH)
49 arch, theArch = x86.Init()
51 arch, theArch = amd64.Init()
53 arch, theArch = arm.Init()
55 arch, theArch = arm64.Init()
56 case "mips", "mipsle":
57 arch, theArch = mips.Init()
58 case "mips64", "mips64le":
59 arch, theArch = mips64.Init()
60 case "ppc64", "ppc64le":
61 arch, theArch = ppc64.Init()
63 arch, theArch = riscv64.Init()
65 arch, theArch = s390x.Init()
67 arch, theArch = wasm.Init()
69 ld.Main(arch, theArch)