On 12/12/2014 12:30 PM, Andrew Haley wrote:
On 12/12/2014 10:20 AM, Florian Weimer wrote:
open is declared as:
int open(const char *pathname, int flags, ...);
The intent is to have two overloaded variants:
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
The presence of the mode argument depends on the flags specified. The
set of such flags is known by the kernel. I wish to avoid to maintain
this implementation detail in libc as well, so I want to always read the
mode argument, possibly passing a garbage value to the kernel.
Is there GCC-portable way to achieve this?
You're assuming that for all targets the varargs calling convention is
the same as the non-varargs calling convention, at least for integer
registers. I don't think this is true for all targets, although it
might be true for the targets GCC supports today.
No, I would be perfectly satisfied with calling va_arg unconditionally
to read a garbage argument if that can be made GCC-portable in some way.
The implementation can still be vararg.
(And I think we had a related conversation about this in the context of
the ppc64le bring-up, with the result that we practically need matching
calling conventions. :-/)
--
Florian Weimer / Red Hat Product Security