[PATCH 4/7] linux: Expand internal prototypes for not-cancel.h
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Thu Jan 2 18:56:45 GMT 2025
On 31/12/24 20:13, H.J. Lu wrote:
> On Wed, Jan 1, 2025 at 4:59 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> On Wed, Jan 1, 2025 at 2:27 AM Adhemerval Zanella
>> <adhemerval.zanella@linaro.org> wrote:
>>>
>>> When building with fortify enable and with clang, internal tests
>>> that might use not-cancel fail with:
>>>
>>> ../sysdeps/unix/sysv/linux/not-cancel.h:36:10: error: reference to overloaded function could not be resolved; did you mean to call it?
>>> 36 | __typeof (open64) __open64_nocancel;
>>
>> __typeof (func) is used in many places. Is there a way to specify a specific
>> overloaded function for Clang?
>
> This is an issue only for functions with variable arguments.
> We should limit changes to these functions.
Yeah, it only affects variadic function because the way fortify is implemented
on clang is by implementing overloading wrappers for each possible signature.
I don't have a strong preference, you patch to limit to only variadic seems fine.
I will add a comment that __typeof should not be used in such cases on not-cancel
to avoid potential future issues.
>
>>> because clang fortify supports relies on function overload and
>>> by having multiple function prototypes the __typeof can not
>>> find which one to use.
>>> ---
>>> sysdeps/unix/sysv/linux/not-cancel.h | 18 +++++++++---------
>>> 1 file changed, 9 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
>>> index 12f26912d3..3a14a407f4 100644
>>> --- a/sysdeps/unix/sysv/linux/not-cancel.h
>>> +++ b/sysdeps/unix/sysv/linux/not-cancel.h
>>> @@ -30,31 +30,31 @@
>>> #include <sys/random.h>
>>>
>>> /* Non cancellable open syscall. */
>>> -__typeof (open) __open_nocancel;
>>> +int __open_nocancel (const char *, int, ...);
>>>
>>> /* Non cancellable open syscall (LFS version). */
>>> -__typeof (open64) __open64_nocancel;
>>> +int __open64_nocancel (const char *, int, ...);
>>>
>>> /* Non cancellable openat syscall. */
>>> -__typeof (openat) __openat_nocancel;
>>> +int __openat_nocancel (int, const char *, int, ...);
>>>
>>> /* Non cacellable openat syscall (LFS version). */
>>> -__typeof (openat64) __openat64_nocancel;
>>> +int __openat64_nocancel (int, const char *, int, ...);
>>>
>>> /* Non cancellable read syscall. */
>>> -__typeof (__read) __read_nocancel;
>>> +ssize_t __read_nocancel (int, void *, size_t);
>>>
>>> /* Non cancellable pread syscall (LFS version). */
>>> -__typeof (__pread64) __pread64_nocancel;
>>> +ssize_t __pread64_nocancel (int, void *, size_t, __off64_t);
>>>
>>> /* Uncancelable write. */
>>> -__typeof (__write) __write_nocancel;
>>> +ssize_t __write_nocancel (int, const void *, size_t);
>>>
>>> /* Uncancelable close. */
>>> -__typeof (__close) __close_nocancel;
>>> +int __close_nocancel (int);
>>>
>>> /* Uncancelable fcntl. */
>>> -__typeof (__fcntl) __fcntl64_nocancel;
>>> +int __fcntl64_nocancel (int, int, ...);
>>>
>>> #if IS_IN (libc) || IS_IN (rtld)
>>> hidden_proto (__open_nocancel)
>>> --
>>> 2.43.0
>>>
>>
>>
>> --
>> H.J.
>
>
>
More information about the Libc-alpha
mailing list