Fix up a couple of minor things pointed out in the last review.
Also:
1. If the symbol starts with center dot, prefix the name with "".
2. If there is no locals size specified, use ArgsSizeUnknown (sic).
3. Do not emit a history point at the start of a macro invocation,
since we do not pop it at the end, behavior consistent with the
old code.
With these changes, old and new assemblers produce identical
output at least for my simple test case, so that provides a verifiable
check for future cleanups.
Change-Id: Iaa91d8e453109824b4be44321ec5e828f39f0299
Reviewed-on: https://go-review.googlesource.com/3242
Reviewed-by: Russ Cox <rsc@golang.org>
if !nameAddr.Is(addr.Symbol|addr.Register|addr.Indirect) || nameAddr.Register != arch.RSB {
p.errorf("TEXT symbol %q must be an offset from SB", nameAddr.Symbol)
}
- name := strings.Replace(nameAddr.Symbol, "·", ".", 1)
+ name := nameAddr.Symbol
// Operand 1 is the text flag, a literal integer.
flagAddr := p.address(operands[1])
// Not clear we can do better, but it doesn't matter.
op := operands[2]
n := len(op)
- var locals int64
+ locals := int64(obj.ArgsSizeUnknown)
if n >= 2 && op[n-2].ScanToken == '-' && op[n-1].ScanToken == scanner.Int {
p.start(op[n-1:])
locals = int64(p.expr())
continue
}
}
- tokens = append(tokens, Token{ScanToken(tok), in.Text()})
+ tokens = append(tokens, Make(tok, in.Text()))
tok = in.Stack.Next()
}
return args, tokens
return args
}
default:
- tokens = append(tokens, Token{tok, in.Stack.Text()})
+ tokens = append(tokens, Make(tok, in.Stack.Text()))
}
}
}
// Make returns a Token with the given rune (ScanToken) and text representation.
func Make(token ScanToken, text string) Token {
+ // If the symbol starts with center dot, as in ·x, rewrite it as ""·x
+ if token == scanner.Ident && strings.HasPrefix(text, "\u00B7") {
+ text = `""` + text
+ }
+ // Substitute the substitutes for . and /.
+ text = strings.Replace(text, "\u00B7", ".", 1)
+ text = strings.Replace(text, "\u2215", "/", -1)
return Token{ScanToken: token, text: text}
}
if tok == scanner.EOF {
break
}
- tokens = append(tokens, Token{ScanToken: tok, text: t.Text()})
+ tokens = append(tokens, Make(tok, t.Text()))
}
return tokens
}
scanner.ScanComments
s.Position.Filename = name
s.IsIdentRune = isIdentRune
- obj.Linklinehist(linkCtxt, histLine, name, 0)
+ if file != nil {
+ obj.Linklinehist(linkCtxt, histLine, name, 0)
+ }
return &Tokenizer{
s: &s,
line: 1,
}
switch t.tok {
case '\n':
- histLine++
+ if t.file != nil {
+ histLine++
+ }
t.line++
case '-':
if s.Peek() == '>' {
log.Fatalf("asm: unrecognized architecture %s", GOARCH)
}
- // Is this right?
- flags.Parse(build.Default.GOROOT, build.Default.GOOS, GOARCH, architecture.Thechar)
+ flags.Parse(obj.Getgoroot(), obj.Getgoos(), obj.Getgoarch(), architecture.Thechar)
// Create object file, write header.
fd, err := os.Create(*flags.OutputFile)