aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2017-04-18 12:53:25 -0700
committerMatthew Dempsky <mdempsky@google.com>2017-04-19 00:00:09 +0000
commit1e3570ac86f6aeb7f8ce70b5ad236a5dd92ec804 (patch)
tree6bb1e704f068dee9f7e95eb0d1b5ed1829441c8b /src/cmd/internal/obj
parentf71f32e5e155ae5b7f60005c939746637086f30e (diff)
downloadgo-1e3570ac86f6aeb7f8ce70b5ad236a5dd92ec804.tar.xz
cmd/internal/objabi: extract shared functionality from obj
Now only cmd/asm and cmd/compile depend on cmd/internal/obj. Changing the assembler backends no longer requires reinstalling cmd/link or cmd/addr2line. There's also now one canonical definition of the object file format in cmd/internal/objabi/doc.go, with a warning to update all three implementations. objabi is still something of a grab bag of unrelated code (e.g., flag and environment variable handling probably belong in a separate "tool" package), but this is still progress. Fixes #15165. Fixes #20026. Change-Id: Ic4b92fac7d0d35438e0d20c9579aad4085c5534c Reviewed-on: https://go-review.googlesource.com/40972 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'src/cmd/internal/obj')
-rw-r--r--src/cmd/internal/obj/arm/asm5.go31
-rw-r--r--src/cmd/internal/obj/arm/obj5.go21
-rw-r--r--src/cmd/internal/obj/arm64/asm7.go25
-rw-r--r--src/cmd/internal/obj/arm64/obj7.go17
-rw-r--r--src/cmd/internal/obj/data.go9
-rw-r--r--src/cmd/internal/obj/flag.go115
-rw-r--r--src/cmd/internal/obj/funcdata.go25
-rw-r--r--src/cmd/internal/obj/go.go72
-rw-r--r--src/cmd/internal/obj/line.go61
-rw-r--r--src/cmd/internal/obj/link.go359
-rw-r--r--src/cmd/internal/obj/mips/asm0.go31
-rw-r--r--src/cmd/internal/obj/mips/obj0.go13
-rw-r--r--src/cmd/internal/obj/objfile.go127
-rw-r--r--src/cmd/internal/obj/plist.go25
-rw-r--r--src/cmd/internal/obj/ppc64/asm9.go27
-rw-r--r--src/cmd/internal/obj/ppc64/obj9.go19
-rw-r--r--src/cmd/internal/obj/reloctype_string.go17
-rw-r--r--src/cmd/internal/obj/s390x/asmz.go17
-rw-r--r--src/cmd/internal/obj/s390x/objz.go19
-rw-r--r--src/cmd/internal/obj/stack.go21
-rw-r--r--src/cmd/internal/obj/sym.go23
-rw-r--r--src/cmd/internal/obj/symkind_string.go16
-rw-r--r--src/cmd/internal/obj/typekind.go41
-rw-r--r--src/cmd/internal/obj/util.go53
-rw-r--r--src/cmd/internal/obj/x86/asm6.go91
-rw-r--r--src/cmd/internal/obj/x86/obj6.go55
26 files changed, 231 insertions, 1099 deletions
diff --git a/src/cmd/internal/obj/arm/asm5.go b/src/cmd/internal/obj/arm/asm5.go
index 4725737b2b..4476439350 100644
--- a/src/cmd/internal/obj/arm/asm5.go
+++ b/src/cmd/internal/obj/arm/asm5.go
@@ -32,6 +32,7 @@ package arm
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"fmt"
"log"
"math"
@@ -602,7 +603,7 @@ func span5(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
p.Pc = int64(pc)
o = c.oplook(p)
- if ctxt.Headtype != obj.Hnacl {
+ if ctxt.Headtype != objabi.Hnacl {
m = int(o.size)
} else {
m = c.asmoutnacl(pc, p, o, nil)
@@ -696,7 +697,7 @@ func span5(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
*/
opc = int32(p.Pc)
- if ctxt.Headtype != obj.Hnacl {
+ if ctxt.Headtype != objabi.Hnacl {
m = int(o.size)
} else {
m = c.asmoutnacl(pc, p, o, nil)
@@ -756,7 +757,7 @@ func span5(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
c.pc = p.Pc
o = c.oplook(p)
opc = int32(p.Pc)
- if ctxt.Headtype != obj.Hnacl {
+ if ctxt.Headtype != objabi.Hnacl {
c.asmout(p, o, out[:])
m = int(o.size)
} else {
@@ -834,7 +835,7 @@ func (c *ctxt5) flushpool(p *obj.Prog, skip int, force int) bool {
} else if force == 0 && (p.Pc+int64(12+c.pool.size)-int64(c.pool.start) < 2048) { // 12 take into account the maximum nacl literal pool alignment padding size
return false
}
- if c.ctxt.Headtype == obj.Hnacl && c.pool.size%16 != 0 {
+ if c.ctxt.Headtype == objabi.Hnacl && c.pool.size%16 != 0 {
// if pool is not multiple of 16 bytes, add an alignment marker
q := c.newprog()
@@ -902,7 +903,7 @@ func (c *ctxt5) addpool(p *obj.Prog, a *obj.Addr) {
}
}
- if c.ctxt.Headtype == obj.Hnacl && c.pool.size%16 == 0 {
+ if c.ctxt.Headtype == objabi.Hnacl && c.pool.size%16 == 0 {
// start a new data bundle
q := c.newprog()
q.As = ADATABUNDLE
@@ -1019,7 +1020,7 @@ func (c *ctxt5) aclass(a *obj.Addr) int {
}
c.instoffset = 0 // s.b. unused but just in case
- if a.Sym.Type == obj.STLSBSS {
+ if a.Sym.Type == objabi.STLSBSS {
if c.ctxt.Flag_shared {
return C_TLS_IE
} else {
@@ -1584,7 +1585,7 @@ func (c *ctxt5) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Sym = p.To.Sym
v += int32(p.To.Offset)
rel.Add = int64(o1) | (int64(v)>>2)&0xffffff
- rel.Type = obj.R_CALLARM
+ rel.Type = objabi.R_CALLARM
break
}
@@ -1612,7 +1613,7 @@ func (c *ctxt5) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel := obj.Addrel(c.cursym)
rel.Off = int32(c.pc)
rel.Siz = 0
- rel.Type = obj.R_CALLIND
+ rel.Type = objabi.R_CALLIND
case 8: /* sll $c,[R],R -> mov (R<<$c),R */
c.aclass(&p.From)
@@ -1661,13 +1662,13 @@ func (c *ctxt5) asmout(p *obj.Prog, o *Optab, out []uint32) {
if c.ctxt.Flag_shared {
if p.To.Name == obj.NAME_GOTREF {
- rel.Type = obj.R_GOTPCREL
+ rel.Type = objabi.R_GOTPCREL
} else {
- rel.Type = obj.R_PCREL
+ rel.Type = objabi.R_PCREL
}
rel.Add += c.pc - p.Rel.Pc - 8
} else {
- rel.Type = obj.R_ADDR
+ rel.Type = objabi.R_ADDR
}
o1 = 0
}
@@ -2080,7 +2081,7 @@ func (c *ctxt5) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Off = int32(c.pc)
rel.Siz = 4
rel.Sym = p.To.Sym
- rel.Type = obj.R_TLS_LE
+ rel.Type = objabi.R_TLS_LE
o1 = 0
case 104: /* word tlsvar, initial exec */
@@ -2094,7 +2095,7 @@ func (c *ctxt5) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Off = int32(c.pc)
rel.Siz = 4
rel.Sym = p.To.Sym
- rel.Type = obj.R_TLS_IE
+ rel.Type = objabi.R_TLS_IE
rel.Add = c.pc - p.Rel.Pc - 8 - int64(rel.Siz)
case 68: /* floating point store -> ADDR */
@@ -2849,7 +2850,7 @@ func (c *ctxt5) omvl(p *obj.Prog, a *obj.Addr, dr int) uint32 {
func (c *ctxt5) chipzero5(e float64) int {
// We use GOARM=7 to gate the use of VFPv3 vmov (imm) instructions.
- if obj.GOARM < 7 || e != 0 {
+ if objabi.GOARM < 7 || e != 0 {
return -1
}
return 0
@@ -2857,7 +2858,7 @@ func (c *ctxt5) chipzero5(e float64) int {
func (c *ctxt5) chipfloat5(e float64) int {
// We use GOARM=7 to gate the use of VFPv3 vmov (imm) instructions.
- if obj.GOARM < 7 {
+ if objabi.GOARM < 7 {
return -1
}
diff --git a/src/cmd/internal/obj/arm/obj5.go b/src/cmd/internal/obj/arm/obj5.go
index cb34d16705..49a24c9b5f 100644
--- a/src/cmd/internal/obj/arm/obj5.go
+++ b/src/cmd/internal/obj/arm/obj5.go
@@ -32,6 +32,7 @@ package arm
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/sys"
)
@@ -62,7 +63,7 @@ func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
ctxt.Diag("%v: TLS MRC instruction must write to R0 as it might get translated into a BL instruction", p.Line())
}
- if obj.GOARM < 7 {
+ if objabi.GOARM < 7 {
// Replace it with BL runtime.read_tls_fallback(SB) for ARM CPUs that lack the tls extension.
if progedit_tlsfallback == nil {
progedit_tlsfallback = ctxt.Lookup("runtime.read_tls_fallback", 0)
@@ -205,7 +206,7 @@ func (c *ctxt5) rewriteToUseGot(p *obj.Prog) {
if p.As == obj.ATEXT || p.As == obj.AFUNCDATA || p.As == obj.ACALL || p.As == obj.ARET || p.As == obj.AJMP {
return
}
- if source.Sym.Type == obj.STLSBSS {
+ if source.Sym.Type == objabi.STLSBSS {
return
}
if source.Type != obj.TYPE_MEM {
@@ -632,7 +633,7 @@ func isfloatreg(a *obj.Addr) bool {
}
func (c *ctxt5) softfloat() {
- if obj.GOARM > 5 {
+ if objabi.GOARM > 5 {
return
}
@@ -722,7 +723,7 @@ func (c *ctxt5) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R1
- if framesize <= obj.StackSmall {
+ if framesize <= objabi.StackSmall {
// small stack: SP < stackguard
// CMP stackguard, SP
p = obj.Appendp(p, c.newprog)
@@ -731,7 +732,7 @@ func (c *ctxt5) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.From.Type = obj.TYPE_REG
p.From.Reg = REG_R1
p.Reg = REGSP
- } else if framesize <= obj.StackBig {
+ } else if framesize <= objabi.StackBig {
// large stack: SP-framesize < stackguard-StackSmall
// MOVW $-(framesize-StackSmall)(SP), R2
// CMP stackguard, R2
@@ -740,7 +741,7 @@ func (c *ctxt5) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.As = AMOVW
p.From.Type = obj.TYPE_ADDR
p.From.Reg = REGSP
- p.From.Offset = -(int64(framesize) - obj.StackSmall)
+ p.From.Offset = -(int64(framesize) - objabi.StackSmall)
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R2
@@ -764,14 +765,14 @@ func (c *ctxt5) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.As = ACMP
p.From.Type = obj.TYPE_CONST
- p.From.Offset = int64(uint32(obj.StackPreempt & (1<<32 - 1)))
+ p.From.Offset = int64(uint32(objabi.StackPreempt & (1<<32 - 1)))
p.Reg = REG_R1
p = obj.Appendp(p, c.newprog)
p.As = AMOVW
p.From.Type = obj.TYPE_ADDR
p.From.Reg = REGSP
- p.From.Offset = obj.StackGuard
+ p.From.Offset = objabi.StackGuard
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R2
p.Scond = C_SCOND_NE
@@ -787,7 +788,7 @@ func (c *ctxt5) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p = obj.Appendp(p, c.newprog)
p.As = AMOVW
p.From.Type = obj.TYPE_ADDR
- p.From.Offset = int64(framesize) + (obj.StackGuard - obj.StackSmall)
+ p.From.Offset = int64(framesize) + (objabi.StackGuard - objabi.StackSmall)
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R3
p.Scond = C_SCOND_NE
@@ -820,7 +821,7 @@ func (c *ctxt5) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
pcdata.Pos = c.cursym.Func.Text.Pos
pcdata.As = obj.APCDATA
pcdata.From.Type = obj.TYPE_CONST
- pcdata.From.Offset = obj.PCDATA_StackMapIndex
+ pcdata.From.Offset = objabi.PCDATA_StackMapIndex
pcdata.To.Type = obj.TYPE_CONST
pcdata.To.Offset = -1 // pcdata starts at -1 at function entry
diff --git a/src/cmd/internal/obj/arm64/asm7.go b/src/cmd/internal/obj/arm64/asm7.go
index 4bc72aab51..b0510267fe 100644
--- a/src/cmd/internal/obj/arm64/asm7.go
+++ b/src/cmd/internal/obj/arm64/asm7.go
@@ -32,6 +32,7 @@ package arm64
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"fmt"
"log"
"math"
@@ -1100,7 +1101,7 @@ func (c *ctxt7) aclass(a *obj.Addr) int {
}
c.instoffset = a.Offset
if a.Sym != nil { // use relocation
- if a.Sym.Type == obj.STLSBSS {
+ if a.Sym.Type == objabi.STLSBSS {
if c.ctxt.Flag_shared {
return C_TLS_IE
} else {
@@ -1187,7 +1188,7 @@ func (c *ctxt7) aclass(a *obj.Addr) int {
if a.Sym == nil {
break
}
- if a.Sym.Type == obj.STLSBSS {
+ if a.Sym.Type == objabi.STLSBSS {
c.ctxt.Diag("taking address of TLS variable is not supported")
}
c.instoffset = a.Offset
@@ -2035,7 +2036,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 4
rel.Sym = p.To.Sym
rel.Add = p.To.Offset
- rel.Type = obj.R_CALLARM64
+ rel.Type = objabi.R_CALLARM64
case 6: /* b ,O(R); bl ,O(R) */
o1 = c.opbrr(p, p.As)
@@ -2044,7 +2045,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel := obj.Addrel(c.cursym)
rel.Off = int32(c.pc)
rel.Siz = 0
- rel.Type = obj.R_CALLIND
+ rel.Type = objabi.R_CALLIND
case 7: /* beq s */
o1 = c.opbra(p, p.As)
@@ -2116,7 +2117,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 8
rel.Sym = p.To.Sym
rel.Add = p.To.Offset
- rel.Type = obj.R_ADDR
+ rel.Type = objabi.R_ADDR
o2 = 0
o1 = o2
}
@@ -2164,7 +2165,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 4
rel.Sym = p.To.Sym
rel.Add = p.To.Offset
- rel.Type = obj.R_ADDR
+ rel.Type = objabi.R_ADDR
o1 = 0
}
@@ -2875,7 +2876,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 8
rel.Sym = p.To.Sym
rel.Add = p.To.Offset
- rel.Type = obj.R_ADDRARM64
+ rel.Type = objabi.R_ADDRARM64
o3 = c.olsr12u(p, int32(c.opstr12(p, p.As)), 0, REGTMP, int(p.From.Reg))
case 65: /* movT addr,R -> adrp + add + movT (REGTMP), R */
@@ -2886,7 +2887,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 8
rel.Sym = p.From.Sym
rel.Add = p.From.Offset
- rel.Type = obj.R_ADDRARM64
+ rel.Type = objabi.R_ADDRARM64
o3 = c.olsr12u(p, int32(c.opldr12(p, p.As)), 0, REGTMP, int(p.To.Reg))
case 66: /* ldp O(R)!, (r1, r2); ldp (R)O!, (r1, r2) */
@@ -2927,7 +2928,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 8
rel.Sym = p.From.Sym
rel.Add = p.From.Offset
- rel.Type = obj.R_ADDRARM64
+ rel.Type = objabi.R_ADDRARM64
case 69: /* LE model movd $tlsvar, reg -> movz reg, 0 + reloc */
o1 = c.opirr(p, AMOVZ)
@@ -2936,7 +2937,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Off = int32(c.pc)
rel.Siz = 4
rel.Sym = p.From.Sym
- rel.Type = obj.R_ARM64_TLS_LE
+ rel.Type = objabi.R_ARM64_TLS_LE
if p.From.Offset != 0 {
c.ctxt.Diag("invalid offset on MOVW $tlsvar")
}
@@ -2949,7 +2950,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 8
rel.Sym = p.From.Sym
rel.Add = 0
- rel.Type = obj.R_ARM64_TLS_IE
+ rel.Type = objabi.R_ARM64_TLS_IE
if p.From.Offset != 0 {
c.ctxt.Diag("invalid offset on MOVW $tlsvar")
}
@@ -2962,7 +2963,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 8
rel.Sym = p.From.Sym
rel.Add = 0
- rel.Type = obj.R_ARM64_GOTPCREL
+ rel.Type = objabi.R_ARM64_GOTPCREL
// This is supposed to be something that stops execution.
// It's not supposed to be reached, ever, but if it is, we'd
diff --git a/src/cmd/internal/obj/arm64/obj7.go b/src/cmd/internal/obj/arm64/obj7.go
index 4dec0a7cda..a4d9ee4a8b 100644
--- a/src/cmd/internal/obj/arm64/obj7.go
+++ b/src/cmd/internal/obj/arm64/obj7.go
@@ -32,6 +32,7 @@ package arm64
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/sys"
"math"
)
@@ -62,7 +63,7 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.To.Reg = REG_R1
q := (*obj.Prog)(nil)
- if framesize <= obj.StackSmall {
+ if framesize <= objabi.StackSmall {
// small stack: SP < stackguard
// MOV SP, R2
// CMP stackguard, R2
@@ -79,7 +80,7 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.From.Type = obj.TYPE_REG
p.From.Reg = REG_R1
p.Reg = REG_R2
- } else if framesize <= obj.StackBig {
+ } else if framesize <= objabi.StackBig {
// large stack: SP-framesize < stackguard-StackSmall
// SUB $(framesize-StackSmall), SP, R2
// CMP stackguard, R2
@@ -87,7 +88,7 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.As = ASUB
p.From.Type = obj.TYPE_CONST
- p.From.Offset = int64(framesize) - obj.StackSmall
+ p.From.Offset = int64(framesize) - objabi.StackSmall
p.Reg = REGSP
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R2
@@ -113,7 +114,7 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.As = ACMP
p.From.Type = obj.TYPE_CONST
- p.From.Offset = obj.StackPreempt
+ p.From.Offset = objabi.StackPreempt
p.Reg = REG_R1
p = obj.Appendp(p, c.newprog)
@@ -124,7 +125,7 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p = obj.Appendp(p, c.newprog)
p.As = AADD
p.From.Type = obj.TYPE_CONST
- p.From.Offset = obj.StackGuard
+ p.From.Offset = objabi.StackGuard
p.Reg = REGSP
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R2
@@ -139,7 +140,7 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p = obj.Appendp(p, c.newprog)
p.As = AMOVD
p.From.Type = obj.TYPE_CONST
- p.From.Offset = int64(framesize) + (obj.StackGuard - obj.StackSmall)
+ p.From.Offset = int64(framesize) + (objabi.StackGuard - objabi.StackSmall)
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R3
@@ -170,7 +171,7 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
pcdata.Pos = c.cursym.Func.Text.Pos
pcdata.As = obj.APCDATA
pcdata.From.Type = obj.TYPE_CONST
- pcdata.From.Offset = obj.PCDATA_StackMapIndex
+ pcdata.From.Offset = objabi.PCDATA_StackMapIndex
pcdata.To.Type = obj.TYPE_CONST
pcdata.To.Offset = -1 // pcdata starts at -1 at function entry
@@ -401,7 +402,7 @@ func (c *ctxt7) rewriteToUseGot(p *obj.Prog) {
if p.As == obj.ATEXT || p.As == obj.AFUNCDATA || p.As == obj.ACALL || p.As == obj.ARET || p.As == obj.AJMP {
return
}
- if source.Sym.Type == obj.STLSBSS {
+ if source.Sym.Type == objabi.STLSBSS {
return
}
if source.Type != obj.TYPE_MEM {
diff --git a/src/cmd/internal/obj/data.go b/src/cmd/internal/obj/data.go
index e67852ac3b..ab873123fc 100644
--- a/src/cmd/internal/obj/data.go
+++ b/src/cmd/internal/obj/data.go
@@ -32,6 +32,7 @@
package obj
import (
+ "cmd/internal/objabi"
"log"
"math"
)
@@ -72,7 +73,7 @@ func (s *LSym) prepwrite(ctxt *Link, off int64, siz int) {
if off < 0 || siz < 0 || off >= 1<<30 {
ctxt.Diag("prepwrite: bad off=%d siz=%d s=%v", off, siz, s)
}
- if s.Type == SBSS || s.Type == STLSBSS {
+ if s.Type == objabi.SBSS || s.Type == objabi.STLSBSS {
ctxt.Diag("cannot supply data for BSS var")
}
l := off + int64(siz)
@@ -125,7 +126,7 @@ func (s *LSym) WriteAddr(ctxt *Link, off int64, siz int, rsym *LSym, roff int64)
}
r.Siz = uint8(siz)
r.Sym = rsym
- r.Type = R_ADDR
+ r.Type = objabi.R_ADDR
r.Add = roff
}
@@ -141,7 +142,7 @@ func (s *LSym) WriteOff(ctxt *Link, off int64, rsym *LSym, roff int64) {
}
r.Siz = 4
r.Sym = rsym
- r.Type = R_ADDROFF
+ r.Type = objabi.R_ADDROFF
r.Add = roff
}
@@ -157,7 +158,7 @@ func (s *LSym) WriteWeakOff(ctxt *Link, off int64, rsym *LSym, roff int64) {
}
r.Siz = 4
r.Sym = rsym
- r.Type = R_WEAKADDROFF
+ r.Type = objabi.R_WEAKADDROFF
r.Add = roff
}
diff --git a/src/cmd/internal/obj/flag.go b/src/cmd/internal/obj/flag.go
deleted file mode 100644
index ff69fd9d57..0000000000
--- a/src/cmd/internal/obj/flag.go
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2015 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 obj
-
-import (
- "flag"
- "fmt"
- "os"
- "strconv"
-)
-
-func Flagfn2(string, string, func(string, string)) { panic("flag") }
-
-func Flagcount(name, usage string, val *int) {
- flag.Var((*count)(val), name, usage)
-}
-
-func Flagint32(name, usage string, val *int32) {
- flag.Var((*int32Value)(val), name, usage)
-}
-
-func Flagint64(name, usage string, val *int64) {
- flag.Int64Var(val, name, *val, usage)
-}
-
-func Flagstr(name, usage string, val *string) {
- flag.StringVar(val, name, *val, usage)
-}
-
-func Flagfn0(name, usage string, f func()) {
- flag.Var(fn0(f), name, usage)
-}
-
-func Flagfn1(name, usage string, f func(string)) {
- flag.Var(fn1(f), name, usage)
-}
-
-func Flagprint(fd int) {
- if fd == 1 {
- flag.CommandLine.SetOutput(os.Stdout)
- }
- flag.PrintDefaults()
-}
-
-func Flagparse(usage func()) {
- flag.Usage = usage
- flag.Parse()
-}
-
-// count is a flag.Value that is like a flag.Bool and a flag.Int.
-// If used as -name, it increments the count, but -name=x sets the count.
-// Used for verbose flag -v.
-type count int
-
-func (c *count) String() string {
- return fmt.Sprint(int(*c))
-}
-
-func (c *count) Set(s string) error {
- switch s {
- case "true":
- *c++
- case "false":
- *c = 0
- default:
- n, err := strconv.Atoi(s)
- if err != nil {
- return fmt.Errorf("invalid count %q", s)
- }
- *c = count(n)
- }
- return nil
-}
-
-func (c *count) IsBoolFlag() bool {
- return true
-}
-
-type int32Value int32
-
-func (i *int32Value) Set(s string) error {
- v, err := strconv.ParseInt(s, 0, 64)
- *i = int32Value(v)
- return err
-}
-
-func (i *int32Value) Get() interface{} { return int32(*i) }
-
-func (i *int32Value) String() string { return fmt.Sprint(*i) }
-
-type fn0 func()
-
-func (f fn0) Set(s string) error {
- f()
- return nil
-}
-
-func (f fn0) Get() interface{} { return nil }
-
-func (f fn0) String() string { return "" }
-
-func (f fn0) IsBoolFlag() bool {
- return true
-}
-
-type fn1 func(string)
-
-func (f fn1) Set(s string) error {
- f(s)
- return nil
-}
-
-func (f fn1) String() string { return "" }
diff --git a/src/cmd/internal/obj/funcdata.go b/src/cmd/internal/obj/funcdata.go
deleted file mode 100644
index af1dbc271d..0000000000
--- a/src/cmd/internal/obj/funcdata.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2013 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 obj
-
-// This file defines the IDs for PCDATA and FUNCDATA instructions
-// in Go binaries.
-//
-// These must agree with ../../../runtime/funcdata.h and
-// ../../../runtime/symtab.go.
-
-const (
- PCDATA_StackMapIndex = 0
- PCDATA_InlTreeIndex = 1
- FUNCDATA_ArgsPointerMaps = 0
- FUNCDATA_LocalsPointerMaps = 1
- FUNCDATA_InlTree = 2
-
- // ArgsSizeUnknown is set in Func.argsize to mark all functions
- // whose argument size is unknown (C vararg functions, and
- // assembly code without an explicit specification).
- // This value is generated by the compiler, assembler, or linker.
- ArgsSizeUnknown = -0x80000000
-)
diff --git a/src/cmd/internal/obj/go.go b/src/cmd/internal/obj/go.go
index 732ce19634..f0b2c46e4f 100644
--- a/src/cmd/internal/obj/go.go
+++ b/src/cmd/internal/obj/go.go
@@ -4,67 +4,8 @@
package obj
-import (
- "fmt"
- "os"
- "strings"
-)
-
// go-specific code shared across loaders (5l, 6l, 8l).
-var (
- framepointer_enabled int
- Fieldtrack_enabled int
- Preemptibleloops_enabled int
-)
-
-// Toolchain experiments.
-// These are controlled by the GOEXPERIMENT environment
-// variable recorded when the toolchain is built.
-// This list is also known to cmd/gc.
-var exper = []struct {
- name string
- val *int
-}{
- {"fieldtrack", &Fieldtrack_enabled},
- {"framepointer", &framepointer_enabled},
- {"preemptibleloops", &Preemptibleloops_enabled},
-}
-
-func addexp(s string) {
- // Could do general integer parsing here, but the runtime copy doesn't yet.
- v := 1
- name := s
- if len(name) > 2 && name[:2] == "no" {
- v = 0
- name = name[2:]
- }
- for i := 0; i < len(exper); i++ {
- if exper[i].name == name {
- if exper[i].val != nil {
- *exper[i].val = v
- }
- return
- }
- }
-
- fmt.Printf("unknown experiment %s\n", s)
- os.Exit(2)
-}
-
-func init() {
- framepointer_enabled = 1 // default
- for _, f := range strings.Split(goexperiment, ",") {
- if f != "" {
- addexp(f)
- }
- }
-}
-
-func Framepointer_enabled(goos, goarch string) bool {
- return framepointer_enabled != 0 && goarch == "amd64" && goos != "nacl"
-}
-
func Nopout(p *Prog) {
p.As = ANOP
p.Scond = 0
@@ -73,16 +14,3 @@ func Nopout(p *Prog) {
p.Reg = 0
p.To = Addr{}
}
-
-func Expstring() string {
- buf := "X"
- for i := range exper {
- if *exper[i].val != 0 {
- buf += "," + exper[i].name
- }
- }
- if buf == "X" {
- buf += ",none"
- }
- return "X:" + buf[2:]
-}
diff --git a/src/cmd/internal/obj/line.go b/src/cmd/internal/obj/line.go
index 0fb915ba30..fecf90c491 100644
--- a/src/cmd/internal/obj/line.go
+++ b/src/cmd/internal/obj/line.go
@@ -6,69 +6,8 @@ package obj
import (
"cmd/internal/src"
- "path/filepath"
)
-// AbsFile returns the absolute filename for file in the given directory.
-// It also removes a leading pathPrefix, or else rewrites a leading $GOROOT
-// prefix to the literal "$GOROOT".
-// If the resulting path is the empty string, the result is "??".
-func AbsFile(dir, file, pathPrefix string) string {
- abs := file
- if dir != "" && !filepath.IsAbs(file) {
- abs = filepath.Join(dir, file)
- }
-
- if pathPrefix != "" && hasPathPrefix(abs, pathPrefix) {
- if abs == pathPrefix {
- abs = ""
- } else {
- abs = abs[len(pathPrefix)+1:]
- }
- } else if hasPathPrefix(abs, GOROOT) {
- abs = "$GOROOT" + abs[len(GOROOT):]
- }
- if abs == "" {
- abs = "??"
- }
-
- return filepath.Clean(abs)
-}
-
-// Does s have t as a path prefix?
-// That is, does s == t or does s begin with t followed by a slash?
-// For portability, we allow ASCII case folding, so that hasPathPrefix("a/b/c", "A/B") is true.
-// Similarly, we allow slash folding, so that hasPathPrefix("a/b/c", "a\\b") is true.
-// We do not allow full Unicode case folding, for fear of causing more confusion
-// or harm than good. (For an example of the kinds of things that can go wrong,
-// see http://article.gmane.org/gmane.linux.kernel/1853266.)
-func hasPathPrefix(s string, t string) bool {
- if len(t) > len(s) {
- return false
- }
- var i int
- for i = 0; i < len(t); i++ {
- cs := int(s[i])
- ct := int(t[i])
- if 'A' <= cs && cs <= 'Z' {
- cs += 'a' - 'A'
- }
- if 'A' <= ct && ct <= 'Z' {
- ct += 'a' - 'A'
- }
- if cs == '\\' {
- cs = '/'
- }
- if ct == '\\' {
- ct = '/'
- }
- if cs != ct {
- return false
- }
- }
- return i >= len(s) || s[i] == '/' || s[i] == '\\'
-}
-
// AddImport adds a package to the list of imported packages.
func (ctxt *Link) AddImport(pkg string) {
ctxt.Imports = append(ctxt.Imports, pkg)
diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go
index 568abd58ef..840df52256 100644
--- a/src/cmd/internal/obj/link.go
+++ b/src/cmd/internal/obj/link.go
@@ -33,6 +33,7 @@ package obj
import (
"bufio"
"cmd/internal/dwarf"
+ "cmd/internal/objabi"
"cmd/internal/src"
"cmd/internal/sys"
"fmt"
@@ -308,7 +309,7 @@ const (
// An LSym is the sort of symbol that is written to an object file.
type LSym struct {
Name string
- Type SymKind
+ Type objabi.SymKind
Version int16
Attribute
@@ -447,289 +448,14 @@ type Pcln struct {
InlTree InlTree // per-function inlining tree extracted from the global tree
}
-// A SymKind describes the kind of memory represented by a symbol.
-type SymKind int16
-
-// Defined SymKind values.
-//
-// TODO(rsc): Give idiomatic Go names.
-// TODO(rsc): Reduce the number of symbol types in the object files.
-//go:generate stringer -type=SymKind
-const (
- Sxxx SymKind = iota
- STEXT
- SELFRXSECT
-
- // Read-only sections.
- STYPE
- SSTRING
- SGOSTRING
- SGOFUNC
- SGCBITS
- SRODATA
- SFUNCTAB
-
- SELFROSECT
- SMACHOPLT
-
- // Read-only sections with relocations.
- //
- // Types STYPE-SFUNCTAB above are written to the .rodata section by default.
- // When linking a shared object, some conceptually "read only" types need to
- // be written to by relocations and putting them in a section called
- // ".rodata" interacts poorly with the system linkers. The GNU linkers
- // support this situation by arranging for sections of the name
- // ".data.rel.ro.XXX" to be mprotected read only by the dynamic linker after
- // relocations have applied, so when the Go linker is creating a shared
- // object it checks all objects of the above types and bumps any object that
- // has a relocation to it to the corresponding type below, which are then
- // written to sections with appropriate magic names.
- STYPERELRO
- SSTRINGRELRO
- SGOSTRINGRELRO
- SGOFUNCRELRO
- SGCBITSRELRO
- SRODATARELRO
- SFUNCTABRELRO
-
- // Part of .data.rel.ro if it exists, otherwise part of .rodata.
- STYPELINK
- SITABLINK
- SSYMTAB
- SPCLNTAB
-
- // Writable sections.
- SELFSECT
- SMACHO
- SMACHOGOT
- SWINDOWS
- SELFGOT
- SNOPTRDATA
- SINITARR
- SDATA
- SBSS
- SNOPTRBSS
- STLSBSS
- SXREF
- SMACHOSYMSTR
- SMACHOSYMTAB
- SMACHOINDIRECTPLT
- SMACHOINDIRECTGOT
- SFILE
- SFILEPATH
- SCONST
- SDYNIMPORT
- SHOSTOBJ
- SDWARFSECT
- SDWARFINFO
- SSUB = SymKind(1 << 8)
- SMASK = SymKind(SSUB - 1)
- SHIDDEN = SymKind(1 << 9)
- SCONTAINER = SymKind(1 << 10) // has a sub-symbol
-)
-
-// ReadOnly are the symbol kinds that form read-only sections. In some
-// cases, if they will require relocations, they are transformed into
-// rel-ro sections using RelROMap.
-var ReadOnly = []SymKind{
- STYPE,
- SSTRING,
- SGOSTRING,
- SGOFUNC,
- SGCBITS,
- SRODATA,
- SFUNCTAB,
-}
-
-// RelROMap describes the transformation of read-only symbols to rel-ro
-// symbols.
-var RelROMap = map[SymKind]SymKind{
- STYPE: STYPERELRO,
- SSTRING: SSTRINGRELRO,
- SGOSTRING: SGOSTRINGRELRO,
- SGOFUNC: SGOFUNCRELRO,
- SGCBITS: SGCBITSRELRO,
- SRODATA: SRODATARELRO,
- SFUNCTAB: SFUNCTABRELRO,
-}
-
type Reloc struct {
Off int32
Siz uint8
- Type RelocType
+ Type objabi.RelocType
Add int64
Sym *LSym
}
-type RelocType int32
-
-//go:generate stringer -type=RelocType
-const (
- R_ADDR RelocType = 1 + iota
- // R_ADDRPOWER relocates a pair of "D-form" instructions (instructions with 16-bit
- // immediates in the low half of the instruction word), usually addis followed by
- // another add or a load, inserting the "high adjusted" 16 bits of the address of
- // the referenced symbol into the immediate field of the first instruction and the
- // low 16 bits into that of the second instruction.
- R_ADDRPOWER
- // R_ADDRARM64 relocates an adrp, add pair to compute the address of the
- // referenced symbol.
- R_ADDRARM64
- // R_ADDRMIPS (only used on mips/mips64) resolves to the low 16 bits of an external
- // address, by encoding it into the instruction.
- R_ADDRMIPS
- // R_ADDROFF resolves to a 32-bit offset from the beginning of the section
- // holding the data being relocated to the referenced symbol.
- R_ADDROFF
- // R_WEAKADDROFF resolves just like R_ADDROFF but is a weak relocation.
- // A weak relocation does not make the symbol it refers to reachable,
- // and is only honored by the linker if the symbol is in some other way
- // reachable.
- R_WEAKADDROFF
- R_SIZE
- R_CALL
- R_CALLARM
- R_CALLARM64
- R_CALLIND
- R_CALLPOWER
- // R_CALLMIPS (only used on mips64) resolves to non-PC-relative target address
- // of a CALL (JAL) instruction, by encoding the address into the instruction.
- R_CALLMIPS
- R_CONST
- R_PCREL
- // R_TLS_LE, used on 386, amd64, and ARM, resolves to the offset of the
- // thread-local symbol from the thread local base and is used to implement the
- // "local exec" model for tls access (r.Sym is not set on intel platforms but is
- // set to a TLS symbol -- runtime.tlsg -- in the linker when externally linking).
- R_TLS_LE
- // R_TLS_IE, used 386, amd64, and ARM resolves to the PC-relative offset to a GOT
- // slot containing the offset from the thread-local symbol from the thread local
- // base and is used to implemented the "initial exec" model for tls access (r.Sym
- // is not set on intel platforms but is set to a TLS symbol -- runtime.tlsg -- in
- // the linker when externally linking).
- R_TLS_IE
- R_GOTOFF
- R_PLT0
- R_PLT1
- R_PLT2
- R_USEFIELD
- // R_USETYPE resolves to an *rtype, but no relocation is created. The
- // linker uses this as a signal that the pointed-to type information
- // should be linked into the final binary, even if there are no other
- // direct references. (This is used for types reachable by reflection.)
- R_USETYPE
- // R_METHODOFF resolves to a 32-bit offset from the beginning of the section
- // holding the data being relocated to the referenced symbol.
- // It is a variant of R_ADDROFF used when linking from the uncommonType of a
- // *rtype, and may be set to zero by the linker if it determines the method
- // text is unreachable by the linked program.
- R_METHODOFF
- R_POWER_TOC
- R_GOTPCREL
- // R_JMPMIPS (only used on mips64) resolves to non-PC-relative target address
- // of a JMP instruction, by encoding the address into the instruction.
- // The stack nosplit check ignores this since it is not a function call.
- R_JMPMIPS
- // R_DWARFREF resolves to the offset of the symbol from its section.
- R_DWARFREF
-
- // Platform dependent relocations. Architectures with fixed width instructions
- // have the inherent issue that a 32-bit (or 64-bit!) displacement cannot be
- // stuffed into a 32-bit instruction, so an address needs to be spread across
- // several instructions, and in turn this requires a sequence of relocations, each
- // updating a part of an instruction. This leads to relocation codes that are
- // inherently processor specific.
-
- // Arm64.
-
- // Set a MOV[NZ] immediate field to bits [15:0] of the offset from the thread
- // local base to the thread local variable defined by the referenced (thread
- // local) symbol. Error if the offset does not fit into 16 bits.
- R_ARM64_TLS_LE
-
- // Relocates an ADRP; LD64 instruction sequence to load the offset between
- // the thread local base and the thread local variable defined by the
- // referenced (thread local) symbol from the GOT.
- R_ARM64_TLS_IE
-
- // R_ARM64_GOTPCREL relocates an adrp, ld64 pair to compute the address of the GOT
- // slot of the referenced symbol.
- R_ARM64_GOTPCREL
-
- // PPC64.
-
- // R_POWER_TLS_LE is used to implement the "local exec" model for tls
- // access. It resolves to the offset of the thread-local symbol from the
- // thread pointer (R13) and inserts this value into the low 16 bits of an
- // instruction word.
- R_POWER_TLS_LE
-
- // R_POWER_TLS_IE is used to implement the "initial exec" model for tls access. It
- // relocates a D-form, DS-form instruction sequence like R_ADDRPOWER_DS. It
- // inserts to the offset of GOT slot for the thread-local symbol from the TOC (the
- // GOT slot is filled by the dynamic linker with the offset of the thread-local
- // symbol from the thread pointer (R13)).
- R_POWER_TLS_IE
-
- // R_POWER_TLS marks an X-form instruction such as "MOVD 0(R13)(R31*1), g" as
- // accessing a particular thread-local symbol. It does not affect code generation
- // but is used by the system linker when relaxing "initial exec" model code to
- // "local exec" model code.
- R_POWER_TLS
-
- // R_ADDRPOWER_DS is similar to R_ADDRPOWER above, but assumes the second
- // instruction is a "DS-form" instruction, which has an immediate field occupying
- // bits [15:2] of the instruction word. Bits [15:2] of the address of the
- // relocated symbol are inserted into this field; it is an error if the last two
- // bits of the address are not 0.
- R_ADDRPOWER_DS
-
- // R_ADDRPOWER_PCREL relocates a D-form, DS-form instruction sequence like
- // R_ADDRPOWER_DS but inserts the offset of the GOT slot for the referenced symbol
- // from the TOC rather than the symbol's address.
- R_ADDRPOWER_GOT
-
- // R_ADDRPOWER_PCREL relocates two D-form instructions like R_ADDRPOWER, but
- // inserts the displacement from the place being relocated to the address of the
- // the relocated symbol instead of just its address.
- R_ADDRPOWER_PCREL
-
- // R_ADDRPOWER_TOCREL relocates two D-form instructions like R_ADDRPOWER, but
- // inserts the offset from the TOC to the address of the relocated symbol
- // rather than the symbol's address.
- R_ADDRPOWER_TOCREL
-
- // R_ADDRPOWER_TOCREL relocates a D-form, DS-form instruction sequence like
- // R_ADDRPOWER_DS but inserts the offset from the TOC to the address of the the
- // relocated symbol rather than the symbol's address.
- R_ADDRPOWER_TOCREL_DS
-
- // R_PCRELDBL relocates s390x 2-byte aligned PC-relative addresses.
- // TODO(mundaym): remove once variants can be serialized - see issue 14218.
- R_PCRELDBL
-
- // R_ADDRMIPSU (only used on mips/mips64) resolves to the sign-adjusted "upper" 16
- // bits (bit 16-31) of an external address, by encoding it into the instruction.
- R_ADDRMIPSU
- // R_ADDRMIPSTLS (only used on mips64) resolves to the low 16 bits of a TLS
- // address (offset from thread pointer), by encoding it into the instruction.
- R_ADDRMIPSTLS
-)
-
-// IsDirectJump returns whether r is a relocation for a direct jump.
-// A direct jump is a CALL or JMP instruction that takes the target address
-// as immediate. The address is embedded into the instruction, possibly
-// with limited width.
-// An indirect jump is a CALL or JMP instruction that takes the target address
-// in register or memory.
-func (r RelocType) IsDirectJump() bool {
- switch r {
- case R_CALL, R_CALLARM, R_CALLARM64, R_CALLPOWER, R_CALLMIPS, R_JMPMIPS:
- return true
- }
- return false
-}
-
type Auto struct {
Asym *LSym
Aoffset int32
@@ -737,12 +463,6 @@ type Auto struct {
Gotype *LSym
}
-// Auto.name
-const (
- A_AUTO = 1 + iota
- A_PARAM
-)
-
type Pcdata struct {
P []byte
}
@@ -750,7 +470,7 @@ type Pcdata struct {
// Link holds the context for writing object code from a compiler
// to be linker input or for reading that input into the linker.
type Link struct {
- Headtype HeadType
+ Headtype objabi.HeadType
Arch *LinkArch
Debugasm bool
Debugvlog bool
@@ -816,74 +536,3 @@ type LinkArch struct {
Progedit func(*Link, *Prog, ProgAlloc)
UnaryDst map[As]bool // Instruction takes one operand, a destination.
}
-
-// HeadType is the executable header type.
-type HeadType uint8
-
-const (
- Hunknown HeadType = iota
- Hdarwin
- Hdragonfly
- Hfreebsd
- Hlinux
- Hnacl
- Hnetbsd
- Hopenbsd
- Hplan9
- Hsolaris
- Hwindows
-)
-
-func (h *HeadType) Set(s string) error {
- switch s {
- case "darwin":
- *h = Hdarwin
- case "dragonfly":
- *h = Hdragonfly
- case "freebsd":
- *h = Hfreebsd
- case "linux", "android":
- *h = Hlinux
- case "nacl":
- *h = Hnacl
- case "netbsd":
- *h = Hnetbsd
- case "openbsd":
- *h = Hopenbsd
- case "plan9":
- *h = Hplan9
- case "solaris":
- *h = Hsolaris
- case "windows":
- *h = Hwindows
- default:
- return fmt.Errorf("invalid headtype: %q", s)
- }
- return nil
-}
-
-func (h *HeadType) String() string {
- switch *h {
- case Hdarwin:
- return "darwin"
- case Hdragonfly:
- return "dragonfly"
- case Hfreebsd:
- return "freebsd"
- case Hlinux:
- return "linux"
- case Hnacl:
- return "nacl"
- case Hnetbsd:
- return "netbsd"
- case Hopenbsd:
- return "openbsd"
- case Hplan9:
- return "plan9"
- case Hsolaris:
- return "solaris"
- case Hwindows:
- return "windows"
- }
- return fmt.Sprintf("HeadType(%d)", *h)
-}
diff --git a/src/cmd/internal/obj/mips/asm0.go b/src/cmd/internal/obj/mips/asm0.go
index dc9ca46db8..39c4d4750b 100644
--- a/src/cmd/internal/obj/mips/asm0.go
+++ b/src/cmd/internal/obj/mips/asm0.go
@@ -31,6 +31,7 @@ package mips
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/sys"
"fmt"
"log"
@@ -545,7 +546,7 @@ func (c *ctxt0) aclass(a *obj.Addr) int {
}
c.instoffset = a.Offset
if a.Sym != nil { // use relocation
- if a.Sym.Type == obj.STLSBSS {
+ if a.Sym.Type == objabi.STLSBSS {
return C_TLS
}
return C_ADDR
@@ -605,13 +606,13 @@ func (c *ctxt0) aclass(a *obj.Addr) int {
if s == nil {
break
}
- if s.Type == obj.SCONST {
+ if s.Type == objabi.SCONST {
c.instoffset = a.Offset
goto consize
}
c.instoffset = a.Offset
- if s.Type == obj.STLSBSS {
+ if s.Type == objabi.STLSBSS {
return C_STCON // address of TLS variable
}
return C_LECON
@@ -1219,9 +1220,9 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Sym = p.To.Sym
rel.Add = p.To.Offset
if p.As == AJAL {
- rel.Type = obj.R_CALLMIPS
+ rel.Type = objabi.R_CALLMIPS
} else {
- rel.Type = obj.R_JMPMIPS
+ rel.Type = objabi.R_JMPMIPS
}
case 12: /* movbs r,r */
@@ -1278,7 +1279,7 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel := obj.Addrel(c.cursym)
rel.Off = int32(c.pc)
rel.Siz = 0
- rel.Type = obj.R_CALLIND
+ rel.Type = objabi.R_CALLIND
case 19: /* mov $lcon,r ==> lu+or */
v := c.regoff(&p.From)
@@ -1474,14 +1475,14 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 4
rel.Sym = p.To.Sym
rel.Add = p.To.Offset
- rel.Type = obj.R_ADDRMIPSU
+ rel.Type = objabi.R_ADDRMIPSU
o2 = OP_IRR(c.opirr(p.As), uint32(0), uint32(REGTMP), uint32(p.From.Reg))
rel2 := obj.Addrel(c.cursym)
rel2.Off = int32(c.pc + 4)
rel2.Siz = 4
rel2.Sym = p.To.Sym
rel2.Add = p.To.Offset
- rel2.Type = obj.R_ADDRMIPS
+ rel2.Type = objabi.R_ADDRMIPS
if o.size == 12 {
o3 = o2
@@ -1496,14 +1497,14 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 4
rel.Sym = p.From.Sym
rel.Add = p.From.Offset
- rel.Type = obj.R_ADDRMIPSU
+ rel.Type = objabi.R_ADDRMIPSU
o2 = OP_IRR(c.opirr(-p.As), uint32(0), uint32(REGTMP), uint32(p.To.Reg))
rel2 := obj.Addrel(c.cursym)
rel2.Off = int32(c.pc + 4)
rel2.Siz = 4
rel2.Sym = p.From.Sym
rel2.Add = p.From.Offset
- rel2.Type = obj.R_ADDRMIPS
+ rel2.Type = objabi.R_ADDRMIPS
if o.size == 12 {
o3 = o2
@@ -1518,14 +1519,14 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 4
rel.Sym = p.From.Sym
rel.Add = p.From.Offset
- rel.Type = obj.R_ADDRMIPSU
+ rel.Type = objabi.R_ADDRMIPSU
o2 = OP_IRR(c.opirr(add), uint32(0), uint32(p.To.Reg), uint32(p.To.Reg))
rel2 := obj.Addrel(c.cursym)
rel2.Off = int32(c.pc + 4)
rel2.Siz = 4
rel2.Sym = p.From.Sym
rel2.Add = p.From.Offset
- rel2.Type = obj.R_ADDRMIPS
+ rel2.Type = objabi.R_ADDRMIPS
if o.size == 12 {
o3 = o2
@@ -1543,7 +1544,7 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 4
rel.Sym = p.To.Sym
rel.Add = p.To.Offset
- rel.Type = obj.R_ADDRMIPSTLS
+ rel.Type = objabi.R_ADDRMIPSTLS
case 54: /* mov tlsvar, r ==> rdhwr + lw o(r3) */
// clobbers R3 !
@@ -1554,7 +1555,7 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 4
rel.Sym = p.From.Sym
rel.Add = p.From.Offset
- rel.Type = obj.R_ADDRMIPSTLS
+ rel.Type = objabi.R_ADDRMIPSTLS
case 55: /* mov $tlsvar, r ==> rdhwr + add */
// clobbers R3 !
@@ -1565,7 +1566,7 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 4
rel.Sym = p.From.Sym
rel.Add = p.From.Offset
- rel.Type = obj.R_ADDRMIPSTLS
+ rel.Type = objabi.R_ADDRMIPSTLS
}
out[0] = o1
diff --git a/src/cmd/internal/obj/mips/obj0.go b/src/cmd/internal/obj/mips/obj0.go
index 2316bc64ec..fd53c3212e 100644
--- a/src/cmd/internal/obj/mips/obj0.go
+++ b/src/cmd/internal/obj/mips/obj0.go
@@ -31,6 +31,7 @@ package mips
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/sys"
"encoding/binary"
"fmt"
@@ -634,7 +635,7 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.To.Reg = REG_R1
var q *obj.Prog
- if framesize <= obj.StackSmall {
+ if framesize <= objabi.StackSmall {
// small stack: SP < stackguard
// AGTU SP, stackguard, R1
p = obj.Appendp(p, c.newprog)
@@ -645,7 +646,7 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.Reg = REG_R1
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R1
- } else if framesize <= obj.StackBig {
+ } else if framesize <= objabi.StackBig {
// large stack: SP-framesize < stackguard-StackSmall
// ADD $-(framesize-StackSmall), SP, R2
// SGTU R2, stackguard, R1
@@ -653,7 +654,7 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.As = add
p.From.Type = obj.TYPE_CONST
- p.From.Offset = -(int64(framesize) - obj.StackSmall)
+ p.From.Offset = -(int64(framesize) - objabi.StackSmall)
p.Reg = REGSP
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R2
@@ -685,7 +686,7 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.As = mov
p.From.Type = obj.TYPE_CONST
- p.From.Offset = obj.StackPreempt
+ p.From.Offset = objabi.StackPreempt
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R2
@@ -701,7 +702,7 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p = obj.Appendp(p, c.newprog)
p.As = add
p.From.Type = obj.TYPE_CONST
- p.From.Offset = obj.StackGuard
+ p.From.Offset = objabi.StackGuard
p.Reg = REGSP
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R2
@@ -716,7 +717,7 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p = obj.Appendp(p, c.newprog)
p.As = mov
p.From.Type = obj.TYPE_CONST
- p.From.Offset = int64(framesize) + obj.StackGuard - obj.StackSmall
+ p.From.Offset = int64(framesize) + objabi.StackGuard - objabi.StackSmall
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R1
diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go
index 2e9e65a99f..d83ccca9a6 100644
--- a/src/cmd/internal/obj/objfile.go
+++ b/src/cmd/internal/obj/objfile.go
@@ -3,118 +3,13 @@
// license that can be found in the LICENSE file.
// Writing of Go object files.
-//
-// Originally, Go object files were Plan 9 object files, but no longer.
-// Now they are more like standard object files, in that each symbol is defined
-// by an associated memory image (bytes) and a list of relocations to apply
-// during linking. We do not (yet?) use a standard file format, however.
-// For now, the format is chosen to be as simple as possible to read and write.
-// It may change for reasons of efficiency, or we may even switch to a
-// standard file format if there are compelling benefits to doing so.
-// See golang.org/s/go13linker for more background.
-//
-// The file format is:
-//
-// - magic header: "\x00\x00go19ld"
-// - byte 1 - version number
-// - sequence of strings giving dependencies (imported packages)
-// - empty string (marks end of sequence)
-// - sequence of symbol references used by the defined symbols
-// - byte 0xff (marks end of sequence)
-// - sequence of integer lengths:
-// - total data length
-// - total number of relocations
-// - total number of pcdata
-// - total number of automatics
-// - total number of funcdata
-// - total number of files
-// - data, the content of the defined symbols
-// - sequence of defined symbols
-// - byte 0xff (marks end of sequence)
-// - magic footer: "\xff\xffgo19ld"
-//
-// All integers are stored in a zigzag varint format.
-// See golang.org/s/go12symtab for a definition.
-//
-// Data blocks and strings are both stored as an integer
-// followed by that many bytes.
-//
-// A symbol reference is a string name followed by a version.
-//
-// A symbol points to other symbols using an index into the symbol
-// reference sequence. Index 0 corresponds to a nil LSym* pointer.
-// In the symbol layout described below "symref index" stands for this
-// index.
-//
-// Each symbol is laid out as the following fields (taken from LSym*):
-//
-// - byte 0xfe (sanity check for synchronization)
-// - type [int]
-// - name & version [symref index]
-// - flags [int]
-// 1<<0 dupok
-// 1<<1 local
-// 1<<2 add to typelink table
-// - size [int]
-// - gotype [symref index]
-// - p [data block]
-// - nr [int]
-// - r [nr relocations, sorted by off]
-//
-// If type == STEXT, there are a few more fields:
-//
-// - args [int]
-// - locals [int]
-// - nosplit [int]
-// - flags [int]
-// 1<<0 leaf
-// 1<<1 C function
-// 1<<2 function may call reflect.Type.Method
-// - nlocal [int]
-// - local [nlocal automatics]
-// - pcln [pcln table]
-//
-// Each relocation has the encoding:
-//
-// - off [int]
-// - siz [int]
-// - type [int]
-// - add [int]
-// - sym [symref index]
-//
-// Each local has the encoding:
-//
-// - asym [symref index]
-// - offset [int]
-// - type [int]
-// - gotype [symref index]
-//
-// The pcln table has the encoding:
-//
-// - pcsp [data block]
-// - pcfile [data block]
-// - pcline [data block]
-// - pcinline [data block]
-// - npcdata [int]
-// - pcdata [npcdata data blocks]
-// - nfuncdata [int]
-// - funcdata [nfuncdata symref index]
-// - funcdatasym [nfuncdata ints]
-// - nfile [int]
-// - file [nfile symref index]
-// - ninlinedcall [int]
-// - inlinedcall [ninlinedcall int symref int symref]
-//
-// The file layout and meaning of type integers are architecture-independent.
-//
-// TODO(rsc): The file format is good for a first pass but needs work.
-// - There are SymID in the object file that should really just be strings.
package obj
import (
"bufio"
"cmd/internal/dwarf"
+ "cmd/internal/objabi"
"cmd/internal/sys"
"fmt"
"log"
@@ -149,7 +44,7 @@ func (w *objWriter) addLengths(s *LSym) {
w.nData += len(s.P)
w.nReloc += len(s.R)
- if s.Type != STEXT {
+ if s.Type != objabi.STEXT {
return
}
@@ -289,7 +184,7 @@ func (w *objWriter) writeRefs(s *LSym) {
w.writeRef(s.R[i].Sym, false)
}
- if s.Type == STEXT {
+ if s.Type == objabi.STEXT {
for _, a := range s.Func.Autom {
w.writeRef(a.Asym, false)
w.writeRef(a.Gotype, false)
@@ -330,14 +225,14 @@ func (w *objWriter) writeSymDebug(s *LSym) {
fmt.Fprintf(ctxt.Bso, "nosplit ")
}
fmt.Fprintf(ctxt.Bso, "size=%d", s.Size)
- if s.Type == STEXT {
+ if s.Type == objabi.STEXT {
fmt.Fprintf(ctxt.Bso, " args=%#x locals=%#x", uint64(s.Func.Args), uint64(s.Func.Locals))
if s.Leaf() {
fmt.Fprintf(ctxt.Bso, " leaf")
}
}
fmt.Fprintf(ctxt.Bso, "\n")
- if s.Type == STEXT {
+ if s.Type == objabi.STEXT {
for p := s.Func.Text; p != nil; p = p.Link {
fmt.Fprintf(ctxt.Bso, "\t%#04x %v\n", uint(int(p.Pc)), p)
}
@@ -369,7 +264,7 @@ func (w *objWriter) writeSymDebug(s *LSym) {
name := ""
if r.Sym != nil {
name = r.Sym.Name
- } else if r.Type == R_TLS_LE {
+ } else if r.Type == objabi.R_TLS_LE {
name = "TLS"
}
if ctxt.Arch.InFamily(sys.ARM, sys.PPC64) {
@@ -415,7 +310,7 @@ func (w *objWriter) writeSym(s *LSym) {
w.writeRefIndex(r.Sym)
}
- if s.Type != STEXT {
+ if s.Type != objabi.STEXT {
return
}
@@ -442,9 +337,9 @@ func (w *objWriter) writeSym(s *LSym) {
w.writeRefIndex(a.Asym)
w.writeInt(int64(a.Aoffset))
if a.Name == NAME_AUTO {
- w.writeInt(A_AUTO)
+ w.writeInt(objabi.A_AUTO)
} else if a.Name == NAME_PARAM {
- w.writeInt(A_PARAM)
+ w.writeInt(objabi.A_PARAM)
} else {
log.Fatalf("%s: invalid local variable type %d", s.Name, a.Name)
}
@@ -552,12 +447,12 @@ func (c dwCtxt) AddSectionOffset(s dwarf.Sym, size int, t interface{}, ofs int64
rsym := t.(*LSym)
ls.WriteAddr(c.Link, ls.Size, size, rsym, ofs)
r := &ls.R[len(ls.R)-1]
- r.Type = R_DWARFREF
+ r.Type = objabi.R_DWARFREF
}
// dwarfSym returns the DWARF symbol for TEXT symbol.
func (ctxt *Link) dwarfSym(s *LSym) *LSym {
- if s.Type != STEXT {
+ if s.Type != objabi.STEXT {
ctxt.Diag("dwarfSym of non-TEXT %v", s)
}
if s.Func.dwarfSym == nil {
diff --git a/src/cmd/internal/obj/plist.go b/src/cmd/internal/obj/plist.go
index 2b01e079c1..84858b479c 100644
--- a/src/cmd/internal/obj/plist.go
+++ b/src/cmd/internal/obj/plist.go
@@ -5,6 +5,7 @@
package obj
import (
+ "cmd/internal/objabi"
"fmt"
"strings"
)
@@ -54,7 +55,7 @@ func Flushplist(ctxt *Link, plist *Plist, newprog ProgAlloc) {
continue
}
if p.To.Sym.Name == "go_args_stackmap" {
- if p.From.Type != TYPE_CONST || p.From.Offset != FUNCDATA_ArgsPointerMaps {
+ if p.From.Type != TYPE_CONST || p.From.Offset != objabi.FUNCDATA_ArgsPointerMaps {
ctxt.Diag("FUNCDATA use of go_args_stackmap(SB) without FUNCDATA_ArgsPointerMaps")
}
p.To.Sym = ctxt.Lookup(fmt.Sprintf("%s.args_stackmap", curtext.Name), int(curtext.Version))
@@ -81,7 +82,7 @@ func Flushplist(ctxt *Link, plist *Plist, newprog ProgAlloc) {
}
found := false
for p := s.Func.Text; p != nil; p = p.Link {
- if p.As == AFUNCDATA && p.From.Type == TYPE_CONST && p.From.Offset == FUNCDATA_ArgsPointerMaps {
+ if p.As == AFUNCDATA && p.From.Type == TYPE_CONST && p.From.Offset == objabi.FUNCDATA_ArgsPointerMaps {
found = true
break
}
@@ -91,7 +92,7 @@ func Flushplist(ctxt *Link, plist *Plist, newprog ProgAlloc) {
p := Appendp(s.Func.Text, newprog)
p.As = AFUNCDATA
p.From.Type = TYPE_CONST
- p.From.Offset = FUNCDATA_ArgsPointerMaps
+ p.From.Offset = objabi.FUNCDATA_ArgsPointerMaps
p.To.Type = TYPE_MEM
p.To.Name = NAME_EXTERN
p.To.Sym = ctxt.Lookup(fmt.Sprintf("%s.args_stackmap", s.Name), int(s.Version))
@@ -131,12 +132,12 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
s.Set(AttrWrapper, flag&WRAPPER != 0)
s.Set(AttrNeedCtxt, flag&NEEDCTXT != 0)
s.Set(AttrNoFrame, flag&NOFRAME != 0)
- s.Type = STEXT
+ s.Type = objabi.STEXT
ctxt.Text = append(ctxt.Text, s)
// Set up DWARF entry for s.
dsym := ctxt.dwarfSym(s)
- dsym.Type = SDWARFINFO
+ dsym.Type = objabi.SDWARFINFO
dsym.Set(AttrDuplicateOK, s.DuplicateOK())
ctxt.Data = append(ctxt.Data, dsym)
@@ -144,10 +145,10 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
// They will be filled in later if needed.
gcargs := &s.Func.GCArgs
gcargs.Set(AttrDuplicateOK, true)
- gcargs.Type = SRODATA
+ gcargs.Type = objabi.SRODATA
gclocals := &s.Func.GCLocals
gclocals.Set(AttrDuplicateOK, true)
- gclocals.Type = SRODATA
+ gclocals.Type = objabi.SRODATA
}
func (ctxt *Link) Globl(s *LSym, size int64, flag int) {
@@ -161,17 +162,17 @@ func (ctxt *Link) Globl(s *LSym, size int64, flag int) {
s.Set(AttrOnList, true)
ctxt.Data = append(ctxt.Data, s)
s.Size = size
- if s.Type == 0 || s.Type == SXREF {
- s.Type = SBSS
+ if s.Type == 0 || s.Type == objabi.SXREF {
+ s.Type = objabi.SBSS
}
if flag&DUPOK != 0 {
s.Set(AttrDuplicateOK, true)
}
if flag&RODATA != 0 {
- s.Type = SRODATA
+ s.Type = objabi.SRODATA
} else if flag&NOPTR != 0 {
- s.Type = SNOPTRBSS
+ s.Type = objabi.SNOPTRBSS
} else if flag&TLSBSS != 0 {
- s.Type = STLSBSS
+ s.Type = objabi.STLSBSS
}
}
diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go
index abf15196ec..033203bfd4 100644
--- a/src/cmd/internal/obj/ppc64/asm9.go
+++ b/src/cmd/internal/obj/ppc64/asm9.go
@@ -31,6 +31,7 @@ package ppc64
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"encoding/binary"
"fmt"
"log"
@@ -742,7 +743,7 @@ func (c *ctxt9) aclass(a *obj.Addr) int {
}
c.instoffset = a.Offset
if a.Sym != nil { // use relocation
- if a.Sym.Type == obj.STLSBSS {
+ if a.Sym.Type == objabi.STLSBSS {
if c.ctxt.Flag_shared {
return C_TLS_IE
} else {
@@ -809,7 +810,7 @@ func (c *ctxt9) aclass(a *obj.Addr) int {
if s == nil {
break
}
- if s.Type == obj.SCONST {
+ if s.Type == objabi.SCONST {
c.instoffset = a.Offset
goto consize
}
@@ -2052,17 +2053,17 @@ func (c *ctxt9) symbolAccess(s *obj.LSym, d int64, reg int16, op uint32) (o1, o2
if c.ctxt.Flag_shared {
switch form {
case D_FORM:
- rel.Type = obj.R_ADDRPOWER_TOCREL
+ rel.Type = objabi.R_ADDRPOWER_TOCREL
case DS_FORM:
- rel.Type = obj.R_ADDRPOWER_TOCREL_DS
+ rel.Type = objabi.R_ADDRPOWER_TOCREL_DS
}
} else {
switch form {
case D_FORM:
- rel.Type = obj.R_ADDRPOWER
+ rel.Type = objabi.R_ADDRPOWER
case DS_FORM:
- rel.Type = obj.R_ADDRPOWER_DS
+ rel.Type = objabi.R_ADDRPOWER_DS
}
}
return
@@ -2280,7 +2281,7 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) {
// we could add some assembly syntax so that the name
// of the variable does not have to be assumed.
rel.Sym = c.ctxt.Lookup("runtime.tls_g", 0)
- rel.Type = obj.R_POWER_TLS
+ rel.Type = objabi.R_POWER_TLS
}
o1 = AOP_RRR(c.opstorex(p.As), uint32(p.From.Reg), uint32(p.To.Index), uint32(r))
} else {
@@ -2311,7 +2312,7 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Off = int32(c.pc)
rel.Siz = 4
rel.Sym = c.ctxt.Lookup("runtime.tls_g", 0)
- rel.Type = obj.R_POWER_TLS
+ rel.Type = objabi.R_POWER_TLS
}
o1 = AOP_RRR(c.oploadx(p.As), uint32(p.To.Reg), uint32(p.From.Index), uint32(r))
} else {
@@ -2379,7 +2380,7 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) {
}
rel.Add = int64(v)
- rel.Type = obj.R_CALLPOWER
+ rel.Type = objabi.R_CALLPOWER
}
o2 = 0x60000000 // nop, sometimes overwritten by ld r2, 24(r1) when dynamic linking
@@ -2787,7 +2788,7 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Siz = 8
rel.Sym = p.From.Sym
rel.Add = p.From.Offset
- rel.Type = obj.R_ADDR
+ rel.Type = objabi.R_ADDR
o2 = 0
o1 = o2
}
@@ -3195,7 +3196,7 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Off = int32(c.pc)
rel.Siz = 4
rel.Sym = p.From.Sym
- rel.Type = obj.R_POWER_TLS_LE
+ rel.Type = objabi.R_POWER_TLS_LE
case 80:
if p.From.Offset != 0 {
@@ -3207,7 +3208,7 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Off = int32(c.pc)
rel.Siz = 8
rel.Sym = p.From.Sym
- rel.Type = obj.R_POWER_TLS_IE
+ rel.Type = objabi.R_POWER_TLS_IE
case 81:
v := c.vregoff(&p.To)
@@ -3221,7 +3222,7 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) {
rel.Off = int32(c.pc)
rel.Siz = 8
rel.Sym = p.From.Sym
- rel.Type = obj.R_ADDRPOWER_GOT
+ rel.Type = objabi.R_ADDRPOWER_GOT
case 82: /* vector instructions, VX-form and VC-form */
if p.From.Type == obj.TYPE_REG {
/* reg reg none OR reg reg reg */
diff --git a/src/cmd/internal/obj/ppc64/obj9.go b/src/cmd/internal/obj/ppc64/obj9.go
index 0adab5b79a..e4c6f63ca2 100644
--- a/src/cmd/internal/obj/ppc64/obj9.go
+++ b/src/cmd/internal/obj/ppc64/obj9.go
@@ -31,6 +31,7 @@ package ppc64
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/sys"
)
@@ -195,7 +196,7 @@ func (c *ctxt9) rewriteToUseGot(p *obj.Prog) {
if p.As == obj.ATEXT || p.As == obj.AFUNCDATA || p.As == obj.ACALL || p.As == obj.ARET || p.As == obj.AJMP {
return
}
- if source.Sym.Type == obj.STLSBSS {
+ if source.Sym.Type == objabi.STLSBSS {
return
}
if source.Type != obj.TYPE_MEM {
@@ -448,7 +449,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
autosize += int32(c.ctxt.FixedFrameSize())
}
- if p.Mark&LEAF != 0 && autosize < obj.StackSmall {
+ if p.Mark&LEAF != 0 && autosize < objabi.StackSmall {
// A leaf function with a small stack can be marked
// NOSPLIT, avoiding a stack check.
p.From.Sym.Set(obj.AttrNoSplit, true)
@@ -489,7 +490,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
rel.Off = 0
rel.Siz = 8
rel.Sym = c.ctxt.Lookup(".TOC.", 0)
- rel.Type = obj.R_ADDRPOWER_PCREL
+ rel.Type = objabi.R_ADDRPOWER_PCREL
}
if !c.cursym.Func.Text.From.Sym.NoSplit() {
@@ -840,7 +841,7 @@ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.To.Reg = REG_R3
var q *obj.Prog
- if framesize <= obj.StackSmall {
+ if framesize <= objabi.StackSmall {
// small stack: SP < stackguard
// CMP stackguard, SP
p = obj.Appendp(p, c.newprog)
@@ -850,7 +851,7 @@ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.From.Reg = REG_R3
p.To.Type = obj.TYPE_REG
p.To.Reg = REGSP
- } else if framesize <= obj.StackBig {
+ } else if framesize <= objabi.StackBig {
// large stack: SP-framesize < stackguard-StackSmall
// ADD $-(framesize-StackSmall), SP, R4
// CMP stackguard, R4
@@ -858,7 +859,7 @@ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.As = AADD
p.From.Type = obj.TYPE_CONST
- p.From.Offset = -(int64(framesize) - obj.StackSmall)
+ p.From.Offset = -(int64(framesize) - objabi.StackSmall)
p.Reg = REGSP
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R4
@@ -891,7 +892,7 @@ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p.From.Type = obj.TYPE_REG
p.From.Reg = REG_R3
p.To.Type = obj.TYPE_CONST
- p.To.Offset = obj.StackPreempt
+ p.To.Offset = objabi.StackPreempt
p = obj.Appendp(p, c.newprog)
q = p
@@ -901,7 +902,7 @@ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p = obj.Appendp(p, c.newprog)
p.As = AADD
p.From.Type = obj.TYPE_CONST
- p.From.Offset = obj.StackGuard
+ p.From.Offset = objabi.StackGuard
p.Reg = REGSP
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R4
@@ -916,7 +917,7 @@ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
p = obj.Appendp(p, c.newprog)
p.As = AMOVD
p.From.Type = obj.TYPE_CONST
- p.From.Offset = int64(framesize) + obj.StackGuard - obj.StackSmall
+ p.From.Offset = int64(framesize) + objabi.StackGuard - objabi.StackSmall
p.To.Type = obj.TYPE_REG
p.To.Reg = REGTMP
diff --git a/src/cmd/internal/obj/reloctype_string.go b/src/cmd/internal/obj/reloctype_string.go
deleted file mode 100644
index 09c1312df5..0000000000
--- a/src/cmd/internal/obj/reloctype_string.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// Code generated by "stringer -type=RelocType"; DO NOT EDIT
-
-package obj
-
-import "fmt"
-
-const _RelocType_name = "R_ADDRR_ADDRPOWERR_ADDRARM64R_ADDRMIPSR_ADDROFFR_WEAKADDROFFR_SIZER_CALLR_CALLARMR_CALLARM64R_CALLINDR_CALLPOWERR_CALLMIPSR_CONSTR_PCRELR_TLS_LER_TLS_IER_GOTOFFR_PLT0R_PLT1R_PLT2R_USEFIELDR_USETYPER_METHODOFFR_POWER_TOCR_GOTPCRELR_JMPMIPSR_DWARFREFR_ARM64_TLS_LER_ARM64_TLS_IER_ARM64_GOTPCRELR_POWER_TLS_LER_POWER_TLS_IER_POWER_TLSR_ADDRPOWER_DSR_ADDRPOWER_GOTR_ADDRPOWER_PCRELR_ADDRPOWER_TOCRELR_ADDRPOWER_TOCREL_DSR_PCRELDBLR_ADDRMIPSUR_ADDRMIPSTLS"
-
-var _RelocType_index = [...]uint16{0, 6, 17, 28, 38, 47, 60, 66, 72, 81, 92, 101, 112, 122, 129, 136, 144, 152, 160, 166, 172, 178, 188, 197, 208, 219, 229, 238, 248, 262, 276, 292, 306, 320, 331, 345, 360, 377, 395, 416, 426, 437, 450}
-
-func (i RelocType) String() string {
- i -= 1
- if i < 0 || i >= RelocType(len(_RelocType_index)-1) {
- return fmt.Sprintf("RelocType(%d)", i+1)
- }
- return _RelocType_name[_RelocType_index[i]:_RelocType_index[i+1]]
-}
diff --git a/src/cmd/internal/obj/s390x/asmz.go b/src/cmd/internal/obj/s390x/asmz.go
index d2b58d616c..7b25b88fa8 100644
--- a/src/cmd/internal/obj/s390x/asmz.go
+++ b/src/cmd/internal/obj/s390x/asmz.go
@@ -31,6 +31,7 @@ package s390x
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"log"
"math"
"sort"
@@ -487,7 +488,7 @@ func (c *ctxtz) aclass(a *obj.Addr) int {
break
}
c.instoffset = a.Offset
- if a.Sym.Type == obj.STLSBSS {
+ if a.Sym.Type == objabi.STLSBSS {
if c.ctxt.Flag_shared {
return C_TLS_IE // initial exec model
}
@@ -557,7 +558,7 @@ func (c *ctxtz) aclass(a *obj.Addr) int {
break
}
c.instoffset = a.Offset
- if s.Type == obj.SCONST {
+ if s.Type == objabi.SCONST {
goto consize
}
@@ -2508,7 +2509,7 @@ func (c *ctxtz) addrilreloc(sym *obj.LSym, add int64) *obj.Reloc {
rel.Siz = 4
rel.Sym = sym
rel.Add = add + offset + int64(rel.Siz)
- rel.Type = obj.R_PCRELDBL
+ rel.Type = objabi.R_PCRELDBL
return rel
}
@@ -2522,7 +2523,7 @@ func (c *ctxtz) addrilrelocoffset(sym *obj.LSym, add, offset int64) *obj.Reloc {
rel.Siz = 4
rel.Sym = sym
rel.Add = add + offset + int64(rel.Siz)
- rel.Type = obj.R_PCRELDBL
+ rel.Type = objabi.R_PCRELDBL
return rel
}
@@ -2538,7 +2539,7 @@ func (c *ctxtz) addcallreloc(sym *obj.LSym, add int64) *obj.Reloc {
rel.Siz = 4
rel.Sym = sym
rel.Add = add + offset + int64(rel.Siz)
- rel.Type = obj.R_CALL
+ rel.Type = objabi.R_CALL
return rel
}
@@ -3716,7 +3717,7 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
rel.Off = int32(c.pc + 2)
rel.Siz = 4
rel.Sym = p.From.Sym
- rel.Type = obj.R_GOTPCREL
+ rel.Type = objabi.R_GOTPCREL
rel.Add = 2 + int64(rel.Siz)
case 94: // TLS local exec model
@@ -3728,7 +3729,7 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
rel.Off = int32(c.pc + sizeRIL + sizeRXY + sizeRI)
rel.Siz = 8
rel.Sym = p.From.Sym
- rel.Type = obj.R_TLS_LE
+ rel.Type = objabi.R_TLS_LE
rel.Add = 0
case 95: // TLS initial exec model
@@ -3748,7 +3749,7 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
ieent.Off = int32(c.pc + 2)
ieent.Siz = 4
ieent.Sym = p.From.Sym
- ieent.Type = obj.R_TLS_IE
+ ieent.Type = objabi.R_TLS_IE
ieent.Add = 2 + int64(ieent.Siz)
// R_390_TLS_LOAD
diff --git a/src/cmd/internal/obj/s390x/objz.go b/src/cmd/internal/obj/s390x/objz.go
index e716eb00b1..80aee60fd2 100644
--- a/src/cmd/internal/obj/s390x/objz.go
+++ b/src/cmd/internal/obj/s390x/objz.go
@@ -31,6 +31,7 @@ package s390x
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/sys"
"math"
)
@@ -159,7 +160,7 @@ func (c *ctxtz) rewriteToUseGot(p *obj.Prog) {
if p.As == obj.ATEXT || p.As == obj.AFUNCDATA || p.As == obj.ACALL || p.As == obj.ARET || p.As == obj.AJMP {
return
}
- if source.Sym.Type == obj.STLSBSS {
+ if source.Sym.Type == objabi.STLSBSS {
return
}
if source.Type != obj.TYPE_MEM {
@@ -302,7 +303,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
autosize += int32(c.ctxt.FixedFrameSize())
}
- if p.Mark&LEAF != 0 && autosize < obj.StackSmall {
+ if p.Mark&LEAF != 0 && autosize < objabi.StackSmall {
// A leaf function with a small stack can be marked
// NOSPLIT, avoiding a stack check.
p.From.Sym.Set(obj.AttrNoSplit, true)
@@ -537,7 +538,7 @@ func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Pro
p.To.Reg = REG_R3
q = nil
- if framesize <= obj.StackSmall {
+ if framesize <= objabi.StackSmall {
// small stack: SP < stackguard
// CMP stackguard, SP
@@ -565,7 +566,7 @@ func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Pro
//p.As = ABGE
//p.To.Type = obj.TYPE_BRANCH
- } else if framesize <= obj.StackBig {
+ } else if framesize <= objabi.StackBig {
// large stack: SP-framesize < stackguard-StackSmall
// ADD $-(framesize-StackSmall), SP, R4
// CMP stackguard, R4
@@ -573,7 +574,7 @@ func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Pro
p.As = AADD
p.From.Type = obj.TYPE_CONST
- p.From.Offset = -(int64(framesize) - obj.StackSmall)
+ p.From.Offset = -(int64(framesize) - objabi.StackSmall)
p.Reg = REGSP
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R4
@@ -607,7 +608,7 @@ func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Pro
p.From.Type = obj.TYPE_REG
p.From.Reg = REG_R3
p.To.Type = obj.TYPE_CONST
- p.To.Offset = obj.StackPreempt
+ p.To.Offset = objabi.StackPreempt
p = obj.Appendp(p, c.newprog)
q = p
@@ -617,7 +618,7 @@ func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Pro
p = obj.Appendp(p, c.newprog)
p.As = AADD
p.From.Type = obj.TYPE_CONST
- p.From.Offset = obj.StackGuard
+ p.From.Offset = objabi.StackGuard
p.Reg = REGSP
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_R4
@@ -632,7 +633,7 @@ func (c *ctxtz) stacksplitPre(p *obj.Prog, framesize int32) (*obj.Prog, *obj.Pro
p = obj.Appendp(p, c.newprog)
p.As = AMOVD
p.From.Type = obj.TYPE_CONST
- p.From.Offset = int64(framesize) + obj.StackGuard - obj.StackSmall
+ p.From.Offset = int64(framesize) + objabi.StackGuard - objabi.StackSmall
p.To.Type = obj.TYPE_REG
p.To.Reg = REGTMP
@@ -659,7 +660,7 @@ func (c *ctxtz) stacksplitPost(p *obj.Prog, pPre *obj.Prog, pPreempt *obj.Prog,
pcdata.Pos = c.cursym.Func.Text.Pos
pcdata.As = obj.APCDATA
pcdata.From.Type = obj.TYPE_CONST
- pcdata.From.Offset = obj.PCDATA_StackMapIndex
+ pcdata.From.Offset = objabi.PCDATA_StackMapIndex
pcdata.To.Type = obj.TYPE_CONST
pcdata.To.Offset = -1 // pcdata starts at -1 at function entry
diff --git a/src/cmd/internal/obj/stack.go b/src/cmd/internal/obj/stack.go
deleted file mode 100644
index 687adf20f3..0000000000
--- a/src/cmd/internal/obj/stack.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2011 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 obj
-
-// For the linkers. Must match Go definitions.
-// TODO(rsc): Share Go definitions with linkers directly.
-
-const (
- STACKSYSTEM = 0
- StackSystem = STACKSYSTEM
- StackBig = 4096
- StackGuard = 880*stackGuardMultiplier + StackSystem
- StackSmall = 128
- StackLimit = StackGuard - StackSystem - StackSmall
-)
-
-const (
- StackPreempt = -1314 // 0xfff...fade
-)
diff --git a/src/cmd/internal/obj/sym.go b/src/cmd/internal/obj/sym.go
index bb844cdb0d..ec50aad7bf 100644
--- a/src/cmd/internal/obj/sym.go
+++ b/src/cmd/internal/obj/sym.go
@@ -32,38 +32,25 @@
package obj
import (
+ "cmd/internal/objabi"
"fmt"
"log"
"math"
- "os"
- "path/filepath"
)
-// WorkingDir returns the current working directory
-// (or "/???" if the directory cannot be identified),
-// with "/" as separator.
-func WorkingDir() string {
- var path string
- path, _ = os.Getwd()
- if path == "" {
- path = "/???"
- }
- return filepath.ToSlash(path)
-}
-
func Linknew(arch *LinkArch) *Link {
ctxt := new(Link)
ctxt.hash = make(map[SymVer]*LSym)
ctxt.Arch = arch
- ctxt.Pathname = WorkingDir()
+ ctxt.Pathname = objabi.WorkingDir()
- ctxt.Headtype.Set(GOOS)
+ ctxt.Headtype.Set(objabi.GOOS)
if ctxt.Headtype < 0 {
- log.Fatalf("unknown goos %s", GOOS)
+ log.Fatalf("unknown goos %s", objabi.GOOS)
}
ctxt.Flag_optimize = true
- ctxt.Framepointer_enabled = Framepointer_enabled(GOOS, arch.Name)
+ ctxt.Framepointer_enabled = objabi.Framepointer_enabled(objabi.GOOS, arch.Name)
return ctxt
}
diff --git a/src/cmd/internal/obj/symkind_string.go b/src/cmd/internal/obj/symkind_string.go
deleted file mode 100644
index fef8c355e4..0000000000
--- a/src/cmd/internal/obj/symkind_string.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Code generated by "stringer -type=SymKind"; DO NOT EDIT
-
-package obj
-
-import "fmt"
-
-const _SymKind_name = "SxxxSTEXTSELFRXSECTSTYPESSTRINGSGOSTRINGSGOFUNCSGCBITSSRODATASFUNCTABSELFROSECTSMACHOPLTSTYPERELROSSTRINGRELROSGOSTRINGRELROSGOFUNCRELROSGCBITSRELROSRODATARELROSFUNCTABRELROSTYPELINKSITABLINKSSYMTABSPCLNTABSELFSECTSMACHOSMACHOGOTSWINDOWSSELFGOTSNOPTRDATASINITARRSDATASBSSSNOPTRBSSSTLSBSSSXREFSMACHOSYMSTRSMACHOSYMTABSMACHOINDIRECTPLTSMACHOINDIRECTGOTSFILESFILEPATHSCONSTSDYNIMPORTSHOSTOBJSDWARFSECTSDWARFINFO"
-
-var _SymKind_index = [...]uint16{0, 4, 9, 19, 24, 31, 40, 47, 54, 61, 69, 79, 88, 98, 110, 124, 136, 148, 160, 173, 182, 191, 198, 206, 214, 220, 229, 237, 244, 254, 262, 267, 271, 280, 287, 292, 304, 316, 333, 350, 355, 364, 370, 380, 388, 398, 408}
-
-func (i SymKind) String() string {
- if i < 0 || i >= SymKind(len(_SymKind_index)-1) {
- return fmt.Sprintf("SymKind(%d)", i)
- }
- return _SymKind_name[_SymKind_index[i]:_SymKind_index[i+1]]
-}
diff --git a/src/cmd/internal/obj/typekind.go b/src/cmd/internal/obj/typekind.go
deleted file mode 100644
index 2193271678..0000000000
--- a/src/cmd/internal/obj/typekind.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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 obj
-
-// Must match runtime and reflect.
-// Included by cmd/gc.
-
-const (
- KindBool = 1 + iota
- KindInt
- KindInt8
- KindInt16
- KindInt32
- KindInt64
- KindUint
- KindUint8
- KindUint16
- KindUint32
- KindUint64
- KindUintptr
- KindFloat32
- KindFloat64
- KindComplex64
- KindComplex128
- KindArray
- KindChan
- KindFunc
- KindInterface
- KindMap
- KindPtr
- KindSlice
- KindString
- KindStruct
- KindUnsafePointer
- KindDirectIface = 1 << 5
- KindGCProg = 1 << 6
- KindNoPointers = 1 << 7
- KindMask = (1 << 5) - 1
-)
diff --git a/src/cmd/internal/obj/util.go b/src/cmd/internal/obj/util.go
index e800ea6efb..2e3ba15542 100644
--- a/src/cmd/internal/obj/util.go
+++ b/src/cmd/internal/obj/util.go
@@ -6,58 +6,13 @@ package obj
import (
"bytes"
+ "cmd/internal/objabi"
"fmt"
- "log"
- "os"
"strings"
- "time"
)
const REG_NONE = 0
-var start time.Time
-
-func Cputime() float64 {
- if start.IsZero() {
- start = time.Now()
- }
- return time.Since(start).Seconds()
-}
-
-func envOr(key, value string) string {
- if x := os.Getenv(key); x != "" {
- return x
- }
- return value
-}
-
-var (
- GOROOT = envOr("GOROOT", defaultGOROOT)
- GOARCH = envOr("GOARCH", defaultGOARCH)
- GOOS = envOr("GOOS", defaultGOOS)
- GO386 = envOr("GO386", defaultGO386)
- GOARM = goarm()
- Version = version
-)
-
-func goarm() int {
- switch v := envOr("GOARM", defaultGOARM); v {
- case "5":
- return 5
- case "6":
- return 6
- case "7":
- return 7
- }
- // Fail here, rather than validate at multiple call sites.
- log.Fatalf("Invalid GOARM value. Must be 5, 6, or 7.")
- panic("unreachable")
-}
-
-func Getgoextlinkenabled() string {
- return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
-}
-
func (p *Prog) Line() string {
return p.Ctxt.OutermostPos(p.Pos).Format(false)
}
@@ -240,7 +195,7 @@ func Dconv(p *Prog, a *Addr) string {
}
case TYPE_TEXTSIZE:
- if a.Val.(int32) == ArgsSizeUnknown {
+ if a.Val.(int32) == objabi.ArgsSizeUnknown {
str = fmt.Sprintf("$%d", a.Offset)
} else {
str = fmt.Sprintf("$%d-%d", a.Offset, a.Val.(int32))
@@ -263,7 +218,7 @@ func Dconv(p *Prog, a *Addr) string {
case TYPE_SHIFT:
v := int(a.Offset)
ops := "<<>>->@>"
- switch GOARCH {
+ switch objabi.GOARCH {
case "arm":
op := ops[((v>>5)&3)<<1:]
if v&(1<<4) != 0 {
@@ -278,7 +233,7 @@ func Dconv(p *Prog, a *Addr) string {
op := ops[((v>>22)&3)<<1:]
str = fmt.Sprintf("R%d%c%c%d", (v>>16)&31, op[0], op[1], (v>>10)&63)
default:
- panic("TYPE_SHIFT is not supported on " + GOARCH)
+ panic("TYPE_SHIFT is not supported on " + objabi.GOARCH)
}
case TYPE_REGREG:
diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go
index 8902725471..cee1a6516d 100644
--- a/src/cmd/internal/obj/x86/asm6.go
+++ b/src/cmd/internal/obj/x86/asm6.go
@@ -32,6 +32,7 @@ package x86
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/sys"
"encoding/binary"
"fmt"
@@ -1844,7 +1845,7 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
s.P = s.P[:0]
c = 0
for p := s.Func.Text; p != nil; p = p.Link {
- if ctxt.Headtype == obj.Hnacl && p.Isize > 0 {
+ if ctxt.Headtype == objabi.Hnacl && p.Isize > 0 {
// pad everything to avoid crossing 32-byte boundary
if c>>5 != (c+int32(p.Isize)-1)>>5 {
@@ -1939,7 +1940,7 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
}
}
- if ctxt.Headtype == obj.Hnacl {
+ if ctxt.Headtype == objabi.Hnacl {
c = naclpad(ctxt, s, c, -c&31)
}
@@ -1975,9 +1976,9 @@ func instinit(ctxt *obj.Link) {
}
switch ctxt.Headtype {
- case obj.Hplan9:
+ case objabi.Hplan9:
plan9privates = ctxt.Lookup("_privates", 0)
- case obj.Hnacl:
+ case objabi.Hnacl:
deferreturn = ctxt.Lookup("runtime.deferreturn", 0)
}
@@ -2121,7 +2122,7 @@ func instinit(ctxt *obj.Link) {
}
}
-var isAndroid = (obj.GOOS == "android")
+var isAndroid = (objabi.GOOS == "android")
func prefixof(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
if a.Reg < REG_CS && a.Index < REG_CS { // fast path
@@ -2159,11 +2160,11 @@ func prefixof(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
}
log.Fatalf("unknown TLS base register for %v", ctxt.Headtype)
- case obj.Hdarwin,
- obj.Hdragonfly,
- obj.Hfreebsd,
- obj.Hnetbsd,
- obj.Hopenbsd:
+ case objabi.Hdarwin,
+ objabi.Hdragonfly,
+ objabi.Hfreebsd,
+ objabi.Hnetbsd,
+ objabi.Hopenbsd:
return 0x65 // GS
}
}
@@ -2172,7 +2173,7 @@ func prefixof(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
default:
log.Fatalf("unknown TLS base register for %v", ctxt.Headtype)
- case obj.Hlinux:
+ case objabi.Hlinux:
if isAndroid {
return 0x64 // FS
}
@@ -2183,14 +2184,14 @@ func prefixof(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
return 0x64 // FS
}
- case obj.Hdragonfly,
- obj.Hfreebsd,
- obj.Hnetbsd,
- obj.Hopenbsd,
- obj.Hsolaris:
+ case objabi.Hdragonfly,
+ objabi.Hfreebsd,
+ objabi.Hnetbsd,
+ objabi.Hopenbsd,
+ objabi.Hsolaris:
return 0x64 // FS
- case obj.Hdarwin:
+ case objabi.Hdarwin:
return 0x65 // GS
}
}
@@ -2800,13 +2801,13 @@ func vaddr(ctxt *obj.Link, p *obj.Prog, a *obj.Addr, r *obj.Reloc) int64 {
if a.Name == obj.NAME_GOTREF {
r.Siz = 4
- r.Type = obj.R_GOTPCREL
+ r.Type = objabi.R_GOTPCREL
} else if isextern(s) || (ctxt.Arch.Family != sys.AMD64 && !ctxt.Flag_shared) {
r.Siz = 4
- r.Type = obj.R_ADDR
+ r.Type = objabi.R_ADDR
} else {
r.Siz = 4
- r.Type = obj.R_PCREL
+ r.Type = objabi.R_PCREL
}
r.Off = -1 // caller must fill in
@@ -2822,8 +2823,8 @@ func vaddr(ctxt *obj.Link, p *obj.Prog, a *obj.Addr, r *obj.Reloc) int64 {
log.Fatalf("reloc")
}
- if !ctxt.Flag_shared || isAndroid || ctxt.Headtype == obj.Hdarwin {
- r.Type = obj.R_TLS_LE
+ if !ctxt.Flag_shared || isAndroid || ctxt.Headtype == objabi.Hdarwin {
+ r.Type = objabi.R_TLS_LE
r.Siz = 4
r.Off = -1 // caller must fill in
r.Add = a.Offset
@@ -2992,7 +2993,7 @@ func (asmbuf *AsmBuf) asmandsz(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, a
if REG_AX <= base && base <= REG_R15 {
if a.Index == REG_TLS && !ctxt.Flag_shared {
rel = obj.Reloc{}
- rel.Type = obj.R_TLS_LE
+ rel.Type = objabi.R_TLS_LE
rel.Siz = 4
rel.Sym = nil
rel.Add = int64(v)
@@ -3625,7 +3626,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
case Zcallindreg:
r = obj.Addrel(cursym)
r.Off = int32(p.Pc)
- r.Type = obj.R_CALLIND
+ r.Type = objabi.R_CALLIND
r.Siz = 0
fallthrough
@@ -3786,7 +3787,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
}
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(asmbuf.Len()))
- r.Type = obj.R_PCREL
+ r.Type = objabi.R_PCREL
r.Siz = 4
r.Add = p.To.Offset
asmbuf.PutInt32(0)
@@ -3796,9 +3797,9 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(asmbuf.Len()))
if ctxt.Arch.Family == sys.AMD64 {
- r.Type = obj.R_PCREL
+ r.Type = objabi.R_PCREL
} else {
- r.Type = obj.R_ADDR
+ r.Type = objabi.R_ADDR
}
r.Siz = 4
r.Add = p.To.Offset
@@ -3830,7 +3831,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
r.Off = int32(p.Pc + int64(asmbuf.Len()))
r.Sym = p.To.Sym
r.Add = p.To.Offset
- r.Type = obj.R_CALL
+ r.Type = objabi.R_CALL
r.Siz = 4
asmbuf.PutInt32(0)
@@ -3855,7 +3856,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(asmbuf.Len()))
r.Sym = p.To.Sym
- r.Type = obj.R_PCREL
+ r.Type = objabi.R_PCREL
r.Siz = 4
asmbuf.PutInt32(0)
break
@@ -4072,8 +4073,8 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
default:
log.Fatalf("unknown TLS base location for %v", ctxt.Headtype)
- case obj.Hlinux,
- obj.Hnacl:
+ case objabi.Hlinux,
+ objabi.Hnacl:
if ctxt.Flag_shared {
// Note that this is not generating the same insns as the other cases.
// MOV TLS, dst
@@ -4090,7 +4091,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
asmbuf.Put1(0xe8)
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(asmbuf.Len()))
- r.Type = obj.R_CALL
+ r.Type = objabi.R_CALL
r.Siz = 4
r.Sym = ctxt.Lookup("__x86.get_pc_thunk."+strings.ToLower(rconv(int(dst))), 0)
asmbuf.PutInt32(0)
@@ -4098,7 +4099,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
asmbuf.Put2(0x8B, byte(2<<6|reg[dst]|(reg[dst]<<3)))
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(asmbuf.Len()))
- r.Type = obj.R_TLS_IE
+ r.Type = objabi.R_TLS_IE
r.Siz = 4
r.Add = 2
asmbuf.PutInt32(0)
@@ -4115,7 +4116,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
0x8B)
asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To)
}
- case obj.Hplan9:
+ case objabi.Hplan9:
pp.From = obj.Addr{}
pp.From.Type = obj.TYPE_MEM
pp.From.Name = obj.NAME_EXTERN
@@ -4125,7 +4126,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
asmbuf.Put1(0x8B)
asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To)
- case obj.Hwindows:
+ case objabi.Hwindows:
// Windows TLS base is always 0x14(FS).
pp.From = p.From
@@ -4145,7 +4146,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
default:
log.Fatalf("unknown TLS base location for %v", ctxt.Headtype)
- case obj.Hlinux:
+ case objabi.Hlinux:
if !ctxt.Flag_shared {
log.Fatalf("unknown TLS base location for linux without -shared")
}
@@ -4163,12 +4164,12 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
asmbuf.Put2(0x8B, byte(0x05|(reg[p.To.Reg]<<3)))
r = obj.Addrel(cursym)
r.Off = int32(p.Pc + int64(asmbuf.Len()))
- r.Type = obj.R_TLS_IE
+ r.Type = objabi.R_TLS_IE
r.Siz = 4
r.Add = -4
asmbuf.PutInt32(0)
- case obj.Hplan9:
+ case objabi.Hplan9:
pp.From = obj.Addr{}
pp.From.Type = obj.TYPE_MEM
pp.From.Name = obj.NAME_EXTERN
@@ -4179,7 +4180,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
asmbuf.Put1(0x8B)
asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To)
- case obj.Hsolaris: // TODO(rsc): Delete Hsolaris from list. Should not use this code. See progedit in obj6.c.
+ case objabi.Hsolaris: // TODO(rsc): Delete Hsolaris from list. Should not use this code. See progedit in obj6.c.
// TLS base is 0(FS).
pp.From = p.From
@@ -4194,7 +4195,7 @@ func (asmbuf *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
0x8B)
asmbuf.asmand(ctxt, cursym, p, &pp.From, &p.To)
- case obj.Hwindows:
+ case objabi.Hwindows:
// Windows TLS base is always 0x28(GS).
pp.From = p.From
@@ -4434,7 +4435,7 @@ func (asmbuf *AsmBuf) nacltrunc(ctxt *obj.Link, reg int) {
func (asmbuf *AsmBuf) asmins(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
asmbuf.Reset()
- if ctxt.Headtype == obj.Hnacl && ctxt.Arch.Family == sys.I386 {
+ if ctxt.Headtype == objabi.Hnacl && ctxt.Arch.Family == sys.I386 {
switch p.As {
case obj.ARET:
asmbuf.Put(naclret8)
@@ -4452,7 +4453,7 @@ func (asmbuf *AsmBuf) asmins(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
}
}
- if ctxt.Headtype == obj.Hnacl && ctxt.Arch.Family == sys.AMD64 {
+ if ctxt.Headtype == objabi.Hnacl && ctxt.Arch.Family == sys.AMD64 {
if p.As == AREP {
asmbuf.rep++
return
@@ -4567,7 +4568,7 @@ func (asmbuf *AsmBuf) asmins(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
if asmbuf.rexflag != 0 {
r.Off++
}
- if r.Type == obj.R_PCREL {
+ if r.Type == objabi.R_PCREL {
if ctxt.Arch.Family == sys.AMD64 || p.As == obj.AJMP || p.As == obj.ACALL {
// PC-relative addressing is relative to the end of the instruction,
// but the relocations applied by the linker are relative to the end
@@ -4585,14 +4586,14 @@ func (asmbuf *AsmBuf) asmins(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
r.Add += int64(r.Off) - p.Pc + int64(r.Siz)
}
}
- if r.Type == obj.R_GOTPCREL && ctxt.Arch.Family == sys.I386 {
+ if r.Type == objabi.R_GOTPCREL && ctxt.Arch.Family == sys.I386 {
// On 386, R_GOTPCREL makes the same assumptions as R_PCREL.
r.Add += int64(r.Off) - p.Pc + int64(r.Siz)
}
}
- if ctxt.Arch.Family == sys.AMD64 && ctxt.Headtype == obj.Hnacl && p.As != ACMPL && p.As != ACMPQ && p.To.Type == obj.TYPE_REG {
+ if ctxt.Arch.Family == sys.AMD64 && ctxt.Headtype == objabi.Hnacl && p.As != ACMPL && p.As != ACMPQ && p.To.Type == obj.TYPE_REG {
switch p.To.Reg {
case REG_SP:
asmbuf.Put(naclspfix)
diff --git a/src/cmd/internal/obj/x86/obj6.go b/src/cmd/internal/obj/x86/obj6.go
index 172a3cb4b5..c25352d0bc 100644
--- a/src/cmd/internal/obj/x86/obj6.go
+++ b/src/cmd/internal/obj/x86/obj6.go
@@ -32,6 +32,7 @@ package x86
import (
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/sys"
"math"
"strings"
@@ -50,10 +51,10 @@ func CanUse1InsnTLS(ctxt *obj.Link) bool {
if ctxt.Arch.Family == sys.I386 {
switch ctxt.Headtype {
- case obj.Hlinux,
- obj.Hnacl,
- obj.Hplan9,
- obj.Hwindows:
+ case objabi.Hlinux,
+ objabi.Hnacl,
+ objabi.Hplan9,
+ objabi.Hwindows:
return false
}
@@ -61,9 +62,9 @@ func CanUse1InsnTLS(ctxt *obj.Link) bool {
}
switch ctxt.Headtype {
- case obj.Hplan9, obj.Hwindows:
+ case objabi.Hplan9, objabi.Hwindows:
return false
- case obj.Hlinux:
+ case objabi.Hlinux:
return !ctxt.Flag_shared
}
@@ -123,7 +124,7 @@ func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
// TODO(rsc): Remove the Hsolaris special case. It exists only to
// guarantee we are producing byte-identical binaries as before this code.
// But it should be unnecessary.
- if (p.As == AMOVQ || p.As == AMOVL) && p.From.Type == obj.TYPE_REG && p.From.Reg == REG_TLS && p.To.Type == obj.TYPE_REG && REG_AX <= p.To.Reg && p.To.Reg <= REG_R15 && ctxt.Headtype != obj.Hsolaris {
+ if (p.As == AMOVQ || p.As == AMOVL) && p.From.Type == obj.TYPE_REG && p.From.Reg == REG_TLS && p.To.Type == obj.TYPE_REG && REG_AX <= p.To.Reg && p.To.Reg <= REG_R15 && ctxt.Headtype != objabi.Hsolaris {
obj.Nopout(p)
}
if p.From.Type == obj.TYPE_MEM && p.From.Index == REG_TLS && REG_AX <= p.From.Reg && p.From.Reg <= REG_R15 {
@@ -161,7 +162,7 @@ func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
}
// TODO: Remove.
- if ctxt.Headtype == obj.Hwindows && ctxt.Arch.Family == sys.AMD64 || ctxt.Headtype == obj.Hplan9 {
+ if ctxt.Headtype == objabi.Hwindows && ctxt.Arch.Family == sys.AMD64 || ctxt.Headtype == objabi.Hplan9 {
if p.From.Scale == 1 && p.From.Index == REG_TLS {
p.From.Scale = 2
}
@@ -199,7 +200,7 @@ func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
}
}
- if ctxt.Headtype == obj.Hnacl && ctxt.Arch.Family == sys.AMD64 {
+ if ctxt.Headtype == objabi.Hnacl && ctxt.Arch.Family == sys.AMD64 {
if p.From3 != nil {
nacladdr(ctxt, p, p.From3)
}
@@ -496,7 +497,7 @@ func rewriteToPcrel(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
if a.Sym == nil || (a.Type != obj.TYPE_MEM && a.Type != obj.TYPE_ADDR) || a.Reg != 0 {
return false
}
- if a.Sym.Type == obj.STLSBSS {
+ if a.Sym.Type == objabi.STLSBSS {
return false
}
return a.Name == obj.NAME_EXTERN || a.Name == obj.NAME_STATIC || a.Name == obj.NAME_GOTREF
@@ -637,7 +638,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
}
// TODO(rsc): Remove 'ctxt.Arch.Family == sys.AMD64 &&'.
- if ctxt.Arch.Family == sys.AMD64 && autoffset < obj.StackSmall && !p.From.Sym.NoSplit() {
+ if ctxt.Arch.Family == sys.AMD64 && autoffset < objabi.StackSmall && !p.From.Sym.NoSplit() {
leaf := true
LeafSearch:
for q := p; q != nil; q = q.Link {
@@ -651,7 +652,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
}
fallthrough
case obj.ADUFFCOPY, obj.ADUFFZERO:
- if autoffset >= obj.StackSmall-8 {
+ if autoffset >= objabi.StackSmall-8 {
leaf = false
break LeafSearch
}
@@ -741,7 +742,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
p.From.Offset = 4 * int64(ctxt.Arch.PtrSize) // g_panic
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_BX
- if ctxt.Headtype == obj.Hnacl && ctxt.Arch.Family == sys.AMD64 {
+ if ctxt.Headtype == objabi.Hnacl && ctxt.Arch.Family == sys.AMD64 {
p.As = AMOVL
p.From.Type = obj.TYPE_MEM
p.From.Reg = REG_R15
@@ -759,7 +760,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
p.From.Reg = REG_BX
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_BX
- if ctxt.Headtype == obj.Hnacl || ctxt.Arch.Family == sys.I386 {
+ if ctxt.Headtype == objabi.Hnacl || ctxt.Arch.Family == sys.I386 {
p.As = ATESTL
}
@@ -786,7 +787,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
p.From.Offset = int64(autoffset) + int64(ctxt.Arch.RegSize)
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_DI
- if ctxt.Headtype == obj.Hnacl || ctxt.Arch.Family == sys.I386 {
+ if ctxt.Headtype == objabi.Hnacl || ctxt.Arch.Family == sys.I386 {
p.As = ALEAL
}
@@ -801,7 +802,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
p.From.Offset = 0 // Panic.argp
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_DI
- if ctxt.Headtype == obj.Hnacl && ctxt.Arch.Family == sys.AMD64 {
+ if ctxt.Headtype == objabi.Hnacl && ctxt.Arch.Family == sys.AMD64 {
p.As = ACMPL
p.From.Type = obj.TYPE_MEM
p.From.Reg = REG_R15
@@ -826,7 +827,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
p.To.Type = obj.TYPE_MEM
p.To.Reg = REG_BX
p.To.Offset = 0 // Panic.argp
- if ctxt.Headtype == obj.Hnacl && ctxt.Arch.Family == sys.AMD64 {
+ if ctxt.Headtype == objabi.Hnacl && ctxt.Arch.Family == sys.AMD64 {
p.As = AMOVL
p.To.Type = obj.TYPE_MEM
p.To.Reg = REG_R15
@@ -958,7 +959,7 @@ func isZeroArgRuntimeCall(s *obj.LSym) bool {
}
func indir_cx(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
- if ctxt.Headtype == obj.Hnacl && ctxt.Arch.Family == sys.AMD64 {
+ if ctxt.Headtype == objabi.Hnacl && ctxt.Arch.Family == sys.AMD64 {
a.Type = obj.TYPE_MEM
a.Reg = REG_R15
a.Index = REG_CX
@@ -1009,7 +1010,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
mov := AMOVQ
sub := ASUBQ
- if ctxt.Headtype == obj.Hnacl || ctxt.Arch.Family == sys.I386 {
+ if ctxt.Headtype == objabi.Hnacl || ctxt.Arch.Family == sys.I386 {
cmp = ACMPL
lea = ALEAL
mov = AMOVL
@@ -1017,7 +1018,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
}
var q1 *obj.Prog
- if framesize <= obj.StackSmall {
+ if framesize <= objabi.StackSmall {
// small stack: SP <= stackguard
// CMPQ SP, stackguard
p = obj.Appendp(p, newprog)
@@ -1030,7 +1031,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
if cursym.CFunc() {
p.To.Offset = 3 * int64(ctxt.Arch.PtrSize) // G.stackguard1
}
- } else if framesize <= obj.StackBig {
+ } else if framesize <= objabi.StackBig {
// large stack: SP-framesize <= stackguard-StackSmall
// LEAQ -xxx(SP), AX
// CMPQ AX, stackguard
@@ -1039,7 +1040,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
p.As = lea
p.From.Type = obj.TYPE_MEM
p.From.Reg = REG_SP
- p.From.Offset = -(int64(framesize) - obj.StackSmall)
+ p.From.Offset = -(int64(framesize) - objabi.StackSmall)
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_AX
@@ -1084,9 +1085,9 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
p.From.Type = obj.TYPE_REG
p.From.Reg = REG_SI
p.To.Type = obj.TYPE_CONST
- p.To.Offset = obj.StackPreempt
+ p.To.Offset = objabi.StackPreempt
if ctxt.Arch.Family == sys.I386 {
- p.To.Offset = int64(uint32(obj.StackPreempt & (1<<32 - 1)))
+ p.To.Offset = int64(uint32(objabi.StackPreempt & (1<<32 - 1)))
}
p = obj.Appendp(p, newprog)
@@ -1098,7 +1099,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
p.As = lea
p.From.Type = obj.TYPE_MEM
p.From.Reg = REG_SP
- p.From.Offset = obj.StackGuard
+ p.From.Offset = objabi.StackGuard
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_AX
@@ -1114,7 +1115,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
p.From.Type = obj.TYPE_REG
p.From.Reg = REG_AX
p.To.Type = obj.TYPE_CONST
- p.To.Offset = int64(framesize) + (obj.StackGuard - obj.StackSmall)
+ p.To.Offset = int64(framesize) + (objabi.StackGuard - objabi.StackSmall)
}
// common
@@ -1137,7 +1138,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
pcdata.Pos = cursym.Func.Text.Pos
pcdata.As = obj.APCDATA
pcdata.From.Type = obj.TYPE_CONST
- pcdata.From.Offset = obj.PCDATA_StackMapIndex
+ pcdata.From.Offset = objabi.PCDATA_StackMapIndex
pcdata.To.Type = obj.TYPE_CONST
pcdata.To.Offset = -1 // pcdata starts at -1 at function entry