Hi Janneke, I propose to, instead, change mes libc to align stuff malloc returns like this:
That should fix it.
diff --git a/include/stddef.h b/include/stddef.h
index a597c9bb..a682d726 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -37,6 +37,10 @@
#endif // !__MESC__
#endif // offsetof
+/* TODO: On armhf gcc, max_align_t is 16 Byte big instead. Use that? */
+
+typedef double max_align_t;
+
#endif // ! SYSTEM_LIBC
#endif // __MES_STDDEF_H
diff --git a/lib/stdlib/malloc.c b/lib/stdlib/malloc.c
index f4be4de1..aaf99886 100644
--- a/lib/stdlib/malloc.c
+++ b/lib/stdlib/malloc.c
@@ -20,6 +20,8 @@
#include <mes/lib.h>
#include <string.h>
+#include <stddef.h>
+#include <stdint.h>
/* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same.
Therfore we cannot remove stdlib/malloc from libc_SOURCES, which is
@@ -37,6 +39,8 @@ malloc (size_t size)
{
if (!__brk)
__brk = (char *) brk (0);
+ /* align what we give back. */
+ __brk = (char*) (((uintptr_t) __brk + sizeof(max_align_t) - 1) &
-sizeof(max_align_t));
if (brk (__brk + size) == -1)
return 0;
char *p = __brk;
pgpgxAYoYNKpK.pgp
Description: OpenPGP digital signature
