Commit f766b680 authored by Russ Cox's avatar Russ Cox

cmd/asm: accept TEXT f+0(SB) in -gensymabis mode

f+0(SB) is a non-standard but acceptable alias for f(SB).

Fixes #30968.

Change-Id: I499ccee4d3ff3ab4e47f75d99407aace858e59aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/174537Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 856b57e0
...@@ -145,17 +145,18 @@ func TestFuncAddress(t *testing.T) { ...@@ -145,17 +145,18 @@ func TestFuncAddress(t *testing.T) {
isFuncSym := strings.HasSuffix(test.input, "(SB)") && isFuncSym := strings.HasSuffix(test.input, "(SB)") &&
// Ignore static symbols. // Ignore static symbols.
!strings.Contains(test.input, "<>") && !strings.Contains(test.input, "<>")
// Ignore symbols with offsets.
!strings.Contains(test.input, "+")
wantName := "" wantName := ""
if isFuncSym { if isFuncSym {
// Strip $|* and (SB). // Strip $|* and (SB) and +Int.
wantName = test.output[:len(test.output)-4] wantName = test.output[:len(test.output)-4]
if strings.HasPrefix(wantName, "$") || strings.HasPrefix(wantName, "*") { if strings.HasPrefix(wantName, "$") || strings.HasPrefix(wantName, "*") {
wantName = wantName[1:] wantName = wantName[1:]
} }
if i := strings.Index(wantName, "+"); i >= 0 {
wantName = wantName[:i]
}
} }
if ok != isFuncSym || name != wantName { if ok != isFuncSym || name != wantName {
t.Errorf("fail at %s as function address: got %s, %v; expected %s, %v", test.input, name, ok, wantName, isFuncSym) t.Errorf("fail at %s as function address: got %s, %v; expected %s, %v", test.input, name, ok, wantName, isFuncSym)
......
...@@ -800,9 +800,9 @@ func (p *Parser) setPseudoRegister(addr *obj.Addr, reg string, isStatic bool, pr ...@@ -800,9 +800,9 @@ func (p *Parser) setPseudoRegister(addr *obj.Addr, reg string, isStatic bool, pr
// funcAddress parses an external function address. This is a // funcAddress parses an external function address. This is a
// constrained form of the operand syntax that's always SB-based, // constrained form of the operand syntax that's always SB-based,
// non-static, and has no additional offsets: // non-static, and has at most a simple integer offset:
// //
// [$|*]sym(SB) // [$|*]sym[+Int](SB)
func (p *Parser) funcAddress() (string, bool) { func (p *Parser) funcAddress() (string, bool) {
switch p.peek() { switch p.peek() {
case '$', '*': case '$', '*':
...@@ -815,7 +815,14 @@ func (p *Parser) funcAddress() (string, bool) { ...@@ -815,7 +815,14 @@ func (p *Parser) funcAddress() (string, bool) {
if tok.ScanToken != scanner.Ident || p.atStartOfRegister(name) { if tok.ScanToken != scanner.Ident || p.atStartOfRegister(name) {
return "", false return "", false
} }
if p.next().ScanToken != '(' { tok = p.next()
if tok.ScanToken == '+' {
if p.next().ScanToken != scanner.Int {
return "", false
}
tok = p.next()
}
if tok.ScanToken != '(' {
return "", false return "", false
} }
if reg := p.next(); reg.ScanToken != scanner.Ident || reg.String() != "SB" { if reg := p.next(); reg.ScanToken != scanner.Ident || reg.String() != "SB" {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment