mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd: simplify some handling of package paths
We have obj.Link.Pkgpath, so we don't need to pass it redundantly in places where we already have an *obj.Link. Also, renaming the parser's "compilingRuntime" field to "allowABI", to match the "AllowAsmABI" name used by objabi.LookupPkgSpecial. Finally, push the handling of GOEXPERIMENT_* flags up to cmd/asm's main entry point, by simply appending them to flags.D. Change-Id: I6ada134522b0cbc90d35bcb145fbe045338fefb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/523297 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
f7f1c4f86d
commit
eaae2d45c7
16 changed files with 85 additions and 91 deletions
|
|
@ -29,8 +29,8 @@ func testEndToEnd(t *testing.T, goarch, file string) {
|
||||||
input := filepath.Join("testdata", file+".s")
|
input := filepath.Join("testdata", file+".s")
|
||||||
architecture, ctxt := setArch(goarch)
|
architecture, ctxt := setArch(goarch)
|
||||||
architecture.Init(ctxt)
|
architecture.Init(ctxt)
|
||||||
lexer := lex.NewLexer(input, false)
|
lexer := lex.NewLexer(input)
|
||||||
parser := NewParser(ctxt, architecture, lexer, false)
|
parser := NewParser(ctxt, architecture, lexer)
|
||||||
pList := new(obj.Plist)
|
pList := new(obj.Plist)
|
||||||
var ok bool
|
var ok bool
|
||||||
testOut = new(strings.Builder) // The assembler writes test output to this buffer.
|
testOut = new(strings.Builder) // The assembler writes test output to this buffer.
|
||||||
|
|
@ -191,7 +191,7 @@ Diff:
|
||||||
t.Errorf(format, args...)
|
t.Errorf(format, args...)
|
||||||
ok = false
|
ok = false
|
||||||
}
|
}
|
||||||
obj.Flushplist(ctxt, pList, nil, "")
|
obj.Flushplist(ctxt, pList, nil)
|
||||||
|
|
||||||
for p := top; p != nil; p = p.Link {
|
for p := top; p != nil; p = p.Link {
|
||||||
if p.As == obj.ATEXT {
|
if p.As == obj.ATEXT {
|
||||||
|
|
@ -278,8 +278,8 @@ func testErrors(t *testing.T, goarch, file string, flags ...string) {
|
||||||
input := filepath.Join("testdata", file+".s")
|
input := filepath.Join("testdata", file+".s")
|
||||||
architecture, ctxt := setArch(goarch)
|
architecture, ctxt := setArch(goarch)
|
||||||
architecture.Init(ctxt)
|
architecture.Init(ctxt)
|
||||||
lexer := lex.NewLexer(input, false)
|
lexer := lex.NewLexer(input)
|
||||||
parser := NewParser(ctxt, architecture, lexer, false)
|
parser := NewParser(ctxt, architecture, lexer)
|
||||||
pList := new(obj.Plist)
|
pList := new(obj.Plist)
|
||||||
var ok bool
|
var ok bool
|
||||||
ctxt.Bso = bufio.NewWriter(os.Stdout)
|
ctxt.Bso = bufio.NewWriter(os.Stdout)
|
||||||
|
|
@ -305,7 +305,7 @@ func testErrors(t *testing.T, goarch, file string, flags ...string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pList.Firstpc, ok = parser.Parse()
|
pList.Firstpc, ok = parser.Parse()
|
||||||
obj.Flushplist(ctxt, pList, nil, "")
|
obj.Flushplist(ctxt, pList, nil)
|
||||||
if ok && !failed {
|
if ok && !failed {
|
||||||
t.Errorf("asm: %s had no errors", file)
|
t.Errorf("asm: %s had no errors", file)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ var exprTests = []exprTest{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExpr(t *testing.T) {
|
func TestExpr(t *testing.T) {
|
||||||
p := NewParser(nil, nil, nil, false) // Expression evaluation uses none of these fields of the parser.
|
p := NewParser(nil, nil, nil) // Expression evaluation uses none of these fields of the parser.
|
||||||
for i, test := range exprTests {
|
for i, test := range exprTests {
|
||||||
p.start(lex.Tokenize(test.input))
|
p.start(lex.Tokenize(test.input))
|
||||||
result := int64(p.expr())
|
result := int64(p.expr())
|
||||||
|
|
@ -113,7 +113,7 @@ func TestBadExpr(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runBadTest(i int, test badExprTest, t *testing.T) (err error) {
|
func runBadTest(i int, test badExprTest, t *testing.T) (err error) {
|
||||||
p := NewParser(nil, nil, nil, false) // Expression evaluation uses none of these fields of the parser.
|
p := NewParser(nil, nil, nil) // Expression evaluation uses none of these fields of the parser.
|
||||||
p.start(lex.Tokenize(test.input))
|
p.start(lex.Tokenize(test.input))
|
||||||
return tryParse(t, func() {
|
return tryParse(t, func() {
|
||||||
p.expr()
|
p.expr()
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ func testBadInstParser(t *testing.T, goarch string, tests []badInstTest) {
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
arch, ctxt := setArch(goarch)
|
arch, ctxt := setArch(goarch)
|
||||||
tokenizer := lex.NewTokenizer("", strings.NewReader(test.input+"\n"), nil)
|
tokenizer := lex.NewTokenizer("", strings.NewReader(test.input+"\n"), nil)
|
||||||
parser := NewParser(ctxt, arch, tokenizer, false)
|
parser := NewParser(ctxt, arch, tokenizer)
|
||||||
|
|
||||||
err := tryParse(t, func() {
|
err := tryParse(t, func() {
|
||||||
parser.Parse()
|
parser.Parse()
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ func setArch(goarch string) (*arch.Arch, *obj.Link) {
|
||||||
|
|
||||||
func newParser(goarch string) *Parser {
|
func newParser(goarch string) *Parser {
|
||||||
architecture, ctxt := setArch(goarch)
|
architecture, ctxt := setArch(goarch)
|
||||||
return NewParser(ctxt, architecture, nil, false)
|
return NewParser(ctxt, architecture, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// tryParse executes parse func in panicOnError=true context.
|
// tryParse executes parse func in panicOnError=true context.
|
||||||
|
|
@ -76,7 +76,7 @@ func testOperandParser(t *testing.T, parser *Parser, tests []operandTest) {
|
||||||
addr := obj.Addr{}
|
addr := obj.Addr{}
|
||||||
parser.operand(&addr)
|
parser.operand(&addr)
|
||||||
var result string
|
var result string
|
||||||
if parser.compilingRuntime {
|
if parser.allowABI {
|
||||||
result = obj.DconvWithABIDetail(&emptyProg, &addr)
|
result = obj.DconvWithABIDetail(&emptyProg, &addr)
|
||||||
} else {
|
} else {
|
||||||
result = obj.Dconv(&emptyProg, &addr)
|
result = obj.Dconv(&emptyProg, &addr)
|
||||||
|
|
@ -91,7 +91,7 @@ func TestAMD64OperandParser(t *testing.T) {
|
||||||
parser := newParser("amd64")
|
parser := newParser("amd64")
|
||||||
testOperandParser(t, parser, amd64OperandTests)
|
testOperandParser(t, parser, amd64OperandTests)
|
||||||
testBadOperandParser(t, parser, amd64BadOperandTests)
|
testBadOperandParser(t, parser, amd64BadOperandTests)
|
||||||
parser.compilingRuntime = true
|
parser.allowABI = true
|
||||||
testOperandParser(t, parser, amd64RuntimeOperandTests)
|
testOperandParser(t, parser, amd64RuntimeOperandTests)
|
||||||
testBadOperandParser(t, parser, amd64BadOperandRuntimeTests)
|
testBadOperandParser(t, parser, amd64BadOperandRuntimeTests)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,31 +21,32 @@ import (
|
||||||
"cmd/internal/obj"
|
"cmd/internal/obj"
|
||||||
"cmd/internal/obj/arm64"
|
"cmd/internal/obj/arm64"
|
||||||
"cmd/internal/obj/x86"
|
"cmd/internal/obj/x86"
|
||||||
|
"cmd/internal/objabi"
|
||||||
"cmd/internal/src"
|
"cmd/internal/src"
|
||||||
"cmd/internal/sys"
|
"cmd/internal/sys"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
lex lex.TokenReader
|
lex lex.TokenReader
|
||||||
lineNum int // Line number in source file.
|
lineNum int // Line number in source file.
|
||||||
errorLine int // Line number of last error.
|
errorLine int // Line number of last error.
|
||||||
errorCount int // Number of errors.
|
errorCount int // Number of errors.
|
||||||
sawCode bool // saw code in this file (as opposed to comments and blank lines)
|
sawCode bool // saw code in this file (as opposed to comments and blank lines)
|
||||||
pc int64 // virtual PC; count of Progs; doesn't advance for GLOBL or DATA.
|
pc int64 // virtual PC; count of Progs; doesn't advance for GLOBL or DATA.
|
||||||
input []lex.Token
|
input []lex.Token
|
||||||
inputPos int
|
inputPos int
|
||||||
pendingLabels []string // Labels to attach to next instruction.
|
pendingLabels []string // Labels to attach to next instruction.
|
||||||
labels map[string]*obj.Prog
|
labels map[string]*obj.Prog
|
||||||
toPatch []Patch
|
toPatch []Patch
|
||||||
addr []obj.Addr
|
addr []obj.Addr
|
||||||
arch *arch.Arch
|
arch *arch.Arch
|
||||||
ctxt *obj.Link
|
ctxt *obj.Link
|
||||||
firstProg *obj.Prog
|
firstProg *obj.Prog
|
||||||
lastProg *obj.Prog
|
lastProg *obj.Prog
|
||||||
dataAddr map[string]int64 // Most recent address for DATA for this symbol.
|
dataAddr map[string]int64 // Most recent address for DATA for this symbol.
|
||||||
isJump bool // Instruction being assembled is a jump.
|
isJump bool // Instruction being assembled is a jump.
|
||||||
compilingRuntime bool
|
allowABI bool // Whether ABI selectors are allowed.
|
||||||
errorWriter io.Writer
|
errorWriter io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
type Patch struct {
|
type Patch struct {
|
||||||
|
|
@ -53,15 +54,15 @@ type Patch struct {
|
||||||
label string
|
label string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewParser(ctxt *obj.Link, ar *arch.Arch, lexer lex.TokenReader, compilingRuntime bool) *Parser {
|
func NewParser(ctxt *obj.Link, ar *arch.Arch, lexer lex.TokenReader) *Parser {
|
||||||
return &Parser{
|
return &Parser{
|
||||||
ctxt: ctxt,
|
ctxt: ctxt,
|
||||||
arch: ar,
|
arch: ar,
|
||||||
lex: lexer,
|
lex: lexer,
|
||||||
labels: make(map[string]*obj.Prog),
|
labels: make(map[string]*obj.Prog),
|
||||||
dataAddr: make(map[string]int64),
|
dataAddr: make(map[string]int64),
|
||||||
errorWriter: os.Stderr,
|
errorWriter: os.Stderr,
|
||||||
compilingRuntime: compilingRuntime,
|
allowABI: ctxt != nil && objabi.LookupPkgSpecial(ctxt.Pkgpath).AllowAsmABI,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -864,7 +865,7 @@ func (p *Parser) symRefAttrs(name string, issueError bool) (bool, obj.ABI) {
|
||||||
isStatic = true
|
isStatic = true
|
||||||
} else if tok == scanner.Ident {
|
} else if tok == scanner.Ident {
|
||||||
abistr := p.get(scanner.Ident).String()
|
abistr := p.get(scanner.Ident).String()
|
||||||
if !p.compilingRuntime {
|
if !p.allowABI {
|
||||||
if issueError {
|
if issueError {
|
||||||
p.errorf("ABI selector only permitted when compiling runtime, reference was to %q", name)
|
p.errorf("ABI selector only permitted when compiling runtime, reference was to %q", name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,16 +64,16 @@ func TestErroneous(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
testcats := []struct {
|
testcats := []struct {
|
||||||
compilingRuntime bool
|
allowABI bool
|
||||||
tests []errtest
|
tests []errtest
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
compilingRuntime: false,
|
allowABI: false,
|
||||||
tests: nonRuntimeTests,
|
tests: nonRuntimeTests,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
compilingRuntime: true,
|
allowABI: true,
|
||||||
tests: runtimeTests,
|
tests: runtimeTests,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ func TestErroneous(t *testing.T) {
|
||||||
|
|
||||||
for _, cat := range testcats {
|
for _, cat := range testcats {
|
||||||
for _, test := range cat.tests {
|
for _, test := range cat.tests {
|
||||||
parser.compilingRuntime = cat.compilingRuntime
|
parser.allowABI = cat.allowABI
|
||||||
parser.errorCount = 0
|
parser.errorCount = 0
|
||||||
parser.lineNum++
|
parser.lineNum++
|
||||||
if !parser.pseudo(test.pseudo, tokenize(test.operands)) {
|
if !parser.pseudo(test.pseudo, tokenize(test.operands)) {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package lex
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/buildcfg"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -34,33 +33,18 @@ type Input struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInput returns an Input from the given path.
|
// NewInput returns an Input from the given path.
|
||||||
func NewInput(name string, compilingRuntime bool) *Input {
|
func NewInput(name string) *Input {
|
||||||
return &Input{
|
return &Input{
|
||||||
// include directories: look in source dir, then -I directories.
|
// include directories: look in source dir, then -I directories.
|
||||||
includes: append([]string{filepath.Dir(name)}, flags.I...),
|
includes: append([]string{filepath.Dir(name)}, flags.I...),
|
||||||
beginningOfLine: true,
|
beginningOfLine: true,
|
||||||
macros: predefine(flags.D, compilingRuntime),
|
macros: predefine(flags.D),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// predefine installs the macros set by the -D flag on the command line.
|
// predefine installs the macros set by the -D flag on the command line.
|
||||||
func predefine(defines flags.MultiFlag, compilingRuntime bool) map[string]*Macro {
|
func predefine(defines flags.MultiFlag) map[string]*Macro {
|
||||||
macros := make(map[string]*Macro)
|
macros := make(map[string]*Macro)
|
||||||
|
|
||||||
// Set macros for GOEXPERIMENTs so we can easily switch
|
|
||||||
// runtime assembly code based on them.
|
|
||||||
if compilingRuntime {
|
|
||||||
for _, exp := range buildcfg.Experiment.Enabled() {
|
|
||||||
// Define macro.
|
|
||||||
name := "GOEXPERIMENT_" + exp
|
|
||||||
macros[name] = &Macro{
|
|
||||||
name: name,
|
|
||||||
args: nil,
|
|
||||||
tokens: Tokenize("1"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, name := range defines {
|
for _, name := range defines {
|
||||||
value := "1"
|
value := "1"
|
||||||
i := strings.IndexRune(name, '=')
|
i := strings.IndexRune(name, '=')
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ func (t ScanToken) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLexer returns a lexer for the named file and the given link context.
|
// NewLexer returns a lexer for the named file and the given link context.
|
||||||
func NewLexer(name string, compilingRuntime bool) TokenReader {
|
func NewLexer(name string) TokenReader {
|
||||||
input := NewInput(name, compilingRuntime)
|
input := NewInput(name)
|
||||||
fd, err := os.Open(name)
|
fd, err := os.Open(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("%s\n", err)
|
log.Fatalf("%s\n", err)
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ var lexTests = []lexTest{
|
||||||
|
|
||||||
func TestLex(t *testing.T) {
|
func TestLex(t *testing.T) {
|
||||||
for _, test := range lexTests {
|
for _, test := range lexTests {
|
||||||
input := NewInput(test.name, false)
|
input := NewInput(test.name)
|
||||||
input.Push(NewTokenizer(test.name, strings.NewReader(test.input), nil))
|
input.Push(NewTokenizer(test.name, strings.NewReader(test.input), nil))
|
||||||
result := drain(input)
|
result := drain(input)
|
||||||
if result != test.output {
|
if result != test.output {
|
||||||
|
|
@ -328,7 +328,7 @@ var badLexTests = []badLexTest{
|
||||||
|
|
||||||
func TestBadLex(t *testing.T) {
|
func TestBadLex(t *testing.T) {
|
||||||
for _, test := range badLexTests {
|
for _, test := range badLexTests {
|
||||||
input := NewInput(test.error, false)
|
input := NewInput(test.error)
|
||||||
input.Push(NewTokenizer(test.error, strings.NewReader(test.input), nil))
|
input.Push(NewTokenizer(test.error, strings.NewReader(test.input), nil))
|
||||||
err := firstError(input)
|
err := firstError(input)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,6 @@ func main() {
|
||||||
if architecture == nil {
|
if architecture == nil {
|
||||||
log.Fatalf("unrecognized architecture %s", GOARCH)
|
log.Fatalf("unrecognized architecture %s", GOARCH)
|
||||||
}
|
}
|
||||||
compilingRuntime := objabi.LookupPkgSpecial(*flags.Importpath).AllowAsmABI
|
|
||||||
|
|
||||||
ctxt := obj.Linknew(architecture.LinkArch)
|
ctxt := obj.Linknew(architecture.LinkArch)
|
||||||
ctxt.Debugasm = flags.PrintOut
|
ctxt.Debugasm = flags.PrintOut
|
||||||
ctxt.Debugvlog = flags.DebugV
|
ctxt.Debugvlog = flags.DebugV
|
||||||
|
|
@ -77,12 +75,19 @@ func main() {
|
||||||
fmt.Fprintf(buf, "!\n")
|
fmt.Fprintf(buf, "!\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set macros for GOEXPERIMENTs so we can easily switch
|
||||||
|
// runtime assembly code based on them.
|
||||||
|
if objabi.LookupPkgSpecial(ctxt.Pkgpath).AllowAsmABI {
|
||||||
|
for _, exp := range buildcfg.Experiment.Enabled() {
|
||||||
|
flags.D = append(flags.D, "GOEXPERIMENT_"+exp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var ok, diag bool
|
var ok, diag bool
|
||||||
var failedFile string
|
var failedFile string
|
||||||
for _, f := range flag.Args() {
|
for _, f := range flag.Args() {
|
||||||
lexer := lex.NewLexer(f, compilingRuntime)
|
lexer := lex.NewLexer(f)
|
||||||
parser := asm.NewParser(ctxt, architecture, lexer,
|
parser := asm.NewParser(ctxt, architecture, lexer)
|
||||||
compilingRuntime)
|
|
||||||
ctxt.DiagFunc = func(format string, args ...interface{}) {
|
ctxt.DiagFunc = func(format string, args ...interface{}) {
|
||||||
diag = true
|
diag = true
|
||||||
log.Printf(format, args...)
|
log.Printf(format, args...)
|
||||||
|
|
@ -94,7 +99,7 @@ func main() {
|
||||||
pList.Firstpc, ok = parser.Parse()
|
pList.Firstpc, ok = parser.Parse()
|
||||||
// reports errors to parser.Errorf
|
// reports errors to parser.Errorf
|
||||||
if ok {
|
if ok {
|
||||||
obj.Flushplist(ctxt, pList, nil, *flags.Importpath)
|
obj.Flushplist(ctxt, pList, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ func AbstractFunc(fn *obj.LSym) {
|
||||||
if base.Debug.DwarfInl != 0 {
|
if base.Debug.DwarfInl != 0 {
|
||||||
base.Ctxt.Logf("DwarfAbstractFunc(%v)\n", fn.Name)
|
base.Ctxt.Logf("DwarfAbstractFunc(%v)\n", fn.Name)
|
||||||
}
|
}
|
||||||
base.Ctxt.DwarfAbstractFunc(ifn, fn, base.Ctxt.Pkgpath)
|
base.Ctxt.DwarfAbstractFunc(ifn, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Undo any versioning performed when a name was written
|
// Undo any versioning performed when a name was written
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ func dumpGlobal(n *ir.Name) {
|
||||||
if n.CoverageCounter() || n.CoverageAuxVar() || n.Linksym().Static() {
|
if n.CoverageCounter() || n.CoverageAuxVar() || n.Linksym().Static() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
base.Ctxt.DwarfGlobal(base.Ctxt.Pkgpath, types.TypeSymName(n.Type()), n.Linksym())
|
base.Ctxt.DwarfGlobal(types.TypeSymName(n.Type()), n.Linksym())
|
||||||
}
|
}
|
||||||
|
|
||||||
func dumpGlobalConst(n *ir.Name) {
|
func dumpGlobalConst(n *ir.Name) {
|
||||||
|
|
@ -186,7 +186,7 @@ func dumpGlobalConst(n *ir.Name) {
|
||||||
// that type so the linker knows about it. See issue 51245.
|
// that type so the linker knows about it. See issue 51245.
|
||||||
_ = reflectdata.TypeLinksym(t)
|
_ = reflectdata.TypeLinksym(t)
|
||||||
}
|
}
|
||||||
base.Ctxt.DwarfIntConst(base.Ctxt.Pkgpath, n.Sym().Name, types.TypeSymName(t), ir.IntVal(t, v))
|
base.Ctxt.DwarfIntConst(n.Sym().Name, types.TypeSymName(t), ir.IntVal(t, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
// addGCLocals adds gcargs, gclocals, gcregs, and stack object symbols to Ctxt.Data.
|
// addGCLocals adds gcargs, gclocals, gcregs, and stack object symbols to Ctxt.Data.
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ func (pp *Progs) NewProg() *obj.Prog {
|
||||||
// Flush converts from pp to machine code.
|
// Flush converts from pp to machine code.
|
||||||
func (pp *Progs) Flush() {
|
func (pp *Progs) Flush() {
|
||||||
plist := &obj.Plist{Firstpc: pp.Text, Curfn: pp.CurFunc}
|
plist := &obj.Plist{Firstpc: pp.Text, Curfn: pp.CurFunc}
|
||||||
obj.Flushplist(base.Ctxt, plist, pp.NewProg, base.Ctxt.Pkgpath)
|
obj.Flushplist(base.Ctxt, plist, pp.NewProg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free clears pp and any associated resources.
|
// Free clears pp and any associated resources.
|
||||||
|
|
|
||||||
|
|
@ -1233,7 +1233,6 @@ func putPrunedScopes(ctxt Context, s *FnState, fnabbrev int) error {
|
||||||
// DIE (as a space-saving measure, so that name/type etc doesn't have
|
// DIE (as a space-saving measure, so that name/type etc doesn't have
|
||||||
// to be repeated for each inlined copy).
|
// to be repeated for each inlined copy).
|
||||||
func PutAbstractFunc(ctxt Context, s *FnState) error {
|
func PutAbstractFunc(ctxt Context, s *FnState) error {
|
||||||
|
|
||||||
if logDwarf {
|
if logDwarf {
|
||||||
ctxt.Logf("PutAbstractFunc(%v)\n", s.Absfn)
|
ctxt.Logf("PutAbstractFunc(%v)\n", s.Absfn)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,12 @@ func (ctxt *Link) fileSymbol(fn *LSym) *LSym {
|
||||||
// populateDWARF fills in the DWARF Debugging Information Entries for
|
// populateDWARF fills in the DWARF Debugging Information Entries for
|
||||||
// TEXT symbol 's'. The various DWARF symbols must already have been
|
// TEXT symbol 's'. The various DWARF symbols must already have been
|
||||||
// initialized in InitTextSym.
|
// initialized in InitTextSym.
|
||||||
func (ctxt *Link) populateDWARF(curfn interface{}, s *LSym, myimportpath string) {
|
func (ctxt *Link) populateDWARF(curfn interface{}, s *LSym) {
|
||||||
|
myimportpath := ctxt.Pkgpath
|
||||||
|
if myimportpath == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
info, loc, ranges, absfunc, lines := ctxt.dwarfSym(s)
|
info, loc, ranges, absfunc, lines := ctxt.dwarfSym(s)
|
||||||
if info.Size != 0 {
|
if info.Size != 0 {
|
||||||
ctxt.Diag("makeFuncDebugEntry double process %v", s)
|
ctxt.Diag("makeFuncDebugEntry double process %v", s)
|
||||||
|
|
@ -394,7 +399,8 @@ func (ctxt *Link) populateDWARF(curfn interface{}, s *LSym, myimportpath string)
|
||||||
|
|
||||||
// DwarfIntConst creates a link symbol for an integer constant with the
|
// DwarfIntConst creates a link symbol for an integer constant with the
|
||||||
// given name, type and value.
|
// given name, type and value.
|
||||||
func (ctxt *Link) DwarfIntConst(myimportpath, name, typename string, val int64) {
|
func (ctxt *Link) DwarfIntConst(name, typename string, val int64) {
|
||||||
|
myimportpath := ctxt.Pkgpath
|
||||||
if myimportpath == "" {
|
if myimportpath == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -407,7 +413,8 @@ func (ctxt *Link) DwarfIntConst(myimportpath, name, typename string, val int64)
|
||||||
|
|
||||||
// DwarfGlobal creates a link symbol containing a DWARF entry for
|
// DwarfGlobal creates a link symbol containing a DWARF entry for
|
||||||
// a global variable.
|
// a global variable.
|
||||||
func (ctxt *Link) DwarfGlobal(myimportpath, typename string, varSym *LSym) {
|
func (ctxt *Link) DwarfGlobal(typename string, varSym *LSym) {
|
||||||
|
myimportpath := ctxt.Pkgpath
|
||||||
if myimportpath == "" || varSym.Local() {
|
if myimportpath == "" || varSym.Local() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -421,7 +428,7 @@ func (ctxt *Link) DwarfGlobal(myimportpath, typename string, varSym *LSym) {
|
||||||
dwarf.PutGlobal(dwCtxt{ctxt}, dieSym, typeSym, varSym, varname)
|
dwarf.PutGlobal(dwCtxt{ctxt}, dieSym, typeSym, varSym, varname)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctxt *Link) DwarfAbstractFunc(curfn interface{}, s *LSym, myimportpath string) {
|
func (ctxt *Link) DwarfAbstractFunc(curfn interface{}, s *LSym) {
|
||||||
absfn := ctxt.DwFixups.AbsFuncDwarfSym(s)
|
absfn := ctxt.DwFixups.AbsFuncDwarfSym(s)
|
||||||
if absfn.Size != 0 {
|
if absfn.Size != 0 {
|
||||||
ctxt.Diag("internal error: DwarfAbstractFunc double process %v", s)
|
ctxt.Diag("internal error: DwarfAbstractFunc double process %v", s)
|
||||||
|
|
@ -434,7 +441,7 @@ func (ctxt *Link) DwarfAbstractFunc(curfn interface{}, s *LSym, myimportpath str
|
||||||
dwctxt := dwCtxt{ctxt}
|
dwctxt := dwCtxt{ctxt}
|
||||||
fnstate := dwarf.FnState{
|
fnstate := dwarf.FnState{
|
||||||
Name: s.Name,
|
Name: s.Name,
|
||||||
Importpath: myimportpath,
|
Importpath: ctxt.Pkgpath,
|
||||||
Info: absfn,
|
Info: absfn,
|
||||||
Absfn: absfn,
|
Absfn: absfn,
|
||||||
StartLine: startLine,
|
StartLine: startLine,
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ type Plist struct {
|
||||||
// It is used to provide access to cached/bulk-allocated Progs to the assemblers.
|
// It is used to provide access to cached/bulk-allocated Progs to the assemblers.
|
||||||
type ProgAlloc func() *Prog
|
type ProgAlloc func() *Prog
|
||||||
|
|
||||||
func Flushplist(ctxt *Link, plist *Plist, newprog ProgAlloc, myimportpath string) {
|
func Flushplist(ctxt *Link, plist *Plist, newprog ProgAlloc) {
|
||||||
// Build list of symbols, and assign instructions to lists.
|
// Build list of symbols, and assign instructions to lists.
|
||||||
var curtext *LSym
|
var curtext *LSym
|
||||||
var etext *Prog
|
var etext *Prog
|
||||||
|
|
@ -155,9 +155,7 @@ func Flushplist(ctxt *Link, plist *Plist, newprog ProgAlloc, myimportpath string
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
linkpcln(ctxt, s)
|
linkpcln(ctxt, s)
|
||||||
if myimportpath != "" {
|
ctxt.populateDWARF(plist.Curfn, s)
|
||||||
ctxt.populateDWARF(plist.Curfn, s, myimportpath)
|
|
||||||
}
|
|
||||||
if ctxt.Headtype == objabi.Hwindows && ctxt.Arch.SEH != nil {
|
if ctxt.Headtype == objabi.Hwindows && ctxt.Arch.SEH != nil {
|
||||||
s.Func().sehUnwindInfoSym = ctxt.Arch.SEH(ctxt, s)
|
s.Func().sehUnwindInfoSym = ctxt.Arch.SEH(ctxt, s)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue