This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: [gofrontend-dev] Re: [PATCH 00/13] Go closures, libffi, and the static chain
- From: Alan Modra <amodra at gmail dot com>
- To: Ian Taylor <iant at golang dot org>
- Cc: Richard Henderson <rth at redhat dot com>, "Lynn A. Boger" <laboger at linux dot vnet dot ibm dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>, libffi-discuss at sourceware dot org, "gofrontend-dev at googlegroups dot com" <gofrontend-dev at googlegroups dot com>, Ian Lance Taylor <ian at airs dot com>
- Date: Sat, 8 Nov 2014 10:24:46 +1030
- Subject: Re: [gofrontend-dev] Re: [PATCH 00/13] Go closures, libffi, and the static chain
- Authentication-results: sourceware.org; auth=none
- References: <1412973773-3942-1-git-send-email-rth at redhat dot com> <545A97BA dot 3030507 at linux dot vnet dot ibm dot com> <545B1C44 dot 3000306 at redhat dot com> <20141106124838 dot GJ30857 at bubble dot grove dot modra dot org> <545B71D1 dot 1090406 at redhat dot com> <CAOyqgcWksQ=f3ekAPFyXcAVxWeyzzcNLKnHRqFkoYWOpNmcxUw at mail dot gmail dot com> <545C770A dot 9040100 at redhat dot com> <CAOyqgcXEqWGRhm50te3mvsh=owSrUAmtrg4EKJ70f_BDBaqtOQ at mail dot gmail dot com>
On Fri, Nov 07, 2014 at 08:06:52AM -0800, Ian Taylor wrote:
> Closures exist only for nested functions and for functions created by
> reflect.MakeFunc and friends.
>
> Storing a top-level function into a variable will give you something
> that looks like it has a closure, but the closure will always be empty
> and it will never be used. The indirect call will set the closure
> value in the static chain register, but the register will not be used
> by the function being called.
Good, this was something I was still worried about, because the mere
fact that a call is indirect doesn't guarantee it won't hit a plt
stub. Many ABIs define the address of a non-local function in an
executable to be the address of the plt stub code for that function.
So it is quite possible for an indirect call to bounce through a plt
stub. Various linker optimisations make this fairly uncommon, for
instance the GNU powerpc linkers won't do this unless the function
address is taken in the executable by non-PIC (see
pointer_equality_needed in BFD code).
--
Alan Modra
Australia Development Lab, IBM
- References:
- [PATCH 00/13] Go closures, libffi, and the static chain
- Re: [PATCH 00/13] Go closures, libffi, and the static chain
- Re: [PATCH 00/13] Go closures, libffi, and the static chain
- Re: [PATCH 00/13] Go closures, libffi, and the static chain
- Re: [PATCH 00/13] Go closures, libffi, and the static chain
- Re: [gofrontend-dev] Re: [PATCH 00/13] Go closures, libffi, and the static chain
- Re: [gofrontend-dev] Re: [PATCH 00/13] Go closures, libffi, and the static chain
- Re: [gofrontend-dev] Re: [PATCH 00/13] Go closures, libffi, and the static chain