Re: libgo patch committed: Implement reflect.MakeFunc for 386

2013-10-07 Thread Rainer Orth
Ian Lance Taylor i...@google.com writes:

 On Wed, Oct 2, 2013 at 7:45 AM, Rainer Orth r...@cebitec.uni-bielefeld.de 
 wrote:

 Here's what I came up with.  As I said, it is inspired by the libffi
 code, but a bit simplified since e.g. stuff like no .ascii support
 aren't relevant on the Solaris versions supported on mainline and 4.8
 branch.

 Bootstrapped on x86_64-unknown-linux-gnu and i386-pc-solaris2.10 with
 Sun as and gas.  I've also compared the readelf --debug-dump=frames
 output for the 32 and 64-bit makefunc.o, both PIC and non-PIC.  64-bit
 is completely unchanged, while for 32-bit there are FDE encoding changes
 as expected from the FDE_ENCODING/FDE_ENCODE macros.

 Rainer


 2013-10-01  Rainer Orth  r...@cebitec.uni-bielefeld.de

 * configure.ac (libgo_cv_ro_eh_frame): New test.
 (libgo_cv_as_comdat_gnu): Likewise.
 (libgo_cv_as_x86_pcrel): Likewise.
 (libgo_cv_as_x86_64_unwind_section_type): Likewise.
 * configure: Regenerate.
 * config.h.in: Regenerate.
 * go/reflect/makefunc_386.S: Replace CFI directives by hand-coded
 .eh_frame section.
 Restrict .note.* sections to Linux.
 * go/reflect/makefunc_amd64.S: Likewise.

 Great, thanks for working on this.  Committed to trunk and 4.8 branch.

Unfortunately, Solaris 9 testing with Sun as revealed two problems: that
assembler cannot handle either # comments or .global instead of .globl.
The following patch fixes this and allows makefunc_386.S to assemble.
Also compiled with a gas build to make nothing broke there.

I didn't touch makefunc_amd64.S, but could to keep the two consistent.

Rainer


diff --git a/libgo/go/reflect/makefunc_386.S b/libgo/go/reflect/makefunc_386.S
--- a/libgo/go/reflect/makefunc_386.S
+++ b/libgo/go/reflect/makefunc_386.S
@@ -1,12 +1,12 @@
-# Copyright 2013 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
+/* Copyright 2013 The Go Authors. All rights reserved.
+   Use of this source code is governed by a BSD-style
+   license that can be found in the LICENSE file.
 
-# MakeFunc 386 assembly code.
+   MakeFunc 386 assembly code.  */
 
 #include config.h
 
-	.global reflect.makeFuncStub
+	.globl reflect.makeFuncStub
 
 #ifdef __ELF__
 	.type reflect.makeFuncStub,@function
@@ -15,25 +15,26 @@
 reflect.makeFuncStub:
 .LFB1:
 
-	# Go does not provide any equivalent to the regparm function
-	# attribute, so on Go we do not need to worry about passing
-	# parameters in registers.  We just pass a pointer to the
-	# arguments on the stack.
-	#
-	# We do need to pick up the return values, though, so we pass
-	# a pointer to a struct that looks like this.
-	# struct {
-	#   esp uint32		// 0x0
-	#   eax uint32		// 0x4
-	#   st0 uint64		// 0x8
-	# }
+	/* Go does not provide any equivalent to the regparm function
+	   attribute, so on Go we do not need to worry about passing
+	   parameters in registers.  We just pass a pointer to the
+	   arguments on the stack.
+	
+	   We do need to pick up the return values, though, so we pass
+	   a pointer to a struct that looks like this.
+	   struct {
+	 esp uint32		// 0x0
+	 eax uint32		// 0x4
+	 st0 uint64		// 0x8
+	   }
+	*/
 
 	pushl	%ebp
 .LCFI0:
 	movl	%esp, %ebp
 .LCFI1:
-	pushl	%ebx		# In case this is PIC.
-	subl	$36, %esp	# Enough for args and to align stack.
+	pushl	%ebx		/* In case this is PIC.  */
+	subl	$36, %esp	/* Enough for args and to align stack.  */
 .LCFI2:
 
 #ifdef __PIC__
