From c324794cb09d0c6495992c9f6cece6e4c67f8c9f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 27 Sep 2012 17:39:41 -0700 Subject: [PATCH] libpayload: Make the symbols in memory.c weak so they can be overridden. The implementations for various stdlib functions in libc/memory.c are very generic and should work under just about any circumstances. They are unfortunately also very slow. This change makes them weak symbols so that faster versions can be defined on a per architecture basis which will automatically take the place of the slow versions. Change-Id: Ia1ac90d9dcd45962b2a15f61ecc74b0a4676048d Signed-off-by: Gabe Black Reviewed-on: http://review.coreboot.org/1725 Reviewed-by: Patrick Georgi Tested-by: build bot (Jenkins) --- payloads/libpayload/libc/memory.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/payloads/libpayload/libc/memory.c b/payloads/libpayload/libc/memory.c index 4757b10596..5af85389fe 100644 --- a/payloads/libpayload/libc/memory.c +++ b/payloads/libpayload/libc/memory.c @@ -34,6 +34,9 @@ #include void *memset(void *s, int c, size_t n) + __attribute__((weak, alias("default_memset"))); + +void *default_memset(void *s, int c, size_t n) { char *os = s; @@ -44,6 +47,9 @@ void *memset(void *s, int c, size_t n) } void *memcpy(void *dst, const void *src, size_t n) + __attribute__((weak, alias("default_memcpy"))); + +void *default_memcpy(void *dst, const void *src, size_t n) { int i; void *ret = dst; @@ -62,6 +68,9 @@ void *memcpy(void *dst, const void *src, size_t n) } void *memmove(void *dst, const void *src, size_t n) + __attribute__((weak, alias("default_memmove"))); + +void *default_memmove(void *dst, const void *src, size_t n) { int i; unsigned long offs; @@ -90,7 +99,11 @@ void *memmove(void *dst, const void *src, size_t n) * @return If len is 0, return zero. If the areas match, return zero. * Otherwise return non-zero. */ + int memcmp(const void *s1, const void *s2, size_t len) + __attribute__((weak, alias("default_memcmp"))); + +int default_memcmp(const void *s1, const void *s2, size_t len) { for (; len && *(char *)s1++ == *(char *)s2++; len--) ; return len;