mirror of
https://github.com/golang/go
synced 2024-11-23 19:20:03 -07:00
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/+/174537 Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
856b57e0d4
commit
f766b68023
@ -145,17 +145,18 @@ func TestFuncAddress(t *testing.T) {
|
||||
|
||||
isFuncSym := strings.HasSuffix(test.input, "(SB)") &&
|
||||
// Ignore static symbols.
|
||||
!strings.Contains(test.input, "<>") &&
|
||||
// Ignore symbols with offsets.
|
||||
!strings.Contains(test.input, "+")
|
||||
!strings.Contains(test.input, "<>")
|
||||
|
||||
wantName := ""
|
||||
if isFuncSym {
|
||||
// Strip $|* and (SB).
|
||||
// Strip $|* and (SB) and +Int.
|
||||
wantName = test.output[:len(test.output)-4]
|
||||
if strings.HasPrefix(wantName, "$") || strings.HasPrefix(wantName, "*") {
|
||||
wantName = wantName[1:]
|
||||
}
|
||||
if i := strings.Index(wantName, "+"); i >= 0 {
|
||||
wantName = wantName[:i]
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
@ -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
|
||||
// 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) {
|
||||
switch p.peek() {
|
||||
case '$', '*':
|
||||
@ -815,7 +815,14 @@ func (p *Parser) funcAddress() (string, bool) {
|
||||
if tok.ScanToken != scanner.Ident || p.atStartOfRegister(name) {
|
||||
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
|
||||
}
|
||||
if reg := p.next(); reg.ScanToken != scanner.Ident || reg.String() != "SB" {
|
||||
|
Loading…
Reference in New Issue
Block a user