mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/obj: manual C->Go cleanups
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>
This commit is contained in:
parent
3f4de49d0a
commit
a13cf8c104
6 changed files with 24 additions and 58 deletions
|
|
@ -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
|
package obj
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AEXIST = 0
|
AEXIST = 0
|
||||||
|
BOM = 0xFEFF
|
||||||
)
|
)
|
||||||
|
|
||||||
var GOEXPERIMENT string
|
var GOEXPERIMENT string
|
||||||
|
|
||||||
const (
|
|
||||||
OREAD = iota
|
|
||||||
OWRITE
|
|
||||||
ORDWR
|
|
||||||
SIGBUS
|
|
||||||
SIGSEGV
|
|
||||||
NDFLT
|
|
||||||
FPPDBL
|
|
||||||
FPRNR
|
|
||||||
HEADER_IO
|
|
||||||
BOM = 0xFEFF
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -481,7 +481,7 @@ type Link struct {
|
||||||
|
|
||||||
type SymVer struct {
|
type SymVer struct {
|
||||||
Name string
|
Name string
|
||||||
Version int
|
Version int // TODO: make int16 to match LSym.Version?
|
||||||
}
|
}
|
||||||
|
|
||||||
// LinkArch is the definition of a single architecture.
|
// LinkArch is the definition of a single architecture.
|
||||||
|
|
@ -527,13 +527,11 @@ type Plist struct {
|
||||||
*/
|
*/
|
||||||
func Linknewplist(ctxt *Link) *Plist {
|
func Linknewplist(ctxt *Link) *Plist {
|
||||||
pl := new(Plist)
|
pl := new(Plist)
|
||||||
*pl = Plist{}
|
|
||||||
if ctxt.Plist == nil {
|
if ctxt.Plist == nil {
|
||||||
ctxt.Plist = pl
|
ctxt.Plist = pl
|
||||||
} else {
|
} else {
|
||||||
ctxt.Plast.Link = pl
|
ctxt.Plast.Link = pl
|
||||||
}
|
}
|
||||||
ctxt.Plast = pl
|
ctxt.Plast = pl
|
||||||
|
|
||||||
return pl
|
return pl
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -514,7 +514,3 @@ func wrsym(b *Biobuf, s *LSym) {
|
||||||
wrstring(b, s.Name)
|
wrstring(b, s.Name)
|
||||||
wrint(b, int64(s.Version))
|
wrint(b, int64(s.Version))
|
||||||
}
|
}
|
||||||
|
|
||||||
var startmagic string = "\x00\x00go13ld"
|
|
||||||
|
|
||||||
var endmagic string = "\xff\xffgo13ld"
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
// Inferno utils/5l/span.c
|
||||||
// http://code.google.com/p/inferno-os/source/browse/utils/5l/span.c
|
// http://code.google.com/p/inferno-os/source/browse/utils/5l/span.c
|
||||||
//
|
//
|
||||||
|
|
@ -30,12 +34,6 @@
|
||||||
|
|
||||||
package obj
|
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.
|
// For the linkers. Must match Go definitions.
|
||||||
// TODO(rsc): Share Go definitions with linkers directly.
|
// TODO(rsc): Share Go definitions with linkers directly.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,17 +32,13 @@
|
||||||
package obj
|
package obj
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func yy_isalpha(c int) bool {
|
|
||||||
return 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z'
|
|
||||||
}
|
|
||||||
|
|
||||||
var headers = []struct {
|
var headers = []struct {
|
||||||
name string
|
name string
|
||||||
val int
|
val int
|
||||||
|
|
@ -71,16 +67,13 @@ func headtype(name string) int {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
var headstr_buf string
|
|
||||||
|
|
||||||
func Headstr(v int) string {
|
func Headstr(v int) string {
|
||||||
for i := 0; i < len(headers); i++ {
|
for i := 0; i < len(headers); i++ {
|
||||||
if v == headers[i].val {
|
if v == headers[i].val {
|
||||||
return headers[i].name
|
return headers[i].name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
headstr_buf = fmt.Sprintf("%d", v)
|
return strconv.Itoa(v)
|
||||||
return headstr_buf
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Linknew(arch *LinkArch) *Link {
|
func Linknew(arch *LinkArch) *Link {
|
||||||
|
|
@ -185,38 +178,31 @@ func Linknew(arch *LinkArch) *Link {
|
||||||
return ctxt
|
return ctxt
|
||||||
}
|
}
|
||||||
|
|
||||||
func linknewsym(ctxt *Link, symb string, v int) *LSym {
|
func _lookup(ctxt *Link, symb string, v int, create bool) *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 {
|
|
||||||
s := ctxt.Hash[SymVer{symb, v}]
|
s := ctxt.Hash[SymVer{symb, v}]
|
||||||
if s != nil || creat == 0 {
|
if s != nil || !create {
|
||||||
return s
|
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
|
ctxt.Hash[SymVer{symb, v}] = s
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func Linklookup(ctxt *Link, name string, v int) *LSym {
|
func Linklookup(ctxt *Link, name string, v int) *LSym {
|
||||||
return _lookup(ctxt, name, v, 1)
|
return _lookup(ctxt, name, v, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// read-only lookup
|
// read-only lookup
|
||||||
func linkrlookup(ctxt *Link, name string, v int) *LSym {
|
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 {
|
func Linksymfmt(s *LSym) string {
|
||||||
|
|
|
||||||
|
|
@ -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
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package obj
|
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.
|
// Must match runtime and reflect.
|
||||||
// Included by cmd/gc.
|
// Included by cmd/gc.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue