From 5bc17330eb7667b96fee8baf3729c3310fa28b40 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 3 Aug 2016 16:11:01 +0200 Subject: elf: dl-minimal malloc needs to respect fundamental alignment The dynamic linker currently uses __libc_memalign for TLS-related allocations. The goal is to switch to malloc instead. If the minimal malloc follows the ABI fundamental alignment, we can assume that malloc provides this alignment, and thus skip explicit alignment in a few cases as an optimization. It was requested on libc-alpha that MALLOC_ALIGNMENT should be used, although this results in wasted space if MALLOC_ALIGNMENT is larger than the fundamental alignment. (The dynamic linker cannot assume that the non-minimal malloc will provide an alignment of MALLOC_ALIGNMENT; the ABI provides _Alignof (max_align_t) only.) --- elf/dl-minimal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'elf') diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c index c8a8f8dc93..6034b5a3fa 100644 --- a/elf/dl-minimal.c +++ b/elf/dl-minimal.c @@ -27,6 +27,7 @@ #include #include #include <_itoa.h> +#include #include @@ -90,7 +91,7 @@ __libc_memalign (size_t align, size_t n) void * weak_function malloc (size_t n) { - return __libc_memalign (sizeof (double), n); + return __libc_memalign (MALLOC_ALIGNMENT, n); } /* We use this function occasionally since the real implementation may -- cgit v1.2.3