[PATCH] elf: dl-minimal malloc needs to respect fundamental alignment
Florian Weimer
fweimer@redhat.com
Thu Jun 23 16:25:00 GMT 2016
On 06/23/2016 06:15 PM, H.J. Lu wrote:
> Malloc alignment has been an isssie. GCC defines
> MALLOC_ABI_ALIGNMENT as
>
> #ifndef MALLOC_ABI_ALIGNMENT
> #define MALLOC_ABI_ALIGNMENT BITS_PER_WORD
> #endif
>
> which is incorrect for Linux and unusable:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36159
>
> I'd like to see a reasonable solution to address malloc alignment
> on Linux, not just in ld.so.
But this glibc bug is fixed:
https://sourceware.org/bugzilla/show_bug.cgi?id=6527
As far as I know, we know match or exceed the C11 max_align_t
requirements. What we cannot do is to bump max_align_t alignment
because it affects ABI. Overall, this entire concept of fundamental
alignment is somewhat ill-defined.
Over-aligned allocations with default operator new in C++ are a
different matter and require C++ ABI changes, so that the C++ runtime
can call the appropriate aligned allocation function.
There are popular interposed mallocs which do not provide sufficient
alignment, matching max_align_t, as well.
Florian
More information about the Libc-alpha
mailing list