]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: manual C->Go cleanups
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 20 Apr 2015 04:00:48 +0000 (21:00 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 20 Apr 2015 16:54:22 +0000 (16:54 +0000)
Change-Id: I5964fc55157dc1df7be400dfa0df591d6163e25e
Reviewed-on: https://go-review.googlesource.com/9084
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>

src/cmd/internal/obj/libc.go
src/cmd/internal/obj/link.go
src/cmd/internal/obj/objfile.go
src/cmd/internal/obj/stack.go
src/cmd/internal/obj/sym.go
src/cmd/internal/obj/typekind.go

index 204839e8af817c56eaf33fd19230b911ca555c14..b200b2604700449230c9af080f9e4905aa8ce734 100644 (file)
@@ -1,20 +1,12 @@
+// 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
-
-const (
-       OREAD = iota
-       OWRITE
-       ORDWR
-       SIGBUS
-       SIGSEGV
-       NDFLT
-       FPPDBL
-       FPRNR
-       HEADER_IO
-       BOM = 0xFEFF
-)
index 7d4026c312c0576abf7e149747bf496282596025..c7c5abe00297cf5367c5412abb55508294261143 100644 (file)
@@ -481,7 +481,7 @@ type Link struct {
 
 type SymVer struct {
        Name    string
-       Version int
+       Version int // TODO: make int16 to match LSym.Version?
 }
 
 // LinkArch is the definition of a single architecture.
@@ -527,13 +527,11 @@ type Plist struct {
  */
 func Linknewplist(ctxt *Link) *Plist {
        pl := new(Plist)
-       *pl = Plist{}
        if ctxt.Plist == nil {
                ctxt.Plist = pl
        } else {
                ctxt.Plast.Link = pl
        }
        ctxt.Plast = pl
-
        return pl
 }
index 1f6857840dc5571e8a20d95684831efdcc4de911..c45ddd86cae2a59b0639257fa5e8a157233504c3 100644 (file)
@@ -514,7 +514,3 @@ func wrsym(b *Biobuf, s *LSym) {
        wrstring(b, s.Name)
        wrint(b, int64(s.Version))
 }
-
-var startmagic string = "\x00\x00go13ld"
-
-var endmagic string = "\xff\xffgo13ld"
index b8d0350d89fb3fd412ba608c1a0f5a921b2cbbe7..9324ef6d1bf1ac0bbc25e4d568772fd474d895b4 100644 (file)
@@ -1,3 +1,7 @@
+// 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.
+
 // Inferno utils/5l/span.c
 // http://code.google.com/p/inferno-os/source/browse/utils/5l/span.c
 //
 
 package obj
 
-// Instruction layout.
-
-// 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.
-
 // For the linkers. Must match Go definitions.
 // TODO(rsc): Share Go definitions with linkers directly.
 
index 046b0f19c28e752aba409a79ba607f98dde58898..37bb40b4add69e90341ca38ffaaba9313a3dac1c 100644 (file)
 package obj
 
 import (
-       "fmt"
        "log"
        "os"
        "path/filepath"
        "runtime"
+       "strconv"
 )
 
-func yy_isalpha(c int) bool {
-       return 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z'
-}
-
 var headers = []struct {
        name string
        val  int
@@ -71,16 +67,13 @@ func headtype(name string) int {
        return -1
 }
 
-var headstr_buf string
-
 func Headstr(v int) string {
        for i := 0; i < len(headers); i++ {
                if v == headers[i].val {
                        return headers[i].name
                }
        }
-       headstr_buf = fmt.Sprintf("%d", v)
-       return headstr_buf
+       return strconv.Itoa(v)
 }
 
 func Linknew(arch *LinkArch) *Link {
@@ -185,38 +178,31 @@ func Linknew(arch *LinkArch) *Link {
        return ctxt
 }
 
-func linknewsym(ctxt *Link, symb string, v int) *LSym {
-       s := new(LSym)
-       *s = LSym{}
-
-       s.Name = symb
-       s.Type = 0
-       s.Version = int16(v)
-       s.Value = 0
-       s.Size = 0
-
-       return s
-}
-
-func _lookup(ctxt *Link, symb string, v int, creat int) *LSym {
+func _lookup(ctxt *Link, symb string, v int, create bool) *LSym {
        s := ctxt.Hash[SymVer{symb, v}]
-       if s != nil || creat == 0 {
+       if s != nil || !create {
                return s
        }
 
-       s = linknewsym(ctxt, symb, v)
+       s = &LSym{
+               Name:    symb,
+               Type:    0,
+               Version: int16(v),
+               Value:   0,
+               Size:    0,
+       }
        ctxt.Hash[SymVer{symb, v}] = s
 
        return s
 }
 
 func Linklookup(ctxt *Link, name string, v int) *LSym {
-       return _lookup(ctxt, name, v, 1)
+       return _lookup(ctxt, name, v, true)
 }
 
 // read-only lookup
 func linkrlookup(ctxt *Link, name string, v int) *LSym {
-       return _lookup(ctxt, name, v, 0)
+       return _lookup(ctxt, name, v, false)
 }
 
 func Linksymfmt(s *LSym) string {
index f8e302bd329a45943f6348384ea57bf432ad516d..21932716786f846d427384495aad04fd17895bf9 100644 (file)
@@ -1,13 +1,9 @@
-// Copyright 2009 The Go Authors. All rights reserved.
+// 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
 
-// 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.
-
 // Must match runtime and reflect.
 // Included by cmd/gc.