__mempcpy inline/builtin emitting mempcpy ref

H.J. Lu hjl.tools@gmail.com
Mon Jan 6 23:42:12 GMT 2025


On Tue, Jan 7, 2025 at 7:30 AM Samuel Thibault <samuel.thibault@gnu.org> wrote:
>
> Hello,
>
> In htl/pt-alloc.c, we call __mempcpy(), but in pt-alloc.os we get an
> external ref to mempcpy, which then violates symbol exposition rules.

Does it only happen in libpthread.a?

> Apparently what is happening is that include/string.h #defines __mempcpy
> to __builtin_mempcpy, and the compiler doesn't actually inline code and
> rather emits a reference to mempcpy. Do we have a proper way to avoid
> this?
>
> #if IS_IN (libc) && !defined SHARED \
>   && !defined NO_MEMPCPY_STPCPY_REDIRECT
> /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call
>    __mempcpy and __stpcpy if not inlined.  */
> extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
>
> is done only for IS_IN (libc), should we perhaps drop that piece of the

Try this

diff --git a/include/string.h b/include/string.h
index 1f6aef9f93..b9c41b0eea 100644
--- a/include/string.h
+++ b/include/string.h
@@ -175,7 +175,7 @@ extern __typeof (strnlen) strnlen attribute_hidden;
 extern __typeof (strsep) strsep attribute_hidden;
 #endif

-#if IS_IN (libc) && !defined SHARED \
+#if (IS_IN (libc) || IS_IN (libpthread)) && !defined SHARED \
   && !defined NO_MEMPCPY_STPCPY_REDIRECT
 /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call
    __mempcpy and __stpcpy if not inlined.  */

> condition?
>
> Samuel



-- 
H.J.


More information about the Libc-alpha mailing list