dclcontext = PEXTERN
nerrors = 0
lexlineno = 1
+ const BOM = 0xFEFF
for _, infile = range flag.Args() {
linehistpush(infile)
curio.last = 0
// Skip initial BOM if present.
- if obj.Bgetrune(curio.bin) != obj.BOM {
+ if obj.Bgetrune(curio.bin) != BOM {
obj.Bungetrune(curio.bin)
}
// if there is an array.6 in the array.a library,
// want to find all of array.a, not just array.6.
file = fmt.Sprintf("%s.a", name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
file = fmt.Sprintf("%s.o", name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
return "", false
for p := idirs; p != nil; p = p.link {
file = fmt.Sprintf("%s/%s.a", p.dir, name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
file = fmt.Sprintf("%s/%s.o", p.dir, name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
}
}
file = fmt.Sprintf("%s/pkg/%s_%s%s%s/%s.a", goroot, goos, goarch, suffixsep, suffix, name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
file = fmt.Sprintf("%s/pkg/%s_%s%s%s/%s.o", goroot, goos, goarch, suffixsep, suffix, name)
- if obj.Access(file, 0) >= 0 {
+ if _, err := os.Stat(file); err == nil {
return file, true
}
}
const (
LFROM = 1 << 0
LTO = 1 << 1
- LPOOL = 1 << 2
)
var optab = []Optab{
return setaddrplus(ctxt, s, off, t, 0)
}
-func addsize(ctxt *Link, s *LSym, t *LSym) int64 {
- if s.Type == 0 {
- s.Type = SDATA
- }
- i := s.Size
- s.Size += int64(ctxt.Arch.Ptrsize)
- Symgrow(ctxt, s, s.Size)
- r := Addrel(s)
- r.Sym = t
- r.Off = int32(i)
- r.Siz = uint8(ctxt.Arch.Ptrsize)
- r.Type = R_SIZE
- return i + int64(r.Siz)
-}
-
func addaddrplus4(ctxt *Link, s *LSym, t *LSym, add int64) int64 {
if s.Type == 0 {
s.Type = SDATA
const (
FmtWidth = 1 << iota
FmtLeft
- FmtPrec
FmtSharp
- FmtSpace
FmtSign
- FmtApost
- FmtZero
FmtUnsigned
FmtShort
FmtLong
- FmtVLong
FmtComma
FmtByte
- FmtLDouble
- FmtFlag
)
PCDATA_StackMapIndex = 0
FUNCDATA_ArgsPointerMaps = 0
FUNCDATA_LocalsPointerMaps = 1
- FUNCDATA_DeadValueMaps = 2
ArgsSizeUnknown = -0x80000000
)
+++ /dev/null
-// 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
-
-const (
- AEXIST = 0
- BOM = 0xFEFF
-)
-
-var GOEXPERIMENT string
+++ /dev/null
-// 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
-
-// Garbage collector liveness bitmap generation.
-
-// The command line flag -live causes this code to print debug information.
-// The levels are:
-//
-// -live (aka -live=1): print liveness lists as code warnings at safe points
-// -live=2: print an assembly listing with liveness annotations
-// -live=3: print information during each computation phase (much chattier)
-//
-// Each level includes the earlier output as well.
-
-// 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.
-
-// Used by cmd/gc.
-
-const (
- InsData = 1 + iota
- InsArray
- InsArrayEnd
- InsEnd
- MaxGCMask = 65536
-)
"strings"
)
-var outfile string
-
// The Go and C compilers, and the assembler, call writeobj to write
// out a Go object file. The linker does not call this; the linker
// does not write out object files.
// On arm, record goarm.
if ctxt.Arch.Thechar == '5' {
- p := Getgoarm()
- if p != "" {
- ctxt.Goarm = int32(Atoi(p))
- } else {
- ctxt.Goarm = 6
- }
+ ctxt.Goarm = Getgoarm()
}
return ctxt
"io"
"log"
"os"
- "strconv"
"strings"
"time"
)
return s
}
-func Access(name string, mode int) int {
- if mode != 0 {
- panic("bad access")
- }
- _, err := os.Stat(name)
- if err != nil {
- return -1
- }
- return 0
-}
-
func Blinelen(b *Biobuf) int {
return b.linelen
}
return envOr("GOOS", defaultGOOS)
}
-func Getgoarm() string {
+func Getgoarm() int32 {
switch v := envOr("GOARM", defaultGOARM); v {
- case "5", "6", "7":
- return 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.")
return version
}
-func Atoi(s string) int {
- i, _ := strconv.Atoi(s)
- return i
-}
-
func (p *Prog) Line() string {
return p.Ctxt.LineHist.LineString(int(p.Lineno))
}
// Instruction layout.
const (
- MaxAlign = 32 // max data alignment
-
// Loop alignment constants:
// want to align loop entry to LoopAlign-byte boundary,
// and willing to insert at most MaxLoopPad bytes of NOP to do so.
Zil_rp
Ziq_rp
Zilo_m
- Ziqo_m
Zjmp
Zjmpcon
Zloop
Py1 = 0x81 // symbolic; exact value doesn't matter
Py3 = 0x83 // symbolic; exact value doesn't matter
- Rxf = 1 << 9 /* internal flag for Rxr on from */
- Rxt = 1 << 8 /* internal flag for Rxr on to */
Rxw = 1 << 3 /* =1, 64-bit operand size */
Rxr = 1 << 2 /* extend modrm reg */
Rxx = 1 << 1 /* extend sib index */
Rxb = 1 << 0 /* extend modrm r/m, sib base, or opcode reg */
-
- Maxand = 10 /* in -a output width of the byte codes */
)
var ycover [Ymax * Ymax]uint8
{Ynone, Ynone, Ynone, Zlit, 1},
}
-var ysahf = []ytab{
- {Ynone, Ynone, Ynone, Zlit, 2},
- {Ynone, Ynone, Ynone, Zlit, 1},
-}
-
var ytext = []ytab{
{Ymb, Ynone, Ytextsize, Zpseudo, 0},
{Ymb, Yi32, Ytextsize, Zpseudo, 1},
"fmt"
"log"
"sort"
+ "strconv"
"strings"
)
if peobj.sect[i].name[0] != '/' {
continue
}
- l = uint32(obj.Atoi(peobj.sect[i].name[1:]))
- peobj.sect[i].name = cstring(peobj.snames[l:])
+ n, _ := strconv.Atoi(peobj.sect[i].name[1:])
+ peobj.sect[i].name = cstring(peobj.snames[n:])
}
// read symbols
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "searching for %s.a in %s\n", name, shlibname)
}
- if obj.Access(shlibname, obj.AEXIST) >= 0 {
+ if _, err := os.Stat(shlibname); err == nil {
addlibpath(Ctxt, "internal", "internal", "", name, shlibname)
found = 1
break
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "searching for %s.a in %s\n", name, pname)
}
- if obj.Access(pname, obj.AEXIST) >= 0 {
+ if _, err := os.Stat(pname); err == nil {
addlibpath(Ctxt, "internal", "internal", pname, name, "")
found = 1
break
// On arm, record goarm.
if ctxt.Arch.Thechar == '5' {
- p := obj.Getgoarm()
- if p != "" {
- ctxt.Goarm = int32(obj.Atoi(p))
- } else {
- ctxt.Goarm = 6
- }
+ ctxt.Goarm = obj.Getgoarm()
}
return ctxt