@@ -41,7 +42,7 @@ reflect.makeFuncStub:
 	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
 #endif
 
-	leal	8(%ebp), %eax	# Set esp field in struct.
+	leal	8(%ebp), %eax	/* Set esp field in struct.  */
 	movl	%eax, -24(%ebp)
 
 #ifdef __PIC__
@@ -61,14 +62,14 @@ reflect.makeFuncStub:
 	call	reflect.MakeFuncStubGo
 #endif
 
-	# Set return registers.
+	/* Set return registers.  */
 
 	movl	-20(%ebp), %eax
 	fldl	-16(%ebp)
 
 #ifdef __SSE2__
-	# In case we are compiling with -msseregparm.  This won't work
-	# correctly if only SSE1 is supported, but that seems unlikely.
+	/* In case we are compiling with -msseregparm.  This won't work
+	   correctly if only SSE1 is supported, but that seems unlikely.  */
 	movsd	-16(%ebp), %xmm0
 #endif
 

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: libgo patch committed: Implement reflect.MakeFunc for 386

2013-10-07 Thread Ian Lance Taylor
On Mon, Oct 7, 2013 at 5:24 AM, Rainer Orth r...@cebitec.uni-bielefeld.de 
wrote:

 Unfortunately, Solaris 9 testing with Sun as revealed two problems: that
 assembler cannot handle either # comments or .global instead of .globl.
 The following patch fixes this and allows makefunc_386.S to assemble.
 Also compiled with a gas build to make nothing broke there.

Thanks.  Committed to mainline and 4.8 branch.

Ian


Re: libgo patch committed: Implement reflect.MakeFunc for 386

2013-10-02 Thread Rainer Orth
Ian Lance Taylor i...@google.com writes:

 On Mon, Sep 30, 2013 at 7:07 AM, Rainer Orth
 r...@cebitec.uni-bielefeld.de wrote:
 Ian Lance Taylor i...@google.com writes:

 On Mon, Sep 30, 2013 at 6:07 AM, Rainer Orth
 r...@cebitec.uni-bielefeld.de wrote:
 Ian Lance Taylor i...@google.com writes:

 Following up on my earlier patch, this patch implements the
 reflect.MakeFunc function for 386.

 Tom Tromey pointed out to me that the libffi closure support can
 probably be used for this.  I was not aware of that support.  It
 supports a lot more processors, and I should probably start using it.
 The approach I am using does have a couple of advantages: it's more
 efficient, and it doesn't require any type of writable executable
 memory.  I can get away with that because indirect calls in Go always
 pass a closure value.  So even when and if I do change to using libffi,
 I might still keep this code for amd64 and 386.

 Unfortunately, this patch (and undoubtedly the corresponding amd64 one)
 break Solaris/x86 libgo bootstrap with native as:

 Unfortunately I think I'll have to somehow disable this functionality
 on systems with assemblers that do not understand the .cfi directives,
 as otherwise calling panic in a function created with MakeFunc will
 not work.

 Alternatively, one could hand-craft the .eh_frame section for such
 systems along the lines of libffi/src/x86/sysv.S: ugly, but doable.

 Yeah.  I'm not going to do that myself.  But I would be happy to
 approve a patch for that if somebody else wants to write it.

Here's what I came up with.  As I said, it is inspired by the libffi
code, but a bit simplified since e.g. stuff like no .ascii support
aren't relevant on the Solaris versions supported on mainline and 4.8
branch.

Bootstrapped on x86_64-unknown-linux-gnu and i386-pc-solaris2.10 with
Sun as and gas.  I've also compared the readelf --debug-dump=frames
output for the 32 and 64-bit makefunc.o, both PIC and non-PIC.  64-bit
is completely unchanged, while for 32-bit there are FDE encoding changes
as expected from the FDE_ENCODING/FDE_ENCODE macros.

Rainer


2013-10-01  Rainer Orth  r...@cebitec.uni-bielefeld.de

