github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/cmd/ld/doc.go (about)

     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  // +build ignore
     6  
     7  /*
     8  
     9  Ld is the portable code for a modified version of the Plan 9 linker.  The original is documented at
    10  
    11  	http://plan9.bell-labs.com/magic/man2html/1/8l
    12  
    13  It reads object files (.5, .6, or .8 files) and writes a binary named for the
    14  architecture (5.out, 6.out, 8.out) by default (if $GOOS is windows, a .exe suffix
    15  will be appended).
    16  
    17  Major changes include:
    18  	- support for ELF, Mach-O and PE binary files
    19  	- support for segmented stacks (this feature is implemented here, not in the compilers).
    20  
    21  Original options are listed on the manual page linked above.
    22  
    23  Usage:
    24  	go tool 6l [flags] mainObj
    25  Substitute 6l with 8l or 5l as appropriate.
    26  
    27  Options new in this version:
    28  
    29  	-d
    30  		Elide the dynamic linking header.  With this option, the binary
    31  		is statically linked and does not refer to a dynamic linker.  Without this option
    32  		(the default), the binary's contents are identical but it is loaded with a dynamic
    33  		linker. This flag cannot be used when $GOOS is windows.
    34  	-H darwin     (only in 6l/8l)
    35  		Write Apple Mach-O binaries (default when $GOOS is darwin)
    36  	-H linux
    37  		Write Linux ELF binaries (default when $GOOS is linux)
    38  	-H freebsd
    39  		Write FreeBSD ELF binaries (default when $GOOS is freebsd)
    40  	-H netbsd
    41  		Write NetBSD ELF binaries (default when $GOOS is netbsd)
    42  	-H openbsd    (only in 6l/8l)
    43  		Write OpenBSD ELF binaries (default when $GOOS is openbsd)
    44  	-H windows    (only in 6l/8l)
    45  		Write Windows PE32+ Console binaries (default when $GOOS is windows)
    46  	-H windowsgui (only in 6l/8l)
    47  		Write Windows PE32+ GUI binaries
    48  	-I interpreter
    49  		Set the ELF dynamic linker to use.
    50  	-L dir1 -L dir2
    51  		Search for libraries (package files) in dir1, dir2, etc.
    52  		The default is the single location $GOROOT/pkg/$GOOS_$GOARCH.
    53  	-r dir1:dir2:...
    54  		Set the dynamic linker search path when using ELF.
    55  	-V
    56  		Print the linker version.
    57  	-X symbol value
    58  		Set the value of an otherwise uninitialized string variable.
    59  		The symbol name should be of the form importpath.name,
    60  		as displayed in the symbol table printed by "go tool nm".
    61  	-race
    62  		Link with race detection libraries.
    63  	-B value
    64  		Add a NT_GNU_BUILD_ID note when using ELF.  The value
    65  		should start with 0x and be an even number of hex digits.
    66  	-Z
    67  		Zero stack on function entry. This is expensive but it might
    68  		be useful in cases where you are suffering from false positives
    69  		during garbage collection and are willing to trade the CPU time
    70  		for getting rid of the false positives.
    71  		NOTE: it only eliminates false positives caused by other function
    72  		calls, not false positives caused by dead temporaries stored in
    73  		the current function call.
    74  	-linkmode argument
    75  		Set the linkmode.  The argument must be one of
    76  		internal, external, or auto.  The default is auto.
    77  		This sets the linking mode as described in
    78  		../cgo/doc.go.
    79  	-tmpdir dir
    80  		Set the location to use for any temporary files.  The
    81  		default is a newly created directory that is removed
    82  		after the linker completes.  Temporary files are only
    83  		used in external linking mode.
    84  	-extld name
    85  		Set the name of the external linker to use in external
    86  		linking mode.  The default is "gcc".
    87  	-extldflags flags
    88  		Set space-separated trailing flags to pass to the
    89  		external linker in external linking mode.  The default
    90  		is to not pass any additional trailing flags.
    91  */
    92  package main