mirror of
https://github.com/golang/go
synced 2024-11-21 23:14:40 -07:00
5l, 6l, 8l: implement -X flag
R=golang-dev, iant CC=golang-dev https://golang.org/cl/5643050
This commit is contained in:
parent
2cc58e93d6
commit
e3755434b8
@ -4,36 +4,10 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
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
|
The flags are documented in ../ld/doc.go.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package documentation
|
package documentation
|
||||||
|
@ -81,7 +81,7 @@ void
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c, i;
|
int c, i;
|
||||||
char *p;
|
char *p, *name, *val;
|
||||||
|
|
||||||
Binit(&bso, 1, OWRITE);
|
Binit(&bso, 1, OWRITE);
|
||||||
listinit();
|
listinit();
|
||||||
@ -92,6 +92,7 @@ main(int argc, char *argv[])
|
|||||||
INITDAT = -1;
|
INITDAT = -1;
|
||||||
INITRND = -1;
|
INITRND = -1;
|
||||||
INITENTRY = 0;
|
INITENTRY = 0;
|
||||||
|
nuxiinit();
|
||||||
|
|
||||||
p = getenv("GOARM");
|
p = getenv("GOARM");
|
||||||
if(p != nil && strcmp(p, "5") == 0)
|
if(p != nil && strcmp(p, "5") == 0)
|
||||||
@ -137,9 +138,9 @@ main(int argc, char *argv[])
|
|||||||
print("%cl version %s\n", thechar, getgoversion());
|
print("%cl version %s\n", thechar, getgoversion());
|
||||||
errorexit();
|
errorexit();
|
||||||
case 'X':
|
case 'X':
|
||||||
// TODO: golang.org/issue/2676
|
name = EARGF(usage());
|
||||||
EARGF(usage());
|
val = EARGF(usage());
|
||||||
EARGF(usage());
|
addstrdata(name, val);
|
||||||
break;
|
break;
|
||||||
} ARGEND
|
} ARGEND
|
||||||
|
|
||||||
@ -240,7 +241,6 @@ main(int argc, char *argv[])
|
|||||||
histgen = 0;
|
histgen = 0;
|
||||||
pc = 0;
|
pc = 0;
|
||||||
dtype = 4;
|
dtype = 4;
|
||||||
nuxiinit();
|
|
||||||
|
|
||||||
version = 0;
|
version = 0;
|
||||||
cbp = buf.cbuf;
|
cbp = buf.cbuf;
|
||||||
|
@ -4,49 +4,10 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
6l is a modified version of the Plan 9 linker. The original is documented at
|
6l is the linker for the x86-64.
|
||||||
|
The $GOARCH for these tools is amd64.
|
||||||
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.
|
|
||||||
|
|
||||||
|
The flags are documented in ../ld/doc.go.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package documentation
|
package documentation
|
||||||
|
@ -82,6 +82,7 @@ void
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
char *name, *val;
|
||||||
|
|
||||||
Binit(&bso, 1, OWRITE);
|
Binit(&bso, 1, OWRITE);
|
||||||
listinit();
|
listinit();
|
||||||
@ -93,6 +94,7 @@ main(int argc, char *argv[])
|
|||||||
INITDAT = -1;
|
INITDAT = -1;
|
||||||
INITRND = -1;
|
INITRND = -1;
|
||||||
INITENTRY = 0;
|
INITENTRY = 0;
|
||||||
|
nuxiinit();
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
default:
|
default:
|
||||||
@ -133,9 +135,9 @@ main(int argc, char *argv[])
|
|||||||
print("%cl version %s\n", thechar, getgoversion());
|
print("%cl version %s\n", thechar, getgoversion());
|
||||||
errorexit();
|
errorexit();
|
||||||
case 'X':
|
case 'X':
|
||||||
// TODO: golang.org/issue/2676
|
name = EARGF(usage());
|
||||||
EARGF(usage());
|
val = EARGF(usage());
|
||||||
EARGF(usage());
|
addstrdata(name, val);
|
||||||
break;
|
break;
|
||||||
} ARGEND
|
} ARGEND
|
||||||
|
|
||||||
@ -253,7 +255,6 @@ main(int argc, char *argv[])
|
|||||||
zprg.mode = 64;
|
zprg.mode = 64;
|
||||||
|
|
||||||
pcstr = "%.6llux ";
|
pcstr = "%.6llux ";
|
||||||
nuxiinit();
|
|
||||||
histgen = 0;
|
histgen = 0;
|
||||||
pc = 0;
|
pc = 0;
|
||||||
dtype = 4;
|
dtype = 4;
|
||||||
|
@ -4,51 +4,10 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
8l is a modified version of the Plan 9 linker. The original is documented at
|
8l is the linker for the 32-bit x86.
|
||||||
|
The $GOARCH for these tools is 386.
|
||||||
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.
|
|
||||||
|
|
||||||
|
The flags are documented in ../ld/doc.go.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package documentation
|
package documentation
|
||||||
|
@ -87,6 +87,7 @@ void
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
char *name, *val;
|
||||||
|
|
||||||
Binit(&bso, 1, OWRITE);
|
Binit(&bso, 1, OWRITE);
|
||||||
listinit();
|
listinit();
|
||||||
@ -98,6 +99,7 @@ main(int argc, char *argv[])
|
|||||||
INITDAT = -1;
|
INITDAT = -1;
|
||||||
INITRND = -1;
|
INITRND = -1;
|
||||||
INITENTRY = 0;
|
INITENTRY = 0;
|
||||||
|
nuxiinit();
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
default:
|
default:
|
||||||
@ -138,9 +140,9 @@ main(int argc, char *argv[])
|
|||||||
print("%cl version %s\n", thechar, getgoversion());
|
print("%cl version %s\n", thechar, getgoversion());
|
||||||
errorexit();
|
errorexit();
|
||||||
case 'X':
|
case 'X':
|
||||||
// TODO: golang.org/issue/2676
|
name = EARGF(usage());
|
||||||
EARGF(usage());
|
val = EARGF(usage());
|
||||||
EARGF(usage());
|
addstrdata(name, val);
|
||||||
break;
|
break;
|
||||||
} ARGEND
|
} ARGEND
|
||||||
|
|
||||||
@ -280,7 +282,6 @@ main(int argc, char *argv[])
|
|||||||
zprg.to = zprg.from;
|
zprg.to = zprg.from;
|
||||||
|
|
||||||
pcstr = "%.6ux ";
|
pcstr = "%.6ux ";
|
||||||
nuxiinit();
|
|
||||||
histgen = 0;
|
histgen = 0;
|
||||||
pc = 0;
|
pc = 0;
|
||||||
dtype = 4;
|
dtype = 4;
|
||||||
|
@ -589,6 +589,25 @@ strnput(char *s, int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
vlong
|
||||||
addstring(Sym *s, char *str)
|
addstring(Sym *s, char *str)
|
||||||
{
|
{
|
||||||
|
@ -4,8 +4,50 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This directory contains the portable section of the Plan 9 C linkers.
|
Ld is the portable code for a modified version of the Plan 9 linker. The original is documented at
|
||||||
See ../6l, ../8l, and ../5l for more information.
|
|
||||||
|
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
|
package documentation
|
||||||
|
@ -179,6 +179,7 @@ void reloc(void);
|
|||||||
void relocsym(Sym*);
|
void relocsym(Sym*);
|
||||||
void savedata(Sym*, Prog*, char*);
|
void savedata(Sym*, Prog*, char*);
|
||||||
void symgrow(Sym*, int32);
|
void symgrow(Sym*, int32);
|
||||||
|
void addstrdata(char*, char*);
|
||||||
vlong addstring(Sym*, char*);
|
vlong addstring(Sym*, char*);
|
||||||
vlong adduint32(Sym*, uint32);
|
vlong adduint32(Sym*, uint32);
|
||||||
vlong adduint64(Sym*, uint64);
|
vlong adduint64(Sym*, uint64);
|
||||||
|
15
test/linkx.go
Normal file
15
test/linkx.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// $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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user