diff --git a/src/boot/support.cpp b/src/boot/support.cpp index a438e91..16a97a6 100644 --- a/src/boot/support.cpp +++ b/src/boot/support.cpp @@ -17,6 +17,18 @@ void *memcpy(void *dest, const void *src, size_t n) return dest; } +/// Basic memset() implementation for clang. Clang requires freestanding code +/// implement memset(), as it may emit references to it. This basic memset is +/// not the most efficient, but will get linked if no other memcpy exists. +__attribute__ ((__weak__)) +void *memset(void *dest, int c, size_t n) +{ + uint8_t *cdest = reinterpret_cast(dest); + for (size_t i = 0; i < n; ++i) + cdest[i] = static_cast(c); + return dest; +} + int _purecall() { ::boot::error::raise(uefi::status::unsupported, L"Pure virtual call");