[PATCH] Make string _chk functions available for glibc tests
H.J. Lu
hjl.tools@gmail.com
Tue Dec 17 22:13:44 GMT 2024
On Tue, Dec 17, 2024 at 11:05 PM Sam James <sam@gentoo.org> wrote:
>
> 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.
Let me send out v2 with __builtin___strcpy_chk.
> >
> >>
> >> 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)
--
H.J.
More information about the Libc-alpha
mailing list