Source file src/cmd/link/doc.go
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 -D address 22 Set data segment address. 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 text segment address. 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 -a 47 Disassemble output. 48 -asan 49 Link with C/C++ address sanitizer support. 50 -buildid id 51 Record id as Go toolchain build id. 52 -buildmode mode 53 Set build mode (default exe). 54 -c 55 Dump call graphs. 56 -compressdwarf 57 Compress DWARF if possible (default true). 58 -cpuprofile file 59 Write CPU profile to file. 60 -d 61 Disable generation of dynamic executables. 62 The emitted code is the same in either case; the option 63 controls only whether a dynamic header is included. 64 The dynamic header is on by default, even without any 65 references to dynamic libraries, because many common 66 system tools now assume the presence of the header. 67 -debugtramp int 68 Debug trampolines. 69 -dumpdep 70 Dump symbol dependency graph. 71 -extar ar 72 Set the external archive program (default "ar"). 73 Used only for -buildmode=c-archive. 74 -extld linker 75 Set the external linker (default "clang" or "gcc"). 76 -extldflags flags 77 Set space-separated flags to pass to the external linker. 78 -f 79 Ignore version mismatch in the linked archives. 80 -g 81 Disable Go package data checks. 82 -importcfg file 83 Read import configuration from file. 84 In the file, set packagefile, packageshlib to specify import resolution. 85 -installsuffix suffix 86 Look for packages in $GOROOT/pkg/$GOOS_$GOARCH_suffix 87 instead of $GOROOT/pkg/$GOOS_$GOARCH. 88 -k symbol 89 Set field tracking symbol. Use this flag when GOEXPERIMENT=fieldtrack is set. 90 -libgcc file 91 Set name of compiler support library. 92 This is only used in internal link mode. 93 If not set, default value comes from running the compiler, 94 which may be set by the -extld option. 95 Set to "none" to use no support library. 96 -linkmode mode 97 Set link mode (internal, external, auto). 98 This sets the linking mode as described in cmd/cgo/doc.go. 99 -linkshared 100 Link against installed Go shared libraries (experimental). 101 -memprofile file 102 Write memory profile to file. 103 -memprofilerate rate 104 Set runtime.MemProfileRate to rate. 105 -msan 106 Link with C/C++ memory sanitizer support. 107 -n 108 Dump symbol table. 109 -o file 110 Write output to file (default a.out, or a.out.exe on Windows). 111 -pluginpath path 112 The path name used to prefix exported plugin symbols. 113 -r dir1:dir2:... 114 Set the ELF dynamic linker search path. 115 -race 116 Link with race detection libraries. 117 -s 118 Omit the symbol table and debug information. 119 -shared 120 Generated shared object (implies -linkmode external; experimental). 121 -tmpdir dir 122 Write temporary files to dir. 123 Temporary files are only used in external linking mode. 124 -u 125 Reject unsafe packages. 126 -v 127 Print trace of linker operations. 128 -w 129 Omit the DWARF symbol table. 130 */ 131 package main 132