[PATCH] Make string _chk functions available for glibc tests

Sam James sam@gentoo.org
Tue Dec 17 15:05:36 GMT 2024


Sam James <sam@gentoo.org> writes:

> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> String _chk functions are exported in libc.so.6, but their prototypes
>> aren't provided since they can be used by GCC directly without prototypes.
>> But some glibc tests are using them and Clang issues an error:
>>
>> ./tst-gnuglob-skeleton.c:225:3: error: call to undeclared function '__strcpy_chk'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>>   225 |   __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX);
>>       |   ^
>>
>> Make string _chk function prototypes available for glibc tests to avoid
>> Clang error.
>
> __builtin___XXX_chk should work for Clang. But maybe it's better for us
> to do this anyway rather than relying on the GCC builtins being
> consistent.

... so OK if no objections.

>
>>
>> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
>> ---
>>  include/string.h | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/include/string.h b/include/string.h
>> index 3b4c6007d7..cfeea9a403 100644
>> --- a/include/string.h
>> +++ b/include/string.h
>> @@ -183,6 +183,8 @@ extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
>>  extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy");
>>  #endif
>>  
>> +#endif /* _ISOMAC  */
>> +
>>  extern void *__memcpy_chk (void *__restrict __dest,
>>  			   const void *__restrict __src, size_t __len,
>>  			   size_t __destlen) __THROW;
>> @@ -209,6 +211,8 @@ extern char *__strncat_chk (char *__restrict __dest,
>>  			    const char *__restrict __src,
>>  			    size_t __len, size_t __destlen) __THROW;
>>  
>> +#ifndef _ISOMAC
>> +
>>  libc_hidden_builtin_proto (__memcpy_chk)
>>  libc_hidden_builtin_proto (__memmove_chk)
>>  libc_hidden_builtin_proto (__mempcpy_chk)


More information about the Libc-alpha mailing list