/*
-5l is a modified version of the Plan 9 linker. The original is documented at
+5l is the linker for the ARM.
+The $GOARCH for these tools is arm.
- http://plan9.bell-labs.com/magic/man2html/1/2l
-
-Its target architecture is the ARM, referred to by these tools as arm.
-It reads files in .5 format generated by 5g, 5c, and 5a and emits
-a binary called 5.out by default.
-
-Major changes include:
- - support for segmented stacks (this feature is implemented here, not in the compilers).
-
-
-Original options are listed in the link above.
-
-Options new in this version:
-
--F
- Force use of software floating point.
- Also implied by setting GOARM=5 in the environment.
--Hlinux
- Write Linux ELF binaries (default when $GOOS is linux)
--I interpreter
- Set the ELF dynamic linker to use.
--L dir1 -L dir2
- Search for libraries (package files) in dir1, dir2, etc.
- The default is the single location $GOROOT/pkg/$GOOS_arm.
--r dir1:dir2:...
- Set the dynamic linker search path when using ELF.
--V
- Print the linker version.
+The flags are documented in ../ld/doc.go.
*/
package documentation
main(int argc, char *argv[])
{
int c, i;
- char *p;
+ char *p, *name, *val;
Binit(&bso, 1, OWRITE);
listinit();
INITDAT = -1;
INITRND = -1;
INITENTRY = 0;
+ nuxiinit();
p = getenv("GOARM");
if(p != nil && strcmp(p, "5") == 0)
print("%cl version %s\n", thechar, getgoversion());
errorexit();
case 'X':
- // TODO: golang.org/issue/2676
- EARGF(usage());
- EARGF(usage());
+ name = EARGF(usage());
+ val = EARGF(usage());
+ addstrdata(name, val);
break;
} ARGEND
histgen = 0;
pc = 0;
dtype = 4;
- nuxiinit();
version = 0;
cbp = buf.cbuf;
/*
-6l is a modified version of the Plan 9 linker. The original is documented at
-
- http://plan9.bell-labs.com/magic/man2html/1/2l
-
-Its target architecture is the x86-64, referred to by these tools as amd64.
-It reads files in .6 format generated by 6g, 6c, and 6a and emits
-a binary called 6.out by default.
-
-Major changes include:
- - support for ELF and Mach-O binary files
- - support for segmented stacks (this feature is implemented here, not in the compilers).
-
-
-Original options are listed in the link above.
-
-Options new in this version:
-
--d
- Elide the dynamic linking header. With this option, the binary
- is statically linked and does not refer to dynld. Without this option
- (the default), the binary's contents are identical but it is loaded with dynld.
--Hdarwin
- Write Apple Mach-O binaries (default when $GOOS is darwin)
--Hlinux
- Write Linux ELF binaries (default when $GOOS is linux)
--Hfreebsd
- Write FreeBSD ELF binaries (default when $GOOS is freebsd)
--Hnetbsd
- Write NetBSD ELF binaries (default when $GOOS is netbsd)
--Hopenbsd
- Write OpenBSD ELF binaries (default when $GOOS is openbsd)
--Hwindows
- Write Windows PE32+ binaries (default when $GOOS is windows)
--I interpreter
- Set the ELF dynamic linker to use.
--L dir1 -L dir2
- Search for libraries (package files) in dir1, dir2, etc.
- The default is the single location $GOROOT/pkg/$GOOS_amd64.
--r dir1:dir2:...
- Set the dynamic linker search path when using ELF.
--V
- Print the linker version.
+6l is the linker for the x86-64.
+The $GOARCH for these tools is amd64.
+The flags are documented in ../ld/doc.go.
*/
package documentation
main(int argc, char *argv[])
{
int c;
+ char *name, *val;
Binit(&bso, 1, OWRITE);
listinit();
INITDAT = -1;
INITRND = -1;
INITENTRY = 0;
+ nuxiinit();
ARGBEGIN {
default:
print("%cl version %s\n", thechar, getgoversion());
errorexit();
case 'X':
- // TODO: golang.org/issue/2676
- EARGF(usage());
- EARGF(usage());
+ name = EARGF(usage());
+ val = EARGF(usage());
+ addstrdata(name, val);
break;
} ARGEND
zprg.mode = 64;
pcstr = "%.6llux ";
- nuxiinit();
histgen = 0;
pc = 0;
dtype = 4;
/*
-8l is a modified version of the Plan 9 linker. The original is documented at
-
- http://plan9.bell-labs.com/magic/man2html/1/2l
-
-Its target architecture is the x86, referred to by these tools for historical reasons as 386.
-It reads files in .8 format generated by 8g, 8c, and 8a and emits
-a binary called 8.out by default.
-
-Major changes include:
- - support for ELF and Mach-O binary files
- - support for segmented stacks (this feature is implemented here, not in the compilers).
-
-
-Original options are listed in the link above.
-
-Options new in this version:
-
--d
- Elide the dynamic linking header. With this option, the binary
- is statically linked and does not refer to dynld. Without this option
- (the default), the binary's contents are identical but it is loaded with dynld.
--Hplan9
- Write Plan 9 32-bit format binaries (default when $GOOS is plan9)
--Hdarwin
- Write Apple Mach-O binaries (default when $GOOS is darwin)
--Hlinux
- Write Linux ELF binaries (default when $GOOS is linux)
--Hfreebsd
- Write FreeBSD ELF binaries (default when $GOOS is freebsd)
--Hnetbsd
- Write NetBSD ELF binaries (default when $GOOS is netbsd)
--Hopenbsd
- Write OpenBSD ELF binaries (default when $GOOS is openbsd)
--Hwindows
- Write Windows PE32 binaries (default when $GOOS is windows)
--I interpreter
- Set the ELF dynamic linker to use.
--L dir1 -L dir2
- Search for libraries (package files) in dir1, dir2, etc.
- The default is the single location $GOROOT/pkg/$GOOS_386.
--r dir1:dir2:...
- Set the dynamic linker search path when using ELF.
--V
- Print the linker version.
+8l is the linker for the 32-bit x86.
+The $GOARCH for these tools is 386.
+The flags are documented in ../ld/doc.go.
*/
package documentation
main(int argc, char *argv[])
{
int c;
+ char *name, *val;
Binit(&bso, 1, OWRITE);
listinit();
INITDAT = -1;
INITRND = -1;
INITENTRY = 0;
+ nuxiinit();
ARGBEGIN {
default:
print("%cl version %s\n", thechar, getgoversion());
errorexit();
case 'X':
- // TODO: golang.org/issue/2676
- EARGF(usage());
- EARGF(usage());
+ name = EARGF(usage());
+ val = EARGF(usage());
+ addstrdata(name, val);
break;
} ARGEND
zprg.to = zprg.from;
pcstr = "%.6ux ";
- nuxiinit();
histgen = 0;
pc = 0;
dtype = 4;
}
}
+void
+addstrdata(char *name, char *value)
+{
+ Sym *s, *sp;
+ char *p;
+
+ p = smprint("%s.str", name);
+ sp = lookup(p, 0);
+ free(p);
+ addstring(sp, value);
+
+ s = lookup(name, 0);
+ s->dupok = 1;
+ addaddr(s, sp);
+ adduint32(s, strlen(value));
+ if(PtrSize == 8)
+ adduint32(s, 0); // round struct to pointer width
+}
+
vlong
addstring(Sym *s, char *str)
{
/*
-This directory contains the portable section of the Plan 9 C linkers.
-See ../6l, ../8l, and ../5l for more information.
+Ld is the portable code for a modified version of the Plan 9 linker. The original is documented at
+
+ http://plan9.bell-labs.com/magic/man2html/1/2l
+
+It reads object files (.5, .6, or .8 files) and writes a binary named for the
+architecture (5.out, 6.out, 8.out) by default.
+
+Major changes include:
+ - support for ELF and Mach-O binary files
+ - support for segmented stacks (this feature is implemented here, not in the compilers).
+
+Original options are listed on the manual page linked above.
+
+Options new in this version:
+
+-d
+ Elide the dynamic linking header. With this option, the binary
+ is statically linked and does not refer to dynld. Without this option
+ (the default), the binary's contents are identical but it is loaded with dynld.
+-Hdarwin
+ Write Apple Mach-O binaries (default when $GOOS is darwin)
+-Hlinux
+ Write Linux ELF binaries (default when $GOOS is linux)
+-Hfreebsd
+ Write FreeBSD ELF binaries (default when $GOOS is freebsd)
+-Hnetbsd
+ Write NetBSD ELF binaries (default when $GOOS is netbsd)
+-Hopenbsd
+ Write OpenBSD ELF binaries (default when $GOOS is openbsd)
+-Hwindows
+ Write Windows PE32+ binaries (default when $GOOS is windows)
+-I interpreter
+ Set the ELF dynamic linker to use.
+-L dir1 -L dir2
+ Search for libraries (package files) in dir1, dir2, etc.
+ The default is the single location $GOROOT/pkg/$GOOS_amd64.
+-r dir1:dir2:...
+ Set the dynamic linker search path when using ELF.
+-V
+ Print the linker version.
+-X symbol value
+ Set the value of an otherwise uninitialized string variable.
+ The symbol name should be of the form importpath.name,
+ as displayed in the symbol table printed by "go tool nm".
*/
package documentation
void relocsym(Sym*);
void savedata(Sym*, Prog*, char*);
void symgrow(Sym*, int32);
+void addstrdata(char*, char*);
vlong addstring(Sym*, char*);
vlong adduint32(Sym*, uint32);
vlong adduint64(Sym*, uint64);
--- /dev/null
+// $G $D/$F.go && $L -X main.tbd hello $F.$A && ./$A.out
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+var tbd string
+
+func main() {
+ if tbd != "hello" {
+ println("BUG: test/linkx", len(tbd), tbd)
+ }
+}