summaryrefslogtreecommitdiffstats
path: root/lib/libstand
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2000-05-12 22:43:20 +0000
committerpeter <peter@FreeBSD.org>2000-05-12 22:43:20 +0000
commita07fee2cdfa426e10cc21ed8f7005c38cdc691d8 (patch)
treeba134efc778b80dac3632d0a874188982f60a062 /lib/libstand
parentb9125258de14ed1e9a7b4fff3e7ea09e81e41dfa (diff)
downloadFreeBSD-src-a07fee2cdfa426e10cc21ed8f7005c38cdc691d8.zip
FreeBSD-src-a07fee2cdfa426e10cc21ed8f7005c38cdc691d8.tar.gz
Fix the real problem that broke the Alpha loader this last week. It
was not the fault of the module code, nor FICL. The malloc code requires sbrk() to return addresses that were at least 16 byte aligned. If the Alpha loader happened to be 8 byte but not 16 byte aligned in length, then you would get a zfree() panic at startup. Incidently, this affected the i386 loader as well, and explains why the static heap changed things and why jlemon had trouble when the bss was not ending at a multiple of 8 bytes. My fix is to 16 byte align it on all arches, even though the x86 version only required 8 byte alignment (struct MemNode is smaller there). We could page align it if we wanted to be paranoid, but it isn't presently necessary.
Diffstat (limited to 'lib/libstand')
-rw-r--r--lib/libstand/sbrk.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libstand/sbrk.c b/lib/libstand/sbrk.c
index fce03cf..3263111 100644
--- a/lib/libstand/sbrk.c
+++ b/lib/libstand/sbrk.c
@@ -39,8 +39,9 @@ static void *heapbase;
void
setheap(void *base, void *top)
{
- heapbase = base;
- maxheap = top - base;
+ /* Align start address to 16 bytes for the malloc code. Sigh. */
+ heapbase = (void *)(((uintptr_t)base + 15) & ~15);
+ maxheap = top - heapbase;
}
char *
OpenPOWER on IntegriCloud