[PATCH] gold: Properly align the NT_GNU_PROPERTY_TYPE_0 note
H.J. Lu
hjl.tools@gmail.com
Fri Aug 17 15:08:00 GMT 2018
On Thu, Aug 16, 2018 at 12:21 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Aug 16, 2018 at 11:49 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 08/16/2018 07:46 PM, H.J. Lu wrote:
>>>
>>> + // The NT_GNU_PROPERTY_TYPE_0 note conforms to gABI.
>>> + const int align_size
>>> + = ((note_type == elfcpp::NT_GNU_PROPERTY_TYPE_0)
>>> + ? parameters->target().get_size()
>>> + : size);
>>
>>
>> Shouldn't the segment alignment be the same as the section alignment?
>
> It should. But gold doesn't do that. If you pass --build-id to gold,
> it will put
> 2 note sections with different alignments into the same NOTE segment:
>
> [hjl@gnu-cfl-1 gold]$ ./ld-new x.o --build-id
> [hjl@gnu-cfl-1 gold]$ readelf -l a.out
>
> Elf file type is EXEC (Executable file)
> Entry point 0x400174
> There are 4 program headers, starting at offset 64
>
> Program Headers:
> Type Offset VirtAddr PhysAddr
> FileSiz MemSiz Flags Align
> LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000
> 0x00000000000001b8 0x00000000000001b8 R E 0x1000
> LOAD 0x0000000000001000 0x0000000000401000 0x0000000000401000
> 0x0000000000000000 0x0000000000000000 RW 0x1000
> NOTE 0x0000000000000120 0x0000000000400120 0x0000000000400120
> 0x0000000000000054 0x0000000000000054 R 0x8
> GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
> 0x0000000000000000 0x0000000000000000 RW 0x10
>
> Section to Segment mapping:
> Segment Sections...
> 00 .note.gnu.property .note.gnu.build-id .text .eh_frame
> 01 .data .bss
> 02 .note.gnu.property .note.gnu.build-id
> 03
> [hjl@gnu-cfl-1 gold]$
Here is the updated patch to place note sections a PT_NOTE segment with the same
alignment.
OK for master?
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gold-Properly-align-the-NT_GNU_PROPERTY_TYPE_0-note.patch
Type: text/x-patch
Size: 7969 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180817/6a8d377c/attachment.bin>
More information about the Binutils
mailing list