* configure.ac (libgo_cv_ro_eh_frame): New test.
(libgo_cv_as_comdat_gnu): Likewise.
(libgo_cv_as_x86_pcrel): Likewise.
(libgo_cv_as_x86_64_unwind_section_type): Likewise.
* configure: Regenerate.
* config.h.in: Regenerate.
* go/reflect/makefunc_386.S: Replace CFI directives by hand-coded
.eh_frame section.
Restrict .note.* sections to Linux.
* go/reflect/makefunc_amd64.S: Likewise.

# HG changeset patch
# Parent afdb60d4178e74141fa8d3ad8dfd756d009a209c
Avoid CFI directives in makefunc_*.S

diff --git a/libgo/configure.ac b/libgo/configure.ac
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -757,6 +757,68 @@ if test $libgo_cv_lib_setcontext_clobbe
 	[Define if setcontext clobbers TLS variables])
 fi
 
+AC_CACHE_CHECK([whether .eh_frame section should be read-only],
+libgo_cv_ro_eh_frame, [
+libgo_cv_ro_eh_frame=no
+echo 'extern void foo (void); void bar (void) { foo (); foo (); }'  conftest.c
+if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c  /dev/null 21; then
+  if grep '.section.*eh_frame.*a' conftest.s  /dev/null; then
+libgo_cv_ro_eh_frame=yes
+  elif grep '.section.*eh_frame.*#alloc' conftest.c \
+   | grep -v '#write'  /dev/null; then
+libgo_cv_ro_eh_frame=yes
+  fi
+fi
+rm -f conftest.*
+])
+if test x$libgo_cv_ro_eh_frame = xyes; then
+  AC_DEFINE(EH_FRAME_FLAGS, a,
+	[Define to the flags needed for the .section .eh_frame directive.])
+else
+  AC_DEFINE(EH_FRAME_FLAGS, aw,
+	[Define to the flags needed for the .section .eh_frame directive.])
+fi
+
+AC_CACHE_CHECK([if assembler supports GNU comdat group syntax],
+libgo_cv_as_comdat_gnu, [
+echo '.section .text,axG,@progbits,.foo,comdat'  conftest.s
+if $CC $CFLAGS -c conftest.s  /dev/null 21; then
+  libgo_cv_as_comdat_gnu=yes
+else
+  libgo_cv_as_comdat_gnu=no
+fi
+])
+if test x$libgo_cv_as_comdat_gnu = xyes; then
+  AC_DEFINE(HAVE_AS_COMDAT_GAS, 1,
+	[Define if your assembler supports GNU comdat group syntax.])
+fi
+
+AC_CACHE_CHECK([assembler supports pc related relocs],
+libgo_cv_as_x86_pcrel, [
+libgo_cv_as_x86_pcrel=yes
+echo '.text; foo: nop; .data; .long foo-.; .text'  conftest.s
+if $CC $CFLAGS -c conftest.s 21 | $EGREP -i 'illegal|warning'  /dev/null; then
+libgo_cv_as_x86_pcrel=no
+fi
+])
+if test x$libgo_cv_as_x86_pcrel = xyes; then
+  AC_DEFINE(HAVE_AS_X86_PCREL, 1,
+	[Define if your assembler supports PC relative relocs.])
+fi
+
+AC_CACHE_CHECK([assembler supports unwind section type],
+libgo_cv_as_x86_64_unwind_section_type, [
+libgo_cv_as_x86_64_unwind_section_type=yes
+echo '.section .eh_frame,a,@unwind'  conftest.s
+if $CC $CFLAGS -c conftest.s 21 | grep -i warning  /dev/null; then
+libgo_cv_as_x86_64_unwind_section_type=no
+fi
+])
+if test 

Re: libgo patch committed: Implement reflect.MakeFunc for 386

