From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Wed, 3 Mar 2021 05:12:09 +0100 Subject: [RFC PATCH u-boot 10/12] string: make memcpy() visible to fix LTO linking errors In-Reply-To: <20210303041211.26945-1-marek.behun@nic.cz> References: <20210303041211.26945-1-marek.behun@nic.cz> Message-ID: <20210303041211.26945-11-marek.behun@nic.cz> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de It seems that sometimes (happening on ARM64, for example with turris_mox_defconfig) GCC, when linking with LTO, changes the name of lib/string.c's memcpy() function to memcpy.isra.0. This is a problem however when GCC for a code such as this: struct some_struct *info = get_some_struct(); struct some struct tmpinfo; tmpinfo = *info; emits a call to memcpy() by builtin behaviour, to copy *info to tmpinfo. This then results in the following linking error: .../lz4.c:93: undefined reference to `memcpy' .../uuid.c:206: more undefined references to `memcpy' follow Make memcpy() visible by using the __visible macro to avoid this error. Signed-off-by: Marek Beh?n --- lib/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/string.c b/lib/string.c index 73b984123d..2290af83c4 100644 --- a/lib/string.c +++ b/lib/string.c @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -529,7 +530,7 @@ void * memset(void * s,int c,size_t count) * You should not use this function to access IO space, use memcpy_toio() * or memcpy_fromio() instead. */ -void * memcpy(void *dest, const void *src, size_t count) +__visible void * memcpy(void *dest, const void *src, size_t count) { unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src; char *d8, *s8; -- 2.26.2