public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Martin Uecker <ma.uecker@gmail.com>
To: Anthony Green <green@moxielogic.com>
Cc: libffi-discuss <libffi-discuss@sourceware.org>
Subject: Re: wide function pointer type
Date: Mon, 18 Oct 2021 07:58:45 +0200	[thread overview]
Message-ID: <857da973fe5bbb94a363114262b57d42b35cc1f6.camel@gmail.com> (raw)
In-Reply-To: <bee7417a7acc67e5af8aff710a1bd55c4d6baa6b.camel@gmail.com>


I would be interested to learn about ABI issues
I might not be aware of. 

In particular, I would be good to know whether
implementing a perfectly forwarding stub for
a variadic functions that loads the static
is possible on all architectures. I assume so,
but I am not entirely sure.

If not, we might need to restrict conversion for
regular functions pointers to wide pointers to only
allow functions without variadic args, or define
a new ABI for wide pointers, but this then
partially defeats the point (on the affected
architecture).

Martin


Am Montag, den 18.10.2021, 07:33 +0200 schrieb Martin Uecker:
> Hi Anthony,
> 
> Am Sonntag, den 17.10.2021, 19:35 -0400 schrieb Anthony Green:
> > Hi Martin,
> > 
> >   I haven't read the whole proposal yet, but I'll try to this week.  I
> > did, however, read the first paragraph, and it says:  "Trying to use
> > regular function pointers for callbacks with data requires run-time
> > code generation (e.g. nested functions in GCC or XL C, and closures in
> > libffi [1]) but this is complex, inefficient, and problematic from a
> > security point of view."
> > 
> >   This is no longer true for libffi on the important Linux platforms.
> > We use static code templates that are placed in memory at a fixed,
> > predetermined distance from the data they reference.  There is no
> > runtime code generation.  Well, to be fair, perhaps it is still
> > complex, but it's far more secure than before.
> > 
> >   Thanks for sharing.  I'm not a language expert, but I know others here are.
> 
> Thank you for your comments! I had to submit this to WG14 to meet
> the deadline for C23. So the final version (so far) is here:
> 
>  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2787.pdf
> 
> Of course, it is still possible to modify the proposal later.
> 
> It is great to hear that libffi can create trampolines
> without run-time code generation! We previously discussed
> such an approach also for GCC, but nothing was implemented.
> 
> 
> Martin
> 
> 
> > AG
> > 
> > On Sun, Oct 10, 2021 at 7:32 AM Martin Uecker via Libffi-discuss
> > <libffi-discuss@sourceware.org> wrote:
> > > 
> > > Hi all,
> > > 
> > > I will propose a wide function pointer type (actually
> > > a wide function type) to WG14 for C23 as a common
> > > type for callbacks, closures, which now require an
> > > additional void pointer argument in C APIs. This
> > > is intended to be compatible with ABIs with now
> > > use a static chain register.
> > > 
> > > An early draft can be found here:
> > > 
> > > http://wwwuser.gwdg.de/~muecker1/wide_v4.pdf
> > > 
> > > 
> > > I thought you might be interested and I would love
> > > to hear your feedback.
> > > 
> > > Martin
> > > 
> > > 
> > > 


  reply	other threads:[~2021-10-18  5:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-10 11:32 Martin Uecker
2021-10-17 23:35 ` Anthony Green
2021-10-18  5:33   ` Martin Uecker
2021-10-18  5:58     ` Martin Uecker [this message]
2021-10-18  7:36       ` Florian Weimer
2021-10-18  7:56         ` Martin Uecker
2021-10-19  9:22           ` Florian Weimer
2021-10-19  9:43             ` Martin Uecker
2021-10-19 10:15               ` Florian Weimer
2021-10-19 12:13                 ` Martin Uecker
2021-10-20  8:24                   ` Kaz Kylheku (libffi)
2021-10-20 18:52                     ` Martin Uecker
2021-10-20  9:10                   ` Florian Weimer
2021-10-20  9:21                     ` Martin Uecker
2021-10-20  9:27                       ` Florian Weimer
2021-10-20 17:27                     ` Kaz Kylheku (libffi)
2021-10-21  9:48                       ` Florian Weimer
2021-10-10 17:01 Kaz Kylheku (libffi)
2021-10-10 17:44 ` Martin Uecker
2021-10-10 17:49   ` Daniel Colascione
2021-10-10 18:05     ` Martin Uecker
2021-10-10 18:17       ` Daniel Colascione
2021-10-10 18:47         ` Martin Uecker
2021-10-10 18:57           ` Daniel Colascione
2021-10-10 19:24             ` Martin Uecker
2021-10-16  8:08               ` Jarkko Hietaniemi
2021-10-16  9:35                 ` Jarkko Hietaniemi
2021-10-10 18:31   ` Kaz Kylheku (libffi)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=857da973fe5bbb94a363114262b57d42b35cc1f6.camel@gmail.com \
    --to=ma.uecker@gmail.com \
    --cc=green@moxielogic.com \
    --cc=libffi-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).