summaryrefslogtreecommitdiff
path: root/libgo/go/reflect
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-27 22:13:11 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-27 22:13:11 +0000
commit77b9c6df173c9fde2447c3560d67e065d97c3938 (patch)
tree723725c19f5dbb008b761be51319c63b4010da84 /libgo/go/reflect
parenta2dfe53f7746a1830821233e5af8e67379912586 (diff)
downloadgcc-77b9c6df173c9fde2447c3560d67e065d97c3938.tar.gz
reflect: Copy stack values onto heap in amd64 MakeFunc.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202995 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/reflect')
-rw-r--r--libgo/go/reflect/makefuncgo_amd64.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/libgo/go/reflect/makefuncgo_amd64.go b/libgo/go/reflect/makefuncgo_amd64.go
index bdc65560506..ecc50a42520 100644
--- a/libgo/go/reflect/makefuncgo_amd64.go
+++ b/libgo/go/reflect/makefuncgo_amd64.go
@@ -431,8 +431,14 @@ argloop:
func amd64Memarg(in []Value, ap uintptr, rt *rtype) ([]Value, uintptr) {
ap = align(ap, ptrSize)
ap = align(ap, uintptr(rt.align))
- p := Value{rt, unsafe.Pointer(ap), flag(rt.Kind()<<flagKindShift) | flagIndir}
- in = append(in, p)
+
+ // We have to copy the argument onto the heap in case the
+ // function hangs onto the reflect.Value we pass it.
+ p := unsafe_New(rt)
+ memmove(p, unsafe.Pointer(ap), rt.size)
+
+ v := Value{rt, p, flag(rt.Kind()<<flagKindShift) | flagIndir}
+ in = append(in, v)
ap += rt.size
return in, ap
}