[PATCH] Properly compute offsets of note descriptor and next note [BZ #22370]
H.J. Lu
hjl.tools@gmail.com
Tue Nov 28 14:45:00 GMT 2017
On Sat, Nov 25, 2017 at 8:39 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Nov 24, 2017 at 6:45 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Nov 20, 2017 at 5:04 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Thu, Nov 16, 2017 at 5:24 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Wed, Nov 15, 2017 at 3:03 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>> On Sun, Nov 12, 2017 at 8:03 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>>>>>> On Nov 12 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>>>>>>
>>>>>>> Data after Elf64_Nhdr is the "name" field which is a 4-byte string, "GNU".
>>>>>>> There is no misalignment.
>>>>>>
>>>>>> That's not what your patch does. You are aligning both the name length
>>>>>> and the data length to a 8 byte boundary, making the note size
>>>>>> unaligned.
>>>>>>
>>>>>
>>>>> You are right. Both glibc and binutils get this wrong. I opened a
>>>>> binutils bug:
>>>>>
>>>>> https://sourceware.org/bugzilla/show_bug.cgi?id=22444
>>>>>
>>>>> I will fix it first and take care of glibc next.
>>>>>
>>>>
>>>> Here is the glibc path.
>>>>
>>>> Any comments?
>>>>
>>>
>>> Any comments or objections?
>>>
>>
>> I updated Linux Extensions to gABI to clarify alignments of NOTE section
>> and segments:
>>
>> https://sourceware.org/ml/gnu-gabi/2017-q4/msg00003.html
>>
>> I will check it in next week.
>>
>
> Here is the updated patch I will check in next week. It added:
>
> + /* NB: Some PT_NOTE segment may have alignment value of 0
> + or 1. gABI specifies that PT_NOTE segments should be
> + aligned to 4 bytes in 32-bit objects and to 8 bytes in
> + 64-bit objects. As a Linux extension, we also support
> + 4 byte alignment in 64-bit objects. If p_align is less
> + than 4, we treate alignment as 4 bytes. */
> + ElfW(Addr) align = phdr[i].p_align;
> + if (align < 4)
> + align = 4;
>
> to prevent infinite loop with incorrect segment alignment.
>
This is the final patch I am checking in now. I added:
+ if (align < 4)
+ align = 4;
+ else if (align != 4 && align != 8)
+ continue;
to skip note segments which aren't aligned to 8 bytes and 4 bytes or
less.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Properly-compute-offsets-of-note-descriptor-and-next.patch
Type: application/octet-stream
Size: 8917 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20171128/92763924/attachment.obj>
More information about the Libc-alpha
mailing list