[PATCH u-boot v4 06/36] string: make memcpy(), memset(), memcmp() and memmove() visible for LTO

Tom Rini trini at konsulko.com
Tue May 25 02:54:42 CEST 2021


On Thu, May 20, 2021 at 01:23:55PM +0200, Marek Behún wrote:

> It seems that sometimes (happening on ARM64, for example with
> turris_mox_defconfig) GCC, when linking with LTO, changes the symbol
> names of some functions, for example 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
> 
> GCC's documentation says this about -nodefaultlibs option:
>   The compiler may generate calls to "memcmp", "memset", "memcpy" and
>   "memmove".  These entries are usually resolved by entries in libc.
>   These entry points should be supplied through some other mechanism
>   when this option is specified.
> 
> Make these functions visible by using the __used macro to avoid this
> error.
> 
> Signed-off-by: Marek Behún <marek.behun at nic.cz>
> Reviewed-by: Simon Glass <sjg at chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210524/c7f821f1/attachment.sig>


More information about the U-Boot mailing list