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: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 23 Jun 2016 09:15:19 -0700
- 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>
On Thu, Jun 23, 2016 at 8:01 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 06/21/2016 03:20 PM, H.J. Lu wrote:
>>
>> On Tue, Jun 21, 2016 at 6:06 AM, Florian Weimer <fweimer@redhat.com>
>> wrote:
>>>
>>> On 06/21/2016 03:00 PM, H.J. Lu wrote:
>>>
>>>>> MALLOC_ALIGNMENT is potentially larger. malloc/tst-malloc-thread-fail
>>>>> tests
>>>>> for alignment. To my knowledge, it passes on all regularly tested
>>>>> architectures after commit dea39b13e2958a7f0e75b5594a06d97d61cc439f.
>>>>
>>>>
>>>>
>>>> MALLOC_ALIGNMENT is kind of mapped to the malloc alignment of
>>>> a psABI. Shouldn't ld.so malloc have the same alignment of libc malloc?
>>>
>>>
>>>
>>> I don't see why. MALLOC_ALIGNMENT has to match both the ABI constraint
>>> and
>>> the malloc/malloc.c implementation constraint (which requires a minimum
>>> alignment of 2 * sizeof (size_t)).
>>
>>
>> My understanding is since the minimum constraint of malloc alignment
>> <= ABI alignment, MALLOC_ALIGNMENT == ABI alignment. Do you
>> have a glibc platform where it isn't true?
>
>
> If I'm not mistaken, m68k has fundamental alignment 2 (the alignment of
> long, double, and long double), but our malloc still aligns to 8 (2 * sizeof
> (size_t)).
>
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.
--
H.J.