2013-10-02 Thread Ian Lance Taylor
On Wed, Oct 2, 2013 at 7:45 AM, Rainer Orth r...@cebitec.uni-bielefeld.de 
wrote:

 Here's what I came up with.  As I said, it is inspired by the libffi
 code, but a bit simplified since e.g. stuff like no .ascii support
 aren't relevant on the Solaris versions supported on mainline and 4.8
 branch.

 Bootstrapped on x86_64-unknown-linux-gnu and i386-pc-solaris2.10 with
 Sun as and gas.  I've also compared the readelf --debug-dump=frames
 output for the 32 and 64-bit makefunc.o, both PIC and non-PIC.  64-bit
 is completely unchanged, while for 32-bit there are FDE encoding changes
 as expected from the FDE_ENCODING/FDE_ENCODE macros.

 Rainer


 2013-10-01  Rainer Orth  r...@cebitec.uni-bielefeld.de

 * configure.ac (libgo_cv_ro_eh_frame): New test.
 (libgo_cv_as_comdat_gnu): Likewise.
 (libgo_cv_as_x86_pcrel): Likewise.
 (libgo_cv_as_x86_64_unwind_section_type): Likewise.
 * configure: Regenerate.
 * config.h.in: Regenerate.
 * go/reflect/makefunc_386.S: Replace CFI directives by hand-coded
 .eh_frame section.
 Restrict .note.* sections to Linux.
 * go/reflect/makefunc_amd64.S: Likewise.

Great, thanks for working on this.  Committed to trunk and 4.8 branch.

Ian


Re: libgo patch committed: Implement reflect.MakeFunc for 386

2013-09-30 Thread Rainer Orth
Ian Lance Taylor i...@google.com writes:

 Following up on my earlier patch, this patch implements the
 reflect.MakeFunc function for 386.

 Tom Tromey pointed out to me that the libffi closure support can
 probably be used for this.  I was not aware of that support.  It
 supports a lot more processors, and I should probably start using it.
 The approach I am using does have a couple of advantages: it's more
 efficient, and it doesn't require any type of writable executable
 memory.  I can get away with that because indirect calls in Go always
 pass a closure value.  So even when and if I do change to using libffi,
 I might still keep this code for amd64 and 386.

Unfortunately, this patch (and undoubtedly the corresponding amd64 one)
break Solaris/x86 libgo bootstrap with native as:

Assembler: 
/var/tmp//cctly9hk.s, line 8 : Illegal mnemonic
Near line:  .cfi_startproc
/var/tmp//cctly9hk.s, line 8 : Syntax error
Near line:  .cfi_startproc
/var/tmp//cctly9hk.s, line 21 : Illegal mnemonic
Near line:  .cfi_def_cfa_offset 8
/var/tmp//cctly9hk.s, line 21 : Syntax error
Near line:  .cfi_def_cfa_offset 8
/var/tmp//cctly9hk.s, line 22 : Illegal mnemonic
Near line:  .cfi_offset %ebp, -8
/var/tmp//cctly9hk.s, line 22 : Syntax error
Near line:  .cfi_offset %ebp, -8
/var/tmp//cctly9hk.s, line 24 : Illegal mnemonic
Near line:  .cfi_def_cfa_register %ebp
/var/tmp//cctly9hk.s, line 24 : Syntax error
Near line:  .cfi_def_cfa_register %ebp
/var/tmp//cctly9hk.s, line 27 : Illegal mnemonic
Near line:  .cfi_offset %ebx, -12
/var/tmp//cctly9hk.s, line 27 : Syntax error
Near line:  .cfi_offset %ebx, -12
/var/tmp//cctly9hk.s, line 45 : Illegal mnemonic
Near line:  .cfi_restore %ebx
/var/tmp//cctly9hk.s, line 45 : Syntax error
Near line:  .cfi_restore %ebx
/var/tmp//cctly9hk.s, line 47 : Illegal mnemonic
Near line:  .cfi_restore %ebp
/var/tmp//cctly9hk.s, line 47 : Syntax error
Near line:  .cfi_restore %ebp
/var/tmp//cctly9hk.s, line 48 : Illegal mnemonic
Near line:  .cfi_def_cfa %esp, 4
/var/tmp//cctly9hk.s, line 48 : Syntax error
Near line:  .cfi_def_cfa %esp, 4
/var/tmp//cctly9hk.s, line 50 : Illegal mnemonic
Near line:  .cfi_endproc
/var/tmp//cctly9hk.s, line 50 : Syntax error
Near line:  .cfi_endproc
/var/tmp//cctly9hk.s, line 52 : Invalid section attribute
/var/tmp//cctly9hk.s, line 52 : Syntax error
Near line:  .section 
.text.__x86.get_pc_thunk.bx,axG,@progbits,__x86.get_pc_thunk.bx,comdat
/var/tmp//cctly9hk.s, line 57 : Illegal mnemonic
Near line:  .cfi_startproc
/var/tmp//cctly9hk.s, line 57 : Syntax error
Near line:  .cfi_startproc
/var/tmp//cctly9hk.s, line 60 : Illegal mnemonic
Near line:  .cfi_endproc
/var/tmp//cctly9hk.s, line 60 : Syntax error
Near line:  .cfi_endproc
/var/tmp//cctly9hk.s, line 62 : Syntax error
Near line:  .section .note.GNU-stack,,@progbits
/var/tmp//cctly9hk.s, line 63 : Syntax error
Near line:  .section .note.GNU-split-stack,,@progbits
/var/tmp//cctly9hk.s, line 64 : Syntax error
Near line:  .section .note.GNU-no-split-stack,,@progbits
make[4]: *** [reflect/makefunc.lo] Error 1

