aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/asm/internal/asm/asm.go21
-rw-r--r--src/cmd/asm/internal/lex/input.go4
-rw-r--r--src/cmd/asm/internal/lex/lex.go2
3 files changed, 20 insertions, 7 deletions
diff --git a/src/cmd/asm/internal/asm/asm.go b/src/cmd/asm/internal/asm/asm.go
index e17c1daa87..ae4f6afffc 100644
--- a/src/cmd/asm/internal/asm/asm.go
+++ b/src/cmd/asm/internal/asm/asm.go
@@ -39,6 +39,15 @@ func (p *Parser) symbolType(a *addr.Addr) int {
return 0
}
+// staticVersion reports whether the data's Symbol has <>, as in data<>.
+// It returns 1 for static, 0 for non-static, because that's what obj wants.
+func staticVersion(a *addr.Addr) int {
+ if a.Symbol != "" && a.IsStatic {
+ return 1
+ }
+ return 0
+}
+
// TODO: configure the architecture
// TODO: This is hacky and irregular. When obj settles down, rewrite for simplicity.
@@ -53,7 +62,6 @@ func (p *Parser) addrToAddr(a *addr.Addr) obj.Addr {
// a<>(SB) = STATIC,NONE
// The call to symbolType does the first column; we need to fix up Index here.
out.Type = int16(p.symbolType(a))
- out.Sym = obj.Linklookup(p.linkCtxt, a.Symbol, 0)
if a.IsImmediateAddress {
// Index field says whether it's a static.
switch a.Register {
@@ -67,6 +75,7 @@ func (p *Parser) addrToAddr(a *addr.Addr) obj.Addr {
p.errorf("can't handle immediate address of %s not (SB)\n", a.Symbol)
}
}
+ out.Sym = obj.Linklookup(p.linkCtxt, a.Symbol, staticVersion(a))
} else if a.Has(addr.Register) {
// TODO: SP is tricky, and this isn't good enough.
// SP = D_SP
@@ -217,7 +226,7 @@ func (p *Parser) asmText(word string, operands [][]lex.Token) {
From: obj.Addr{
Type: int16(p.symbolType(&nameAddr)),
Index: uint8(p.arch.D_NONE),
- Sym: obj.Linklookup(p.linkCtxt, name, 0),
+ Sym: obj.Linklookup(p.linkCtxt, name, staticVersion(&nameAddr)),
Scale: flag,
},
To: obj.Addr{
@@ -282,7 +291,7 @@ func (p *Parser) asmData(word string, operands [][]lex.Token) {
From: obj.Addr{
Type: int16(p.symbolType(&nameAddr)),
Index: uint8(p.arch.D_NONE),
- Sym: obj.Linklookup(p.linkCtxt, name, 0),
+ Sym: obj.Linklookup(p.linkCtxt, name, staticVersion(&nameAddr)),
Offset: nameAddr.Offset,
Scale: scale,
},
@@ -335,7 +344,7 @@ func (p *Parser) asmGlobl(word string, operands [][]lex.Token) {
From: obj.Addr{
Type: int16(p.symbolType(&nameAddr)),
Index: uint8(p.arch.D_NONE),
- Sym: obj.Linklookup(p.linkCtxt, name, 0),
+ Sym: obj.Linklookup(p.linkCtxt, name, staticVersion(&nameAddr)),
Offset: nameAddr.Offset,
Scale: scale,
},
@@ -425,7 +434,7 @@ func (p *Parser) asmFuncData(word string, operands [][]lex.Token) {
To: obj.Addr{
Type: int16(p.symbolType(&nameAddr)),
Index: uint8(p.arch.D_NONE),
- Sym: obj.Linklookup(p.linkCtxt, name, 0),
+ Sym: obj.Linklookup(p.linkCtxt, name, staticVersion(&nameAddr)),
Offset: value1,
},
}
@@ -485,7 +494,7 @@ func (p *Parser) asmJump(op int, a []addr.Addr) {
}
prog.To = obj.Addr{
Type: int16(p.arch.D_BRANCH),
- Sym: obj.Linklookup(p.linkCtxt, target.Symbol, 0),
+ Sym: obj.Linklookup(p.linkCtxt, target.Symbol, staticVersion(target)),
Index: uint8(p.arch.D_NONE),
Offset: target.Offset,
}
diff --git a/src/cmd/asm/internal/lex/input.go b/src/cmd/asm/internal/lex/input.go
index 19a50f4fd0..4c8abafc23 100644
--- a/src/cmd/asm/internal/lex/input.go
+++ b/src/cmd/asm/internal/lex/input.go
@@ -422,6 +422,10 @@ func (in *Input) line() {
if err != nil {
in.Error("unquoting #line file name: ", err)
}
+ tok = in.Stack.Next()
+ if tok != '\n' {
+ in.Error("unexpected token at end of #line: ", tok)
+ }
obj.Linklinehist(linkCtxt, histLine, file, line)
in.Stack.SetPos(line, file)
}
diff --git a/src/cmd/asm/internal/lex/lex.go b/src/cmd/asm/internal/lex/lex.go
index b4b0a8c304..bf45ae7071 100644
--- a/src/cmd/asm/internal/lex/lex.go
+++ b/src/cmd/asm/internal/lex/lex.go
@@ -113,7 +113,7 @@ func Make(token ScanToken, text string) Token {
text = `""` + text
}
// Substitute the substitutes for . and /.
- text = strings.Replace(text, "\u00B7", ".", 1)
+ text = strings.Replace(text, "\u00B7", ".", -1)
text = strings.Replace(text, "\u2215", "/", -1)
return Token{ScanToken: token, text: text}
}