summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2014-02-22 11:06:48 +0000
committerdavidxu <davidxu@FreeBSD.org>2014-02-22 11:06:48 +0000
commitd5fd940f42f4f9136e5b800ec08ecc05046b9012 (patch)
tree9bbedd1964210e924e99cec1459d950065df8dff /libexec
parentc917c5fba9d9696174f2d0bb435634cd8f040a3c (diff)
downloadFreeBSD-src-d5fd940f42f4f9136e5b800ec08ecc05046b9012.zip
FreeBSD-src-d5fd940f42f4f9136e5b800ec08ecc05046b9012.tar.gz
Increase alignment to size of pointer if the alignment is too small.
Some modules do not align data at least to size of pointer, they uses a smaller alignment, but our pointer should be aligned to its native boundary, otherwise on some platforms, hardware alignment checking will cause bus error.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/xmalloc.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/libexec/rtld-elf/xmalloc.c b/libexec/rtld-elf/xmalloc.c
index f8409e4..ed195df 100644
--- a/libexec/rtld-elf/xmalloc.c
+++ b/libexec/rtld-elf/xmalloc.c
@@ -73,10 +73,8 @@ malloc_aligned(size_t size, size_t align)
{
void *mem, *res;
- if (align & (sizeof(void *) -1)) {
- rtld_fdputstr(STDERR_FILENO, "Invalid alignment\n");
- _exit(1);
- }
+ if (align < sizeof(void *))
+ align = sizeof(void *);
mem = xmalloc(size + sizeof(void *) + align - 1);
res = (void *)round((uintptr_t)mem + sizeof(void *), align);
OpenPOWER on IntegriCloud