From: H.J. Lu Date: Wed, 1 Jan 2025 00:20:34 +0000 (+0800) Subject: Redirect mempcpy and stpcpy only in libc.a X-Git-Tag: glibc-2.41~153 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e9eea05986e4a02f1169ef0775c1d05802c5287f;p=thirdparty%2Fglibc.git Redirect mempcpy and stpcpy only in libc.a The mempcpy and stpcpy redirections to __mempcpy and __stpcpy were added by commit 939da41143341bbcdd3dd50ee7b57776603da260 Author: Joseph Myers Date: Wed Nov 12 22:36:34 2014 +0000 Fix stpcpy / mempcpy namespace (bug 17573). to fix the namespace bug since __mempcpy and __stpcpy were defined as macros in . These macros call __builtin_mempcpy and __builtin_stpcpy which may end up calling the C functions mempcpy and stpcpy. In libc.so, libc_hidden_builtin_proto ensures that calls to mempcpy and stpcpy are in turn mapped to call __GI_mempcpy and __GI_stpcpy. The redirections were applied outside of libc.so, including libc.a, to map mempcpy and stpcpy to __mempcpy and __stpcpy. Since commit 18b10de7ced9e9c3843299fb600e40b11af3e0af Author: Wilco Dijkstra Date: Mon Jun 12 15:19:38 2017 +0100 2017-06-12 Wilco Dijkstra There is no longer a need for string2.h, so remove it and all mention of it. Move the redirect for __stpcpy to include/string.h since it is still required until all internal uses have been renamed. This fixes several linknamespace/localplt failures when building with -Os. removed the __mempcpy and __stpcpy macros from the public header file, limit these redirections to libc.a to avoid Clang error: In file included from tst-iconv-sticky-input-error.c:22: In file included from ./gconv_int.h:24: ../include/string.h:182:44: error: attribute declaration must precede definition [-Werror,-Wignored-attributes] 182 | extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy"); | ^ ../string/bits/string_fortified.h:42:8: note: previous definition is here 42 | __NTH (mempcpy (void *__restrict __dest, const void *__restrict __src, | ^ when testing with Clang for fortify build. Signed-off-by: H.J. Lu Reviewed-by: Sam James --- diff --git a/include/string.h b/include/string.h index 3b4c6007d7..1f6aef9f93 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) && !defined SHARED \ && !defined NO_MEMPCPY_STPCPY_REDIRECT /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call __mempcpy and __stpcpy if not inlined. */