mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.cc] asm: fix handling of statics (data<>) and symbols
A typo limited the number of center-dot substitutions to one. Fixed. With these changes, plus a recent fix to 6a, the are no differences, down to the bit level, in object code for any assembly files in std between asm and 6a. (Runtime has not been checked yet, but I expect no errors.) Change-Id: I0e8045b4414223d937e7f8919c8768860554b7d5 Reviewed-on: https://go-review.googlesource.com/3820 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
975c82fd9b
commit
eeebcd9db3
3 changed files with 20 additions and 7 deletions
|
|
@ -39,6 +39,15 @@ func (p *Parser) symbolType(a *addr.Addr) int {
|
||||||
return 0
|
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: configure the architecture
|
||||||
|
|
||||||
// TODO: This is hacky and irregular. When obj settles down, rewrite for simplicity.
|
// 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
|
// a<>(SB) = STATIC,NONE
|
||||||
// The call to symbolType does the first column; we need to fix up Index here.
|
// The call to symbolType does the first column; we need to fix up Index here.
|
||||||
out.Type = int16(p.symbolType(a))
|
out.Type = int16(p.symbolType(a))
|
||||||
out.Sym = obj.Linklookup(p.linkCtxt, a.Symbol, 0)
|
|
||||||
if a.IsImmediateAddress {
|
if a.IsImmediateAddress {
|
||||||
// Index field says whether it's a static.
|
// Index field says whether it's a static.
|
||||||
switch a.Register {
|
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)
|
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) {
|
} else if a.Has(addr.Register) {
|
||||||
// TODO: SP is tricky, and this isn't good enough.
|
// TODO: SP is tricky, and this isn't good enough.
|
||||||
// SP = D_SP
|
// SP = D_SP
|
||||||
|
|
@ -217,7 +226,7 @@ func (p *Parser) asmText(word string, operands [][]lex.Token) {
|
||||||
From: obj.Addr{
|
From: obj.Addr{
|
||||||
Type: int16(p.symbolType(&nameAddr)),
|
Type: int16(p.symbolType(&nameAddr)),
|
||||||
Index: uint8(p.arch.D_NONE),
|
Index: uint8(p.arch.D_NONE),
|
||||||
Sym: obj.Linklookup(p.linkCtxt, name, 0),
|
Sym: obj.Linklookup(p.linkCtxt, name, staticVersion(&nameAddr)),
|
||||||
Scale: flag,
|
Scale: flag,
|
||||||
},
|
},
|
||||||
To: obj.Addr{
|
To: obj.Addr{
|
||||||
|
|
@ -282,7 +291,7 @@ func (p *Parser) asmData(word string, operands [][]lex.Token) {
|
||||||
From: obj.Addr{
|
From: obj.Addr{
|
||||||
Type: int16(p.symbolType(&nameAddr)),
|
Type: int16(p.symbolType(&nameAddr)),
|
||||||
Index: uint8(p.arch.D_NONE),
|
Index: uint8(p.arch.D_NONE),
|
||||||
Sym: obj.Linklookup(p.linkCtxt, name, 0),
|
Sym: obj.Linklookup(p.linkCtxt, name, staticVersion(&nameAddr)),
|
||||||
Offset: nameAddr.Offset,
|
Offset: nameAddr.Offset,
|
||||||
Scale: scale,
|
Scale: scale,
|
||||||
},
|
},
|
||||||
|
|
@ -335,7 +344,7 @@ func (p *Parser) asmGlobl(word string, operands [][]lex.Token) {
|
||||||
From: obj.Addr{
|
From: obj.Addr{
|
||||||
Type: int16(p.symbolType(&nameAddr)),
|
Type: int16(p.symbolType(&nameAddr)),
|
||||||
Index: uint8(p.arch.D_NONE),
|
Index: uint8(p.arch.D_NONE),
|
||||||
Sym: obj.Linklookup(p.linkCtxt, name, 0),
|
Sym: obj.Linklookup(p.linkCtxt, name, staticVersion(&nameAddr)),
|
||||||
Offset: nameAddr.Offset,
|
Offset: nameAddr.Offset,
|
||||||
Scale: scale,
|
Scale: scale,
|
||||||
},
|
},
|
||||||
|
|
@ -425,7 +434,7 @@ func (p *Parser) asmFuncData(word string, operands [][]lex.Token) {
|
||||||
To: obj.Addr{
|
To: obj.Addr{
|
||||||
Type: int16(p.symbolType(&nameAddr)),
|
Type: int16(p.symbolType(&nameAddr)),
|
||||||
Index: uint8(p.arch.D_NONE),
|
Index: uint8(p.arch.D_NONE),
|
||||||
Sym: obj.Linklookup(p.linkCtxt, name, 0),
|
Sym: obj.Linklookup(p.linkCtxt, name, staticVersion(&nameAddr)),
|
||||||
Offset: value1,
|
Offset: value1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -485,7 +494,7 @@ func (p *Parser) asmJump(op int, a []addr.Addr) {
|
||||||
}
|
}
|
||||||
prog.To = obj.Addr{
|
prog.To = obj.Addr{
|
||||||
Type: int16(p.arch.D_BRANCH),
|
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),
|
Index: uint8(p.arch.D_NONE),
|
||||||
Offset: target.Offset,
|
Offset: target.Offset,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -422,6 +422,10 @@ func (in *Input) line() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
in.Error("unquoting #line file name: ", err)
|
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)
|
obj.Linklinehist(linkCtxt, histLine, file, line)
|
||||||
in.Stack.SetPos(line, file)
|
in.Stack.SetPos(line, file)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ func Make(token ScanToken, text string) Token {
|
||||||
text = `""` + text
|
text = `""` + text
|
||||||
}
|
}
|
||||||
// Substitute the substitutes for . and /.
|
// Substitute the substitutes for . and /.
|
||||||
text = strings.Replace(text, "\u00B7", ".", 1)
|
text = strings.Replace(text, "\u00B7", ".", -1)
|
||||||
text = strings.Replace(text, "\u2215", "/", -1)
|
text = strings.Replace(text, "\u2215", "/", -1)
|
||||||
return Token{ScanToken: token, text: text}
|
return Token{ScanToken: token, text: text}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue