| 1 |
// Copyright 2009 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. |
| 4 |
|
| 5 |
/* |
| 6 |
Link, typically invoked as “go tool link”, reads the Go archive or object |
| 7 |
for a package main, along with its dependencies, and combines them |
| 8 |
into an executable binary. |
| 9 |
|
| 10 |
# Command Line |
| 11 |
|
| 12 |
Usage: |
| 13 |
|
| 14 |
go tool link [flags] main.a |
| 15 |
|
| 16 |
Flags: |
| 17 |
|
| 18 |
-B note |
| 19 |
Add an ELF_NT_GNU_BUILD_ID note when using ELF. |
| 20 |
The value should start with 0x and be an even number of hex digits. |
| 21 |
Alternatively, you can pass "gobuildid" in order to derive the |
| 22 |
GNU build ID from the Go build ID. |
| 23 |
-E entry |
| 24 |
Set entry symbol name. |
| 25 |
-H type |
| 26 |
Set executable format type. |
| 27 |
The default format is inferred from GOOS and GOARCH. |
| 28 |
On Windows, -H windowsgui writes a "GUI binary" instead of a "console binary." |
| 29 |
-I interpreter |
| 30 |
Set the ELF dynamic linker to use. |
| 31 |
-L dir1 -L dir2 |
| 32 |
Search for imported packages in dir1, dir2, etc, |
| 33 |
after consulting $GOROOT/pkg/$GOOS_$GOARCH. |
| 34 |
-R quantum |
| 35 |
Set address rounding quantum. |
| 36 |
-T address |
| 37 |
Set the start address of text symbols. |
| 38 |
-V |
| 39 |
Print linker version and exit. |
| 40 |
-X importpath.name=value |
| 41 |
Set the value of the string variable in importpath named name to value. |
| 42 |
This is only effective if the variable is declared in the source code either uninitialized |
| 43 |
or initialized to a constant string expression. -X will not work if the initializer makes |
| 44 |
a function call or refers to other variables. |
| 45 |
Note that before Go 1.5 this option took two separate arguments. |
| 46 |
-asan |
| 47 |
Link with C/C++ address sanitizer support. |
| 48 |
-aslr |
| 49 |
Enable ASLR for buildmode=c-shared on windows (default true). |
| 50 |
-bindnow |
| 51 |
Mark a dynamically linked ELF object for immediate function binding (default false). |
| 52 |
-buildid id |
| 53 |
Record id as Go toolchain build id. |
| 54 |
-buildmode mode |
| 55 |
Set build mode (default exe). |
| 56 |
-c |
| 57 |
Dump call graphs. |
| 58 |
-checklinkname=value |
| 59 |
If value is 0, all go:linkname directives are permitted. |
| 60 |
If value is 1 (the default), only a known set of widely-used |
| 61 |
linknames are permitted. |
| 62 |
-compressdwarf |
| 63 |
Compress DWARF if possible (default true). |
| 64 |
-cpuprofile file |
| 65 |
Write CPU profile to file. |
| 66 |
-d |
| 67 |
Disable generation of dynamic executables. |
| 68 |
The emitted code is the same in either case; the option |
| 69 |
controls only whether a dynamic header is included. |
| 70 |
The dynamic header is on by default, even without any |
| 71 |
references to dynamic libraries, because many common |
| 72 |
system tools now assume the presence of the header. |
| 73 |
-dumpdep |
| 74 |
Dump symbol dependency graph. |
| 75 |
-e |
| 76 |
No limit on number of errors reported. |
| 77 |
-extar ar |
| 78 |
Set the external archive program (default "ar"). |
| 79 |
Used only for -buildmode=c-archive. |
| 80 |
-extld linker |
| 81 |
Set the external linker (default "clang" or "gcc"). |
| 82 |
-extldflags flags |
| 83 |
Set space-separated flags to pass to the external linker. |
| 84 |
-f |
| 85 |
Ignore version mismatch in the linked archives. |
| 86 |
-funcalign N |
| 87 |
Set function alignment to N bytes |
| 88 |
-g |
| 89 |
Disable Go package data checks. |
| 90 |
-importcfg file |
| 91 |
Read import configuration from file. |
| 92 |
In the file, set packagefile, packageshlib to specify import resolution. |
| 93 |
-installsuffix suffix |
| 94 |
Look for packages in $GOROOT/pkg/$GOOS_$GOARCH_suffix |
| 95 |
instead of $GOROOT/pkg/$GOOS_$GOARCH. |
| 96 |
-k symbol |
| 97 |
Set field tracking symbol. Use this flag when GOEXPERIMENT=fieldtrack is set. |
| 98 |
-libgcc file |
| 99 |
Set name of compiler support library. |
| 100 |
This is only used in internal link mode. |
| 101 |
If not set, default value comes from running the compiler, |
| 102 |
which may be set by the -extld option. |
| 103 |
Set to "none" to use no support library. |
| 104 |
-linkmode mode |
| 105 |
Set link mode (internal, external, auto). |
| 106 |
This sets the linking mode as described in cmd/cgo/doc.go. |
| 107 |
-linkshared |
| 108 |
Link against installed Go shared libraries (experimental). |
| 109 |
-memprofile file |
| 110 |
Write memory profile to file. |
| 111 |
-memprofilerate rate |
| 112 |
Set runtime.MemProfileRate to rate. |
| 113 |
-msan |
| 114 |
Link with C/C++ memory sanitizer support. |
| 115 |
-o file |
| 116 |
Write output to file (default a.out, or a.out.exe on Windows). |
| 117 |
-pluginpath path |
| 118 |
The path name used to prefix exported plugin symbols. |
| 119 |
-r dir1:dir2:... |
| 120 |
Set the ELF dynamic linker search path. |
| 121 |
-race |
| 122 |
Link with race detection libraries. |
| 123 |
-s |
| 124 |
Omit the symbol table and debug information. |
| 125 |
Implies the -w flag, which can be negated with -w=0. |
| 126 |
-tmpdir dir |
| 127 |
Write temporary files to dir. |
| 128 |
Temporary files are only used in external linking mode. |
| 129 |
-v |
| 130 |
Print trace of linker operations. |
| 131 |
-w |
| 132 |
Omit the DWARF symbol table. |
| 133 |
*/ |
| 134 |
package main |