On Sat, Apr 4, 2020 at 3:17 AM Richard Purdie
<[email protected]> wrote:
> On Fri, 2020-04-03 at 15:39 -0700, Andre McCurdy wrote:
> > On Fri, Apr 3, 2020 at 2:59 PM Richard Purdie
> > <[email protected]> wrote:
> > > ++      /* gcc magic to attempt to just pass these args to syscall.
> > > we have to
> >
> > Comment needs updating - you are calling prctl() here, not syscall().
> >
> > > ++       * guess about the number of args; the docs discuss calling
> > > conventions
> > > ++       * up to 4, so let's try that?
> >
> > The args for prctl() are option plus 4 additional arguments, so a
> > total of 5, not 4.
>
> Thanks, fixed.

It's perhaps also worth noting that it's only necessary to use
__builtin_apply_args() + __builtin_apply() when the data types of the
arguments passed to a function are not known (that was to original
argument for using them in the wrapper for syscall()). Together these
two work by saving a copy of all registers which could be used to pass
arguments (both integer and floating point) together with a chunk of
the stack used to pass arguments. Using them should be safe, but they
are gcc specific and not very efficient.

For prctl() however the data type of the arguments is known. They are
all unsigned long:

  http://man7.org/linux/man-pages/man2/prctl.2.html

Therefore a wrapper for prctl() can simply extract option + 4
additional unsigned long vargs arguments from the caller and pass them
along to the real prcrtl(). See the implementation of prctl() in musl:

  https://git.musl-libc.org/cgit/musl/tree/src/linux/prctl.c

Also, since prctl() is Linux specific, it looks like this patch will
make pseudo Linux specific. Is that OK? If so maybe worth making an
official statement that OE is only supported for Linux hosts?
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#137023): 
https://lists.openembedded.org/g/openembedded-core/message/137023
Mute This Topic: https://lists.openembedded.org/mt/72759808/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to