Re: [PATCH] ArmPkg/CompilerIntrinsicsLib: fix GCC8 warning for __aeabi_memcpy aliases


Michael Zimmermann
 

Hi Ard,

yes that fixes the problem too and looks much better, thx!

On Thu, Jun 7, 2018 at 9:05 AM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

On 7 June 2018 at 07:47, Michael Zimmermann <sigmaepsilon92@gmail.com> wrote:
This was the warning(shown for __aeabi_memcpy, __aeabi_memcpy4 and __aeabi_memcpy8):
ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c:42:6: error: '__aeabi_memcpy8' alias between functions of incompatible types 'void(void
*, const void *, size_t)' {aka 'void(void *, const void *, unsigned int)'} and 'void *(void *, const void *, size_t)' {aka 'void
*(void *, const void *, unsigned int)'} [-Werror=attribute-alias]
void __aeabi_memcpy8(void *dest, const void *src, size_t n);
^~~~~~~~~~~~~~~
ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c:19:7: note: aliased declaration here
void *__memcpy(void *dest, const void *src, size_t n)

The problem is the different return type(void vs void*).
This commit adds a wrapper '__aeabi___memcpy' with a void return value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
---
ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
index a944e00b89e1..507234186fa9 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
@@ -31,14 +31,19 @@ __attribute__((__alias__("__memcpy")))
void *memcpy(void *dest, const void *src, size_t n);

#ifdef __arm__
+static __attribute__((__used__))
+void __aeabi___memcpy(void *dest, const void *src, size_t n)
+{
+ __memcpy(dest, src, n);
+}

-__attribute__((__alias__("__memcpy")))
+__attribute__((__alias__("__aeabi___memcpy")))
void __aeabi_memcpy(void *dest, const void *src, size_t n);

-__attribute__((__alias__("__memcpy")))
+__attribute__((__alias__("__aeabi___memcpy")))
void __aeabi_memcpy4(void *dest, const void *src, size_t n);

-__attribute__((__alias__("__memcpy")))
+__attribute__((__alias__("__aeabi___memcpy")))
void __aeabi_memcpy8(void *dest, const void *src, size_t n);

#endif
Thanks Michael.

Would this fix the problem as well?

--- a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
@@ -16,20 +16,21 @@
typedef __SIZE_TYPE__ size_t;

static __attribute__((__used__))
-void *__memcpy(void *dest, const void *src, size_t n)
+void __memcpy(void *dest, const void *src, size_t n)
{
unsigned char *d = dest;
unsigned char const *s = src;

while (n--)
*d++ = *s++;
+}

+void *memcpy(void *dest, const void *src, size_t n)
+{
+ __memcpy(dest, src, n);
return dest;
}

-__attribute__((__alias__("__memcpy")))
-void *memcpy(void *dest, const void *src, size_t n);
-
#ifdef __arm__

__attribute__((__alias__("__memcpy")))

Join devel@edk2.groups.io to automatically receive all group messages.