mirror of
https://github.com/golang/go
synced 2024-11-26 09:18:07 -07:00
cmd/compile: assert that function values reference ABIInternal
Function values must always point to the ABIInternal entry point of a function. It wasn't entirely obvious to me we were getting this right, so this CL adds checks for this. Updates #40724. Change-Id: Idd854e996d63d9151c28ec5c9251b690453b1024 Reviewed-on: https://go-review.googlesource.com/c/go/+/305272 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
0d1423583b
commit
1e8fff0f7b
@ -2360,6 +2360,11 @@ func (s *state) expr(n ir.Node) *ssa.Value {
|
|||||||
case ir.OCFUNC:
|
case ir.OCFUNC:
|
||||||
n := n.(*ir.UnaryExpr)
|
n := n.(*ir.UnaryExpr)
|
||||||
aux := n.X.(*ir.Name).Linksym()
|
aux := n.X.(*ir.Name).Linksym()
|
||||||
|
// OCFUNC is used to build function values, which must
|
||||||
|
// always reference ABIInternal entry points.
|
||||||
|
if aux.ABI() != obj.ABIInternal {
|
||||||
|
s.Fatalf("expected ABIInternal: %v", aux.ABI())
|
||||||
|
}
|
||||||
return s.entryNewValue1A(ssa.OpAddr, n.Type(), aux, s.sb)
|
return s.entryNewValue1A(ssa.OpAddr, n.Type(), aux, s.sb)
|
||||||
case ir.ONAME:
|
case ir.ONAME:
|
||||||
n := n.(*ir.Name)
|
n := n.(*ir.Name)
|
||||||
|
@ -292,7 +292,13 @@ func WriteFuncSyms() {
|
|||||||
for _, nam := range funcsyms {
|
for _, nam := range funcsyms {
|
||||||
s := nam.Sym()
|
s := nam.Sym()
|
||||||
sf := s.Pkg.Lookup(ir.FuncSymName(s)).Linksym()
|
sf := s.Pkg.Lookup(ir.FuncSymName(s)).Linksym()
|
||||||
objw.SymPtr(sf, 0, s.Linksym(), 0)
|
// Function values must always reference ABIInternal
|
||||||
|
// entry points.
|
||||||
|
target := s.Linksym()
|
||||||
|
if target.ABI() != obj.ABIInternal {
|
||||||
|
base.Fatalf("expected ABIInternal: %v has %v", target, target.ABI())
|
||||||
|
}
|
||||||
|
objw.SymPtr(sf, 0, target, 0)
|
||||||
objw.Global(sf, int32(types.PtrSize), obj.DUPOK|obj.RODATA)
|
objw.Global(sf, int32(types.PtrSize), obj.DUPOK|obj.RODATA)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user