[CRIU] [PATCH 04/23] pie: provide own memcpy for x86
Laurent Dufour
ldufour at linux.vnet.ibm.com
Thu Oct 13 01:04:29 PDT 2016
On 12/10/2016 03:46, Kir Kolyshkin wrote:
> When compiling criu with clang, I discovered compilation fails like
> this:
>
> GEN criu/pie/restorer-blob.h
> restorer_blob: Error (compel/src/lib/handle-elf-host.c:328): Unexpected
> undefined symbol: `memcpy'. External symbol in PIE?
>
> This happens because clang emits a call to memcpy for struct
> initialization (specifically, struct vdso_symtable in vdso_proxify()).
> Naturally, as pie is complied without libc there is no memcpy()
> so "compel piegen" rightfully complains.
>
> There are a number of possible solutions to that:
> 1. Write our own vdso_init_symtable() function instead of using =
> 2. Use some compiler flags that disables using memcpy
> 3. Provide own version of memcpy
>
> Now, (1) looks ugly, (2) I was not able to find such flags. Another
> argument in favor of (3) is we already have implementation of
> builtin_memcpy() optimized for x86.
>
> The only problem is it is not named memcpy(). Using assembler file (.S)
> we can have a function with two names (entry points).
>
> For a similar issue in ppc, see commits 0570dd8 and 1ad7817. Ultimately,
> we should get rid of builtin_mem* names and just use memcpy(), memcmp()
> etc, which in case of non-libc linked objects are to be provided by us.
>
> Cc: Laurent Dufour <ldufour at linux.vnet.ibm.com>
> Cc: Cyrill Gorcunov <gorcunov at openvz.org>
> Signed-off-by: Kir Kolyshkin <kir at openvz.org>
Acked-by: Laurent Dufour <ldufour at linux.vnet.ibm.com>
More information about the CRIU
mailing list