2015-01-19 14:34:58 -05:00
|
|
|
// Derived from Inferno utils/6l/l.h and related files.
|
|
|
|
|
// http://code.google.com/p/inferno-os/source/browse/utils/6l/l.h
|
|
|
|
|
//
|
|
|
|
|
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
|
|
|
|
|
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
|
|
|
|
|
// Portions Copyright © 1997-1999 Vita Nuova Limited
|
|
|
|
|
// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
|
|
|
|
|
// Portions Copyright © 2004,2006 Bruce Ellis
|
|
|
|
|
// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
|
|
|
|
|
// Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
|
|
|
|
|
// Portions Copyright © 2009 The Go Authors. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
package obj
|
|
|
|
|
|
|
|
|
|
import "encoding/binary"
|
|
|
|
|
|
|
|
|
|
type Addr struct {
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
Type int16
|
|
|
|
|
Reg int16
|
2015-02-26 17:09:16 -08:00
|
|
|
Reg2 int16 // RHS of register pair. AX:DX (386)
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
Index int16
|
2015-02-26 17:09:16 -08:00
|
|
|
Scale int16 // Sometimes holds a register.
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
Name int8
|
2015-01-19 14:34:58 -05:00
|
|
|
Offset int64
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
Sym *LSym
|
2015-01-19 14:34:58 -05:00
|
|
|
U struct {
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
Sval string
|
|
|
|
|
Dval float64
|
|
|
|
|
Branch *Prog
|
|
|
|
|
Argsize int32
|
|
|
|
|
Bits uint64
|
2015-01-19 14:34:58 -05:00
|
|
|
}
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
Gotype *LSym
|
|
|
|
|
Class int8
|
|
|
|
|
Etype uint8
|
|
|
|
|
Node interface{}
|
|
|
|
|
Width int64
|
2015-01-19 14:34:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Prog struct {
|
|
|
|
|
Ctxt *Link
|
|
|
|
|
Pc int64
|
|
|
|
|
Lineno int32
|
|
|
|
|
Link *Prog
|
|
|
|
|
As int16
|
|
|
|
|
Scond uint8
|
|
|
|
|
From Addr
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
Reg int16
|
2015-01-19 14:34:58 -05:00
|
|
|
From3 Addr
|
|
|
|
|
To Addr
|
|
|
|
|
Opt interface{}
|
|
|
|
|
Forwd *Prog
|
|
|
|
|
Pcond *Prog
|
|
|
|
|
Comefrom *Prog
|
|
|
|
|
Pcrel *Prog
|
|
|
|
|
Spadj int32
|
|
|
|
|
Mark uint16
|
|
|
|
|
Optab uint16
|
|
|
|
|
Back uint8
|
|
|
|
|
Ft uint8
|
cmd/internal/obj/x86: take over i386 duty, clean up PINSRQ, CMPSD
Make cmd/internal/obj/x86 support 32-bit mode and use
instead of cmd/internal/obj/i386. Delete cmd/internal/obj/i386.
Clean up encoding of PINSRQ, CMPSD to use explicit third arg
instead of jamming it into an unused slot of a different arg.
Also fix bug in old6a, which declared the wrong grammar.
The accepted (and encoded) arguments to CMPSD etc are mem,reg not reg,mem.
Code that did try to use mem,reg before would be rejected by liblink,
so only reg,reg ever worked, so existing code is not affected.
After this change, code can use mem,reg successfully.
The real bug here is that the encoding tables inverted the argument
order, making the comparisons all backward from what they say on the page.
It's too late to swap them, though: people have already written code that
expects the inverted comparisons (like in package math, and likely externally).
The best we can do is make the argument that should and can take a
memory operand accept it.
Bit-for-bit compatibility checked against tree without this CL.
Change-Id: Ife5685bc98c95001f64407f35066b34b4dae11c1
Reviewed-on: https://go-review.googlesource.com/6810
Reviewed-by: Rob Pike <r@golang.org>
2015-03-04 15:46:52 -05:00
|
|
|
F3t uint8
|
2015-01-19 14:34:58 -05:00
|
|
|
Tt uint8
|
|
|
|
|
Isize uint8
|
|
|
|
|
Printed uint8
|
|
|
|
|
Width int8
|
|
|
|
|
Mode int8
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type LSym struct {
|
|
|
|
|
Name string
|
|
|
|
|
Extname string
|
2015-01-21 14:48:18 -05:00
|
|
|
Type int16
|
2015-01-19 14:34:58 -05:00
|
|
|
Version int16
|
|
|
|
|
Dupok uint8
|
|
|
|
|
Cfunc uint8
|
|
|
|
|
External uint8
|
|
|
|
|
Nosplit uint8
|
|
|
|
|
Reachable uint8
|
|
|
|
|
Cgoexport uint8
|
|
|
|
|
Special uint8
|
|
|
|
|
Stkcheck uint8
|
|
|
|
|
Hide uint8
|
|
|
|
|
Leaf uint8
|
|
|
|
|
Fnptr uint8
|
|
|
|
|
Localentry uint8
|
|
|
|
|
Seenglobl uint8
|
|
|
|
|
Onlist uint8
|
|
|
|
|
Printed uint8
|
|
|
|
|
Symid int16
|
|
|
|
|
Dynid int32
|
|
|
|
|
Plt int32
|
|
|
|
|
Got int32
|
|
|
|
|
Align int32
|
|
|
|
|
Elfsym int32
|
|
|
|
|
Args int32
|
|
|
|
|
Locals int32
|
|
|
|
|
Value int64
|
|
|
|
|
Size int64
|
|
|
|
|
Hash *LSym
|
|
|
|
|
Allsym *LSym
|
|
|
|
|
Next *LSym
|
|
|
|
|
Sub *LSym
|
|
|
|
|
Outer *LSym
|
|
|
|
|
Gotype *LSym
|
|
|
|
|
Reachparent *LSym
|
|
|
|
|
Queue *LSym
|
|
|
|
|
File string
|
|
|
|
|
Dynimplib string
|
|
|
|
|
Dynimpvers string
|
|
|
|
|
Sect *struct{}
|
|
|
|
|
Autom *Auto
|
|
|
|
|
Text *Prog
|
|
|
|
|
Etext *Prog
|
|
|
|
|
Pcln *Pcln
|
|
|
|
|
P []byte
|
|
|
|
|
R []Reloc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Reloc struct {
|
|
|
|
|
Off int32
|
|
|
|
|
Siz uint8
|
|
|
|
|
Done uint8
|
2015-01-21 14:48:18 -05:00
|
|
|
Type int32
|
2015-01-19 14:34:58 -05:00
|
|
|
Variant int32
|
|
|
|
|
Add int64
|
|
|
|
|
Xadd int64
|
|
|
|
|
Sym *LSym
|
|
|
|
|
Xsym *LSym
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Auto struct {
|
|
|
|
|
Asym *LSym
|
|
|
|
|
Link *Auto
|
|
|
|
|
Aoffset int32
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
Name int16
|
2015-01-19 14:34:58 -05:00
|
|
|
Gotype *LSym
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Link struct {
|
|
|
|
|
Thechar int32
|
|
|
|
|
Thestring string
|
|
|
|
|
Goarm int32
|
|
|
|
|
Headtype int
|
|
|
|
|
Arch *LinkArch
|
|
|
|
|
Ignore func(string) int32
|
|
|
|
|
Debugasm int32
|
|
|
|
|
Debugline int32
|
|
|
|
|
Debughist int32
|
|
|
|
|
Debugread int32
|
|
|
|
|
Debugvlog int32
|
|
|
|
|
Debugstack int32
|
|
|
|
|
Debugzerostack int32
|
|
|
|
|
Debugdivmod int32
|
|
|
|
|
Debugfloat int32
|
|
|
|
|
Debugpcln int32
|
|
|
|
|
Flag_shared int32
|
|
|
|
|
Iself int32
|
|
|
|
|
Bso *Biobuf
|
|
|
|
|
Pathname string
|
|
|
|
|
Windows int32
|
|
|
|
|
Trimpath string
|
|
|
|
|
Goroot string
|
|
|
|
|
Goroot_final string
|
|
|
|
|
Enforce_data_order int32
|
|
|
|
|
Hash [LINKHASH]*LSym
|
|
|
|
|
Allsym *LSym
|
|
|
|
|
Nsymbol int32
|
|
|
|
|
Hist *Hist
|
|
|
|
|
Ehist *Hist
|
|
|
|
|
Plist *Plist
|
|
|
|
|
Plast *Plist
|
|
|
|
|
Sym_div *LSym
|
|
|
|
|
Sym_divu *LSym
|
|
|
|
|
Sym_mod *LSym
|
|
|
|
|
Sym_modu *LSym
|
|
|
|
|
Symmorestack [2]*LSym
|
|
|
|
|
Tlsg *LSym
|
|
|
|
|
Plan9privates *LSym
|
|
|
|
|
Curp *Prog
|
|
|
|
|
Printp *Prog
|
|
|
|
|
Blitrl *Prog
|
|
|
|
|
Elitrl *Prog
|
|
|
|
|
Rexflag int
|
|
|
|
|
Rep int
|
|
|
|
|
Repn int
|
|
|
|
|
Lock int
|
|
|
|
|
Asmode int
|
|
|
|
|
Andptr []byte
|
|
|
|
|
And [100]uint8
|
|
|
|
|
Instoffset int64
|
|
|
|
|
Autosize int32
|
|
|
|
|
Armsize int32
|
|
|
|
|
Pc int64
|
|
|
|
|
Libdir []string
|
|
|
|
|
Library []Library
|
|
|
|
|
Tlsoffset int
|
|
|
|
|
Diag func(string, ...interface{})
|
|
|
|
|
Mode int
|
|
|
|
|
Curauto *Auto
|
|
|
|
|
Curhist *Auto
|
|
|
|
|
Cursym *LSym
|
|
|
|
|
Version int
|
|
|
|
|
Textp *LSym
|
|
|
|
|
Etextp *LSym
|
|
|
|
|
Histdepth int32
|
|
|
|
|
Nhistfile int32
|
|
|
|
|
Filesyms *LSym
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Plist struct {
|
|
|
|
|
Name *LSym
|
|
|
|
|
Firstpc *Prog
|
|
|
|
|
Recur int
|
|
|
|
|
Link *Plist
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type LinkArch struct {
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
ByteOrder binary.ByteOrder
|
|
|
|
|
Name string
|
|
|
|
|
Thechar int
|
|
|
|
|
Preprocess func(*Link, *LSym)
|
|
|
|
|
Assemble func(*Link, *LSym)
|
|
|
|
|
Follow func(*Link, *LSym)
|
|
|
|
|
Progedit func(*Link, *Prog)
|
2015-03-02 11:04:06 -08:00
|
|
|
UnaryDst map[int]bool // Instruction takes one operand, a destination.
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
Minlc int
|
|
|
|
|
Ptrsize int
|
|
|
|
|
Regsize int
|
2015-01-19 14:34:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Library struct {
|
|
|
|
|
Objref string
|
|
|
|
|
Srcref string
|
|
|
|
|
File string
|
|
|
|
|
Pkg string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Pcln struct {
|
|
|
|
|
Pcsp Pcdata
|
|
|
|
|
Pcfile Pcdata
|
|
|
|
|
Pcline Pcdata
|
|
|
|
|
Pcdata []Pcdata
|
|
|
|
|
Funcdata []*LSym
|
|
|
|
|
Funcdataoff []int64
|
|
|
|
|
File []*LSym
|
|
|
|
|
Lastfile *LSym
|
|
|
|
|
Lastindex int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Pcdata struct {
|
|
|
|
|
P []byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Pciter struct {
|
2015-02-17 22:13:49 -05:00
|
|
|
d Pcdata
|
|
|
|
|
p []byte
|
|
|
|
|
pc uint32
|
|
|
|
|
nextpc uint32
|
|
|
|
|
pcscale uint32
|
|
|
|
|
value int32
|
|
|
|
|
start int
|
|
|
|
|
done int
|
2015-01-19 14:34:58 -05:00
|
|
|
}
|
|
|
|
|
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
// An Addr is an argument to an instruction.
|
|
|
|
|
// The general forms and their encodings are:
|
|
|
|
|
//
|
|
|
|
|
// sym±offset(symkind)(reg)(index*scale)
|
|
|
|
|
// Memory reference at address &sym(symkind) + offset + reg + index*scale.
|
|
|
|
|
// Any of sym(symkind), ±offset, (reg), (index*scale), and *scale can be omitted.
|
|
|
|
|
// If (reg) and *scale are both omitted, the resulting expression (index) is parsed as (reg).
|
|
|
|
|
// To force a parsing as index*scale, write (index*1).
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_MEM
|
|
|
|
|
// name = symkind (NAME_AUTO, ...) or 0 (NAME_NONE)
|
|
|
|
|
// sym = sym
|
|
|
|
|
// offset = ±offset
|
|
|
|
|
// reg = reg (REG_*)
|
|
|
|
|
// index = index (REG_*)
|
|
|
|
|
// scale = scale (1, 2, 4, 8)
|
|
|
|
|
//
|
|
|
|
|
// $<mem>
|
|
|
|
|
// Effective address of memory reference <mem>, defined above.
|
|
|
|
|
// Encoding: same as memory reference, but type = TYPE_ADDR.
|
|
|
|
|
//
|
|
|
|
|
// $<±integer value>
|
|
|
|
|
// This is a special case of $<mem>, in which only ±offset is present.
|
|
|
|
|
// It has a separate type for easy recognition.
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_CONST
|
|
|
|
|
// offset = ±integer value
|
|
|
|
|
//
|
|
|
|
|
// *<mem>
|
|
|
|
|
// Indirect reference through memory reference <mem>, defined above.
|
|
|
|
|
// Only used on x86 for CALL/JMP *sym(SB), which calls/jumps to a function
|
|
|
|
|
// pointer stored in the data word sym(SB), not a function named sym(SB).
|
|
|
|
|
// Encoding: same as above, but type = TYPE_INDIR.
|
|
|
|
|
//
|
|
|
|
|
// $*$<mem>
|
|
|
|
|
// No longer used.
|
|
|
|
|
// On machines with actual SB registers, $*$<mem> forced the
|
|
|
|
|
// instruction encoding to use a full 32-bit constant, never a
|
|
|
|
|
// reference relative to SB.
|
|
|
|
|
//
|
|
|
|
|
// $<floating point literal>
|
|
|
|
|
// Floating point constant value.
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_FCONST
|
|
|
|
|
// u.dval = floating point value
|
|
|
|
|
//
|
|
|
|
|
// $<string literal, up to 8 chars>
|
|
|
|
|
// String literal value (raw bytes used for DATA instruction).
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_SCONST
|
|
|
|
|
// u.sval = string
|
|
|
|
|
//
|
|
|
|
|
// <register name>
|
|
|
|
|
// Any register: integer, floating point, control, segment, and so on.
|
|
|
|
|
// If looking for specific register kind, must check type and reg value range.
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_REG
|
|
|
|
|
// reg = reg (REG_*)
|
|
|
|
|
//
|
|
|
|
|
// x(PC)
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_BRANCH
|
|
|
|
|
// u.branch = Prog* reference OR ELSE offset = target pc (branch takes priority)
|
|
|
|
|
//
|
|
|
|
|
// $±x-±y
|
|
|
|
|
// Final argument to TEXT, specifying local frame size x and argument size y.
|
|
|
|
|
// In this form, x and y are integer literals only, not arbitrary expressions.
|
|
|
|
|
// This avoids parsing ambiguities due to the use of - as a separator.
|
|
|
|
|
// The ± are optional.
|
|
|
|
|
// If the final argument to TEXT omits the -±y, the encoding should still
|
|
|
|
|
// use TYPE_TEXTSIZE (not TYPE_CONST), with u.argsize = ArgsSizeUnknown.
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_TEXTSIZE
|
|
|
|
|
// offset = x
|
|
|
|
|
// u.argsize = y
|
|
|
|
|
//
|
|
|
|
|
// reg<<shift, reg>>shift, reg->shift, reg@>shift
|
|
|
|
|
// Shifted register value, for ARM.
|
|
|
|
|
// In this form, reg must be a register and shift can be a register or an integer constant.
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_SHIFT
|
|
|
|
|
// offset = (reg&15) | shifttype<<5 | count
|
|
|
|
|
// shifttype = 0, 1, 2, 3 for <<, >>, ->, @>
|
|
|
|
|
// count = (reg&15)<<8 | 1<<4 for a register shift count, (n&31)<<7 for an integer constant.
|
|
|
|
|
//
|
|
|
|
|
// (reg, reg)
|
|
|
|
|
// A destination register pair. When used as the last argument of an instruction,
|
|
|
|
|
// this form makes clear that both registers are destinations.
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_REGREG
|
|
|
|
|
// reg = first register
|
|
|
|
|
// offset = second register
|
|
|
|
|
//
|
2015-02-27 13:50:26 -08:00
|
|
|
// [reg, reg, reg-reg]
|
|
|
|
|
// Register list for ARM.
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_REGLIST
|
|
|
|
|
// offset = bit mask of registers in list; R0 is low bit.
|
|
|
|
|
//
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
// reg, reg
|
2015-03-05 10:39:23 -08:00
|
|
|
// Register pair for ARM.
|
|
|
|
|
// TYPE_REGREG2
|
|
|
|
|
//
|
|
|
|
|
// (reg+reg)
|
|
|
|
|
// Register pair for PPC64.
|
|
|
|
|
// Encoding:
|
|
|
|
|
// type = TYPE_MEM
|
|
|
|
|
// reg = first register
|
|
|
|
|
// index = second register
|
|
|
|
|
// scale = 1
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
NAME_NONE = 0 + iota
|
|
|
|
|
NAME_EXTERN
|
|
|
|
|
NAME_STATIC
|
|
|
|
|
NAME_AUTO
|
|
|
|
|
NAME_PARAM
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
2015-03-05 14:04:12 -05:00
|
|
|
TYPE_NONE = 0
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
TYPE_BRANCH = 5 + iota
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
TYPE_TEXTSIZE
|
|
|
|
|
TYPE_MEM
|
|
|
|
|
TYPE_CONST
|
|
|
|
|
TYPE_FCONST
|
|
|
|
|
TYPE_SCONST
|
|
|
|
|
TYPE_REG
|
|
|
|
|
TYPE_ADDR
|
|
|
|
|
TYPE_SHIFT
|
|
|
|
|
TYPE_REGREG
|
|
|
|
|
TYPE_REGREG2
|
|
|
|
|
TYPE_INDIR
|
2015-02-27 13:50:26 -08:00
|
|
|
TYPE_REGLIST
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// TODO(rsc): Describe prog.
|
|
|
|
|
// TODO(rsc): Describe TEXT/GLOBL flag in from3, DATA width in from3.
|
|
|
|
|
|
|
|
|
|
// Prog.as opcodes.
|
|
|
|
|
// These are the portable opcodes, common to all architectures.
|
|
|
|
|
// Each architecture defines many more arch-specific opcodes,
|
|
|
|
|
// with values starting at A_ARCHSPECIFIC.
|
2015-03-02 20:17:20 -08:00
|
|
|
// Each architecture adds an offset to this so each machine has
|
|
|
|
|
// distinct space for its instructions. The offset is a power of
|
|
|
|
|
// two so it can be masked to return to origin zero.
|
|
|
|
|
// See the definitions of ABase386 etc.
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
const (
|
|
|
|
|
AXXX = 0 + iota
|
|
|
|
|
ACALL
|
|
|
|
|
ACHECKNIL
|
|
|
|
|
ADATA
|
|
|
|
|
ADUFFCOPY
|
|
|
|
|
ADUFFZERO
|
|
|
|
|
AEND
|
|
|
|
|
AFUNCDATA
|
|
|
|
|
AGLOBL
|
|
|
|
|
AJMP
|
|
|
|
|
ANOP
|
|
|
|
|
APCDATA
|
|
|
|
|
ARET
|
|
|
|
|
ATEXT
|
|
|
|
|
ATYPE
|
|
|
|
|
AUNDEF
|
|
|
|
|
AUSEFIELD
|
|
|
|
|
AVARDEF
|
|
|
|
|
AVARKILL
|
|
|
|
|
A_ARCHSPECIFIC
|
|
|
|
|
)
|
2015-01-19 14:34:58 -05:00
|
|
|
|
|
|
|
|
// prevent incompatible type signatures between liblink and 8l on Plan 9
|
|
|
|
|
|
|
|
|
|
// LSym.type
|
|
|
|
|
const (
|
|
|
|
|
Sxxx = iota
|
|
|
|
|
STEXT
|
|
|
|
|
SELFRXSECT
|
|
|
|
|
STYPE
|
|
|
|
|
SSTRING
|
|
|
|
|
SGOSTRING
|
|
|
|
|
SGOFUNC
|
|
|
|
|
SRODATA
|
|
|
|
|
SFUNCTAB
|
|
|
|
|
STYPELINK
|
|
|
|
|
SSYMTAB
|
|
|
|
|
SPCLNTAB
|
|
|
|
|
SELFROSECT
|
|
|
|
|
SMACHOPLT
|
|
|
|
|
SELFSECT
|
|
|
|
|
SMACHO
|
|
|
|
|
SMACHOGOT
|
|
|
|
|
SWINDOWS
|
|
|
|
|
SELFGOT
|
|
|
|
|
SNOPTRDATA
|
|
|
|
|
SINITARR
|
|
|
|
|
SDATA
|
|
|
|
|
SBSS
|
|
|
|
|
SNOPTRBSS
|
|
|
|
|
STLSBSS
|
|
|
|
|
SXREF
|
|
|
|
|
SMACHOSYMSTR
|
|
|
|
|
SMACHOSYMTAB
|
|
|
|
|
SMACHOINDIRECTPLT
|
|
|
|
|
SMACHOINDIRECTGOT
|
|
|
|
|
SFILE
|
|
|
|
|
SFILEPATH
|
|
|
|
|
SCONST
|
|
|
|
|
SDYNIMPORT
|
|
|
|
|
SHOSTOBJ
|
|
|
|
|
SSUB = 1 << 8
|
|
|
|
|
SMASK = SSUB - 1
|
|
|
|
|
SHIDDEN = 1 << 9
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Reloc.type
|
|
|
|
|
const (
|
|
|
|
|
R_ADDR = 1 + iota
|
|
|
|
|
R_ADDRPOWER
|
|
|
|
|
R_SIZE
|
|
|
|
|
R_CALL
|
|
|
|
|
R_CALLARM
|
|
|
|
|
R_CALLIND
|
|
|
|
|
R_CALLPOWER
|
|
|
|
|
R_CONST
|
|
|
|
|
R_PCREL
|
|
|
|
|
R_TLS
|
|
|
|
|
R_TLS_LE
|
|
|
|
|
R_TLS_IE
|
|
|
|
|
R_GOTOFF
|
|
|
|
|
R_PLT0
|
|
|
|
|
R_PLT1
|
|
|
|
|
R_PLT2
|
|
|
|
|
R_USEFIELD
|
|
|
|
|
R_POWER_TOC
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Reloc.variant
|
|
|
|
|
const (
|
|
|
|
|
RV_NONE = iota
|
|
|
|
|
RV_POWER_LO
|
|
|
|
|
RV_POWER_HI
|
|
|
|
|
RV_POWER_HA
|
|
|
|
|
RV_POWER_DS
|
|
|
|
|
RV_CHECK_OVERFLOW = 1 << 8
|
|
|
|
|
RV_TYPE_MASK = RV_CHECK_OVERFLOW - 1
|
|
|
|
|
)
|
|
|
|
|
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
// Auto.name
|
2015-01-19 14:34:58 -05:00
|
|
|
const (
|
|
|
|
|
A_AUTO = 1 + iota
|
|
|
|
|
A_PARAM
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
LINKHASH = 100003
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Pcdata iterator.
|
|
|
|
|
// for(pciterinit(ctxt, &it, &pcd); !it.done; pciternext(&it)) { it.value holds in [it.pc, it.nextpc) }
|
|
|
|
|
|
|
|
|
|
// symbol version, incremented each time a file is loaded.
|
|
|
|
|
// version==1 is reserved for savehist.
|
|
|
|
|
const (
|
|
|
|
|
HistVersion = 1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Link holds the context for writing object code from a compiler
|
|
|
|
|
// to be linker input or for reading that input into the linker.
|
|
|
|
|
|
|
|
|
|
// LinkArch is the definition of a single architecture.
|
|
|
|
|
|
|
|
|
|
/* executable header types */
|
|
|
|
|
const (
|
|
|
|
|
Hunknown = 0 + iota
|
|
|
|
|
Hdarwin
|
|
|
|
|
Hdragonfly
|
|
|
|
|
Helf
|
|
|
|
|
Hfreebsd
|
|
|
|
|
Hlinux
|
|
|
|
|
Hnacl
|
|
|
|
|
Hnetbsd
|
|
|
|
|
Hopenbsd
|
|
|
|
|
Hplan9
|
|
|
|
|
Hsolaris
|
|
|
|
|
Hwindows
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
LinkAuto = 0 + iota
|
|
|
|
|
LinkInternal
|
|
|
|
|
LinkExternal
|
|
|
|
|
)
|
|
|
|
|
|
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.
- Brings in new, more regular Prog, Addr definitions
- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).
- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
They need to be updated for the changes.
- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.
All architectures build successfully again.
Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 03:57:44 -05:00
|
|
|
var linkbasepointer int
|