AFAICS, this is just the .cfi_* directives and empty section flags.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: libgo patch committed: Implement reflect.MakeFunc for 386

2013-09-30 Thread Ian Lance Taylor
On Mon, Sep 30, 2013 at 6:07 AM, Rainer Orth
r...@cebitec.uni-bielefeld.de wrote:
 Ian Lance Taylor i...@google.com writes:

 Following up on my earlier patch, this patch implements the
 reflect.MakeFunc function for 386.

 Tom Tromey pointed out to me that the libffi closure support can
 probably be used for this.  I was not aware of that support.  It
 supports a lot more processors, and I should probably start using it.
 The approach I am using does have a couple of advantages: it's more
 efficient, and it doesn't require any type of writable executable
 memory.  I can get away with that because indirect calls in Go always
 pass a closure value.  So even when and if I do change to using libffi,
 I might still keep this code for amd64 and 386.

 Unfortunately, this patch (and undoubtedly the corresponding amd64 one)
 break Solaris/x86 libgo bootstrap with native as:

Unfortunately I think I'll have to somehow disable this functionality
on systems with assemblers that do not understand the .cfi directives,
as otherwise calling panic in a function created with MakeFunc will
not work.

Ian


Re: libgo patch committed: Implement reflect.MakeFunc for 386

2013-09-30 Thread Rainer Orth
Ian Lance Taylor i...@google.com writes:

 On Mon, Sep 30, 2013 at 6:07 AM, Rainer Orth
 r...@cebitec.uni-bielefeld.de wrote:
 Ian Lance Taylor i...@google.com writes:

 Following up on my earlier patch, this patch implements the
 reflect.MakeFunc function for 386.

 Tom Tromey pointed out to me that the libffi closure support can
 probably be used for this.  I was not aware of that support.  It
 supports a lot more processors, and I should probably start using it.
 The approach I am using does have a couple of advantages: it's more
 efficient, and it doesn't require any type of writable executable
 memory.  I can get away with that because indirect calls in Go always
 pass a closure value.  So even when and if I do change to using libffi,
 I might still keep this code for amd64 and 386.

 Unfortunately, this patch (and undoubtedly the corresponding amd64 one)
 break Solaris/x86 libgo bootstrap with native as:

 Unfortunately I think I'll have to somehow disable this functionality
 on systems with assemblers that do not understand the .cfi directives,
 as otherwise calling panic in a function created with MakeFunc will
 not work.

Alternatively, one could hand-craft the .eh_frame section for such
systems along the lines of libffi/src/x86/sysv.S: ugly, but doable.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: libgo patch committed: Implement reflect.MakeFunc for 386

