Commit ef23fa9b authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Implement memcpy for mini_installer

On ARM64 builds of mini_installer the compiler generates calls to
memcpy. Since we don't link mini_installer with the CRT (to guarantee
that it is kept small) we have to implement this function.

Bug: 931856
Change-Id: I3e1909b6ebf6255e0da981f20282562c33547a9b
Reviewed-on: https://chromium-review.googlesource.com/c/1476527
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#633843}
parent 02464bf7
......@@ -4,6 +4,7 @@
#include <stdint.h>
#include "build/build_config.h"
#include "chrome/installer/mini_installer/mini_installer.h"
// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
......@@ -27,6 +28,9 @@ extern "C" int WINAPI wWinMain(HINSTANCE /* instance */,
}
#endif
// We don't link with the CRT so we have to implement CRT functions that the
// compiler generates calls to.
// VC Express editions don't come with the memset CRT obj file and linking to
// the obj files between versions becomes a bit problematic. Therefore,
// simply implement memset.
......@@ -56,4 +60,22 @@ void* memset(void* dest, int c, size_t count) {
*scan++ = static_cast<uint8_t>(c);
return dest;
}
#if defined(_DEBUG) && defined(ARCH_CPU_ARM64)
// The compiler generates calls to memcpy for ARM64 debug builds so we need to
// supply a memcpy implementation in that configuration.
// See comments above for why we do this incantation.
#ifdef __clang__
__attribute__((used))
#else
#pragma function(memcpy)
#endif
void* memcpy(void* destination, const void* source, size_t count) {
auto* dst = reinterpret_cast<uint8_t*>(destination);
auto* src = reinterpret_cast<const uint8_t*>(source);
while (count--)
*dst++ = *src++;
return destination;
}
#endif
} // extern "C"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment