guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bootstrappable] Re: wip-full-source-bootstrap: from a 357-byte `hex


From: Danny Milosavljevic
Subject: Re: [bootstrappable] Re: wip-full-source-bootstrap: from a 357-byte `hex0' to 'hello'
Date: Fri, 8 Jan 2021 15:07:25 +0100

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;

Attachment: pgppgSyZ1jgtD.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]