2013-09-30 Thread Ian Lance Taylor
On Mon, Sep 30, 2013 at 7:07 AM, Rainer Orth
r...@cebitec.uni-bielefeld.de wrote:
 Ian Lance Taylor i...@google.com writes:

 On Mon, Sep 30, 2013 at 6:07 AM, Rainer Orth
 r...@cebitec.uni-bielefeld.de wrote:
 Ian Lance Taylor i...@google.com writes:

 Following up on my earlier patch, this patch implements the
 reflect.MakeFunc function for 386.

 Tom Tromey pointed out to me that the libffi closure support can
 probably be used for this.  I was not aware of that support.  It
 supports a lot more processors, and I should probably start using it.
 The approach I am using does have a couple of advantages: it's more
 efficient, and it doesn't require any type of writable executable
 memory.  I can get away with that because indirect calls in Go always
 pass a closure value.  So even when and if I do change to using libffi,
 I might still keep this code for amd64 and 386.

 Unfortunately, this patch (and undoubtedly the corresponding amd64 one)
 break Solaris/x86 libgo bootstrap with native as:

 Unfortunately I think I'll have to somehow disable this functionality
 on systems with assemblers that do not understand the .cfi directives,
 as otherwise calling panic in a function created with MakeFunc will
 not work.

 Alternatively, one could hand-craft the .eh_frame section for such
 systems along the lines of libffi/src/x86/sysv.S: ugly, but doable.

Yeah.  I'm not going to do that myself.  But I would be happy to
approve a patch for that if somebody else wants to write it.

Ian


libgo patch committed: Implement reflect.MakeFunc for 386

2013-09-27 Thread Ian Lance Taylor
Following up on my earlier patch, this patch implements the
reflect.MakeFunc function for 386.

Tom Tromey pointed out to me that the libffi closure support can
probably be used for this.  I was not aware of that support.  It
supports a lot more processors, and I should probably start using it.
The approach I am using does have a couple of advantages: it's more
efficient, and it doesn't require any type of writable executable
memory.  I can get away with that because indirect calls in Go always
pass a closure value.  So even when and if I do change to using libffi,
I might still keep this code for amd64 and 386.

Anyhow, for this patch, bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and 4.8 branch.

Ian

diff -r 14a32fb52e24 libgo/Makefile.am
--- a/libgo/Makefile.am	Fri Sep 27 10:46:09 2013 -0700
+++ b/libgo/Makefile.am	Fri Sep 27 14:30:27 2013 -0700
@@ -901,10 +901,17 @@
 go_reflect_makefunc_s_file = \
 	go/reflect/makefunc_amd64.S
 else
+if LIBGO_IS_386
+go_reflect_makefunc_file = \
+	go/reflect/makefuncgo_386.go
+go_reflect_makefunc_s_file = \
+	go/reflect/makefunc_386.S
+else
 go_reflect_makefunc_file =
 go_reflect_makefunc_s_file = \
 	go/reflect/makefunc_dummy.c
 endif
+endif
 
 go_reflect_files = \
 	go/reflect/deepequal.go \
diff -r 14a32fb52e24 libgo/go/reflect/all_test.go
--- a/libgo/go/reflect/all_test.go	Fri Sep 27 10:46:09 2013 -0700
+++ b/libgo/go/reflect/all_test.go	Fri Sep 27 14:30:27 2013 -0700
@@ -1432,7 +1432,7 @@
 
 func TestMakeFunc(t *testing.T) {
 	switch runtime.GOARCH {
-	case amd64:
+	case amd64, 386:
 	default:
 		t.Skip(MakeFunc not implemented for  + runtime.GOARCH)
 	}
diff -r 14a32fb52e24 libgo/go/reflect/makefunc.go
--- a/libgo/go/reflect/makefunc.go	Fri Sep 27 10:46:09 2013 -0700
+++ b/libgo/go/reflect/makefunc.go	Fri Sep 27 14:30:27 2013 -0700
@@ -47,7 +47,7 @@
 	}
 
 	switch runtime.GOARCH {
-	case amd64:
+	case amd64, 386:
 	default:
 		panic(reflect.MakeFunc not implemented for  + runtime.GOARCH)
 	}
