This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] elf: dl-minimal malloc needs to respect fundamental alignment
- From: Florian Weimer <fweimer at redhat dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 23 Jun 2016 18:25:39 +0200
- Subject: Re: [PATCH] elf: dl-minimal malloc needs to respect fundamental alignment
- Authentication-results: sourceware.org; auth=none
- References: <20160621111702 dot 39A5B402F6E95 at oldenburg dot str dot redhat dot com> <CAMe9rOpx1Vbr6_n8+SvGCe92TO5e+KdC3hNcNAN3LvfXhd79Ow at mail dot gmail dot com> <6ca009d9-433e-31f5-c3c0-c84ecc587059 at redhat dot com> <CAMe9rOpLkftyZ+4y=1E3pbrKRU-i0kE4bdQLGaCac_Q9v1cV6g at mail dot gmail dot com> <0ef86d34-0642-8e47-9fe4-dcd7638c6153 at redhat dot com> <CAMe9rOo5F4GXuh7HRUYeDh60wh6qafNtJH1xVXJREc6w4EPCiQ at mail dot gmail dot com> <7b71fba2-3afd-4eae-329e-3530cf828607 at redhat dot com> <CAMe9rOrVMtou+D-+JoNki+JHNcT8wWu0oeMOcA6nbkzORhZVww at mail dot gmail dot com>
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