[PATCH] Linux: Support non-variadic calls to prctl (bug 29770)

Florian Weimer fweimer@redhat.com
Thu Nov 10 20:08:43 GMT 2022


* H. J. Lu:

> On Thu, Nov 10, 2022 at 11:18 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > prctl is an exported variadic function.  Do we need to keep it?
>>
>> Do you mean whether we should keep it as a variadic function or turn it
>> into a function with a fixed argument list?
>
> Yes.
>
>> Unfortunately the types and number of arguments vary between the
>> sub-operations.  Pretty much any application calling prctl would have to
>> be changed.  It's just syscall by another name (and with a fixed number
>> of course).
>>
>
> <sys/prctl.h> has
>
> extern int prctl (int __option, ...) __THROW;
>
> Your change works for
>
> int prctl(int option, unsigned long arg2, unsigned long arg3,
>                  unsigned long arg4, unsigned long arg5);
>
> prtcl (...);
>
> But it breaks
>
> #include <sys/prctl.h>
>
> prctl (...);

I don't think that's true for our current ABIs.  They support
unprototyped calls, and by extension this also means that calls through
a variadic prototype to a prototyped non-variadic function must work as
well.  There are other ABIs which do not work this way, but glibc hasn't
been ported to them (and it's unclear how useful they would be for
GNU/Linux).

The new C implementation is equivalent to the previous assembler
implementation.

Thanks,
Florian



More information about the Libc-alpha mailing list