diff -r 14a32fb52e24 libgo/go/reflect/makefunc_386.S
--- /dev/null	Thu Jan 01 00:00:00 1970 +
+++ b/libgo/go/reflect/makefunc_386.S	Fri Sep 27 14:30:27 2013 -0700
@@ -0,0 +1,111 @@
+# Copyright 2013 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# MakeFunc 386 assembly code.
+
+	.global reflect.makeFuncStub
+
+#ifdef __ELF__
+	.type reflect.makeFuncStub,@function
+#endif
+
+reflect.makeFuncStub:
+	.cfi_startproc
+
+	# Go does not provide any equivalent to the regparm function
+	# attribute, so on Go we do not need to worry about passing
+	# parameters in registers.  We just pass a pointer to the
+	# arguments on the stack.
+	#
+	# We do need to pick up the return values, though, so we pass
+	# a pointer to a struct that looks like this.
+	# struct {
+	#   esp uint32		// 0x0
+	#   eax uint32		// 0x4
+	#   st0 uint64		// 0x8
+	# }
+
+	pushl	%ebp
+	.cfi_def_cfa_offset 8
+	.cfi_offset %ebp, -8
+	movl	%esp, %ebp
+	.cfi_def_cfa_register %ebp
+
+	pushl	%ebx		# In case this is PIC.
+
+	subl	$36, %esp	# Enough for args and to align stack.
+	.cfi_offset %ebx, -12
+
+#ifdef __PIC__
+	call	__x86.get_pc_thunk.bx
+	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
+#endif
+
+	leal	8(%ebp), %eax	# Set esp field in struct.
+	movl	%eax, -24(%ebp)
+
+#ifdef __PIC__
+	call	__go_get_closure@PLT
+#else
+	call	__go_get_closure
+#endif
+
+	movl	%eax, 4(%esp)
+
+	leal	-24(%ebp), %eax
+	movl	%eax, (%esp)
+
+#ifdef __PIC__
+	call	reflect.MakeFuncStubGo@PLT
+#else
+	call	reflect.MakeFuncStubGo
+#endif
+
+	# Set return registers.
+
+	movl	-20(%ebp), %eax
+	fldl	-16(%ebp)
+
+#ifdef __SSE2__
+	# In case we are compiling with -msseregparm.  This won't work
+	# correctly if only SSE1 is supported, but that seems unlikely.
+	movsd	-16(%ebp), %xmm0
+#endif
+
+	addl	$36, %esp
+	popl	%ebx
+	.cfi_restore %ebx
+	popl	%ebp
+	.cfi_restore %ebp
+	.cfi_def_cfa %esp, 4
+
+	ret
+	.cfi_endproc
+
+#ifdef __ELF__
+	.size	reflect.makeFuncStub, . - reflect.makeFuncStub
+#endif
+
+#ifdef __PIC__
+	.section	.text.__x86.get_pc_thunk.bx,axG,@progbits,__x86.get_pc_thunk.bx,comdat
+	.globl	__x86.get_pc_thunk.bx
+	.hidden	__x86.get_pc_thunk.bx
+#ifdef __ELF__
+	.type	__x86.get_pc_thunk.bx, @function
+#endif
+__x86.get_pc_thunk.bx:
+	.cfi_startproc
+	movl	(%esp), %ebx
+	ret
+	.cfi_endproc
+#ifdef __ELF__
+	.size	__x86.get_pc_thunk.bx, . - __x86.get_pc_thunk.bx
+#endif
+#endif
+
+#ifdef __ELF__
+	.section	.note.GNU-stack,,@progbits
+	.section	.note.GNU-split-stack,,@progbits
+	.section	.note.GNU-no-split-stack,,@progbits
+#endif
diff -r 14a32fb52e24 libgo/go/reflect/makefuncgo_386.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +
+++ b/libgo/go/reflect/makefuncgo_386.go	Fri Sep 27 14:30:27 2013 -0700
@@ -0,0 +1,135 @@
+// Copyright 2013 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// MakeFunc 386