This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] gold: NOLOAD behavior compatible with GNU ld.
- From: Doug Kwan (éæå) <dougkwan at google dot com>
- To: Johan Karlsson <Johan dot Karlsson at enea dot com>
- Cc: Cary Coutant <ccoutant at gmail dot com>, Binutils <binutils at sourceware dot org>, "iant at google dot com" <iant at google dot com>
- Date: Fri, 16 Oct 2015 00:13:00 -0700
- Subject: Re: [PATCH] gold: NOLOAD behavior compatible with GNU ld.
- Authentication-results: sourceware.org; auth=none
- References: <5006DF1F5103294E8DA02CC4C71B1BF80873BF3C at SESTOEX04 dot enea dot se> <CAH9SEo7BgZJLyAGDJjmBxBTYJwwqcaVDts6HHZ+5jF_aez2J=g at mail dot gmail dot com> <CAJimCsGDXs0D9LsV=N=qb6M1iKXW11cY2F9onTD+LE9YVWfNaA at mail dot gmail dot com> <CAH9SEo5aFZ4mQjZExuDQgVNebkex0a_xWsZOon3V=QxKD4hCSg at mail dot gmail dot com> <5006DF1F5103294E8DA02CC4C71B1BF808744F61 at SESTOEX04 dot enea dot se> <CAH9SEo5cqkW2fXY3RCDCm2fRMbrYS1+KgwUR5-=KQdhGHP0JDA at mail dot gmail dot com> <CAH9SEo78prUeLWAg8-w+3uv1WJpsUJcEF1YGD9m6ih-cg+rVMw at mail dot gmail dot com> <CAH9SEo4xW5wSepteRpZoCd06gJVQFcVmR6+8buCJfWjrfKEhBA at mail dot gmail dot com>
Hi
I talked to the ChromeOS toolchain folks and was told that the
currently shipping version is based on 3.x kernel. So they cannot
help us the test this patch as NOLOAD is not used.
I tried build arm kernel using latest 2.6 stable kernel version
2.6.32.68 using arm-eabi-gcc 4.8 and gold (trunk and 2.23). Both time
gold crashed due to unhandled relocation types. I tried arm-eabi-gcc
4.6 and it is still the same.
So it seems that gold has not been able to build the kernel for a
while. It is a separate issue.
Cary earlier asked what the expected behaviour was. Here is section
headers of vmlinux compiled using arm-eabi-gcc 4.8 and binutils 2.23.2
arch/arm/boot/compressed/vmlinux: file format elf32-little
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00161660 00000000 00000000 00010000 2**5
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .got 00000068 00161660 00161660 00171660 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .got.plt 0000000c 001616c8 001616c8 001716c8 2**2
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00008440 001616d4 001616d4 001716d4 2**2
ALLOC
4 .stack 00001000 00169b14 00169b14 001716d4 2**0
CONTENTS
5 .comment 0000000f 00000000 00000000 001726d4 2**0
CONTENTS, READONLY
6 .ARM.attributes 00000010 00000000 00000000 001726e3 2**0
CONTENTS, READONLY
If this patch preserves the old behaviour then it is okay. Otherwise,
I cannot tell if older kernel will boot or not.
On Tue, Oct 13, 2015 at 4:38 PM, Doug Kwan (éæå) <dougkwan@google.com> wrote:
> I talked to the Android folks and it seems that they have never used
> gold to build their kernels. I will contact the ChromeOS folks to see
> if they can help testing your patch.
>
> I did some digging and found that NOLOAD is only use in the 2.x kernels:
>
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/arch/arm/boot/compressed/vmlinux.lds.in?id=refs/tags/v2.6.32.68#n54
>
> It is used to mark the stack for the decompression. Interestingly,
> the NOLOAD keyword is removed in 3.x kernels and above.
>
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/arch/arm/boot/compressed/vmlinux.lds.in?id=b0c4d4ee4e4f13fa3f017c00319a18c1ea31b7d7
>
> So, this patch should not affect any ARM kernel 3.x or above.
>
> I tried to test this patch on my ARMv7 system but the 2.6x does not
> build with my environment. I will try another approach tomorrow.
>
> On Tue, Oct 13, 2015 at 12:41 AM, Doug Kwan (éæå) <dougkwan@google.com> wrote:
>> It seems that Android prebuilt kernel toolchain is not configured with
>> gold. Let me talk to the Android Team and see if building the kernel
>> with gold is still supported. I have not worked on Android for more
>> than a couple of years. I am not sure if we ever use gold to build
>> production Android kernel.
>>
>> On Wed, Oct 7, 2015 at 10:15 PM, Doug Kwan (éæå) <dougkwan@google.com> wrote:
>>> I can test Johan's patch and see if it build the ARM kernel.
>>>
>>> On Wed, Oct 7, 2015 at 5:49 AM, Johan Karlsson <Johan.Karlsson@enea.com> wrote:
>>>> I don't know how to build the ARM kernel so I would appreciate if someone could try it out using the patch. This patch together with the fix I did for PR 16711 greatly improves the ELF size when using NOLOAD and lots of bss.
>>>>
>>>>> From: Doug Kwan (éæå) [mailto:dougkwan@google.com]
>>>>> Sent: den 7 oktober 2015 00:26
>>>>>
>>>>> Expected behaviour was gold being able to build an ARM kernel that boots.
>>>>> The original patch was added because gold had not been able to build the
>>>>> kernel used in Android.
>>>>>
>>>>> As long as Johan can build an ARM kernel that boots with this patch. I am
>>>>> okay.
>>>>>
>>>>> On Tue, Oct 6, 2015 at 3:18 PM, Cary Coutant <ccoutant@gmail.com> wrote:
>>>>> > Based on
>>>>> >
>>>>> > https://sourceware.org/ml/binutils/2010-04/msg00094.html
>>>>> >
>>>>> > it seems to me that ripping out the original NOLOAD patch would break
>>>>> > building the ARM compressed kernel.
>>>>> >
>>>>> > Doug, do you remember what the expected behavior was at the time?
>>>>> >
>>>>> > -cary
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> > On Sun, Sep 20, 2015 at 12:54 PM, Doug Kwan (éæå)
>>>>> <dougkwan@google.com> wrote:
>>>>> >> Looks good to me. I don't have right to approve the patch though.
>>>>> >>
>>>>> >> On Thu, Sep 17, 2015 at 2:47 AM, Johan Karlsson
>>>>> <Johan.Karlsson@enea.com> wrote:
>>>>> >>> Hi all,
>>>>> >>> This patch makes gold handle the NOLOAD section attribute in the same
>>>>> way GNU ld does for elf.
>>>>> >>>
>>>>> >>> Instead of creating a SHT_PROGBITS with no flags section it creates one
>>>>> with SHT_NOBITS and SHF_ALLOC set. With this change all special handling of
>>>>> noload sections can be removed and all NOLOAD sections as handled as
>>>>> NOBITS.
>>>>> >>>
>>>>> >>> 2015-09-17 Johan Karlsson <johan.karlsson@enea.com>
>>>>> >>>
>>>>> >>> NOLOAD section attribute compatible with GNU ld.
>>>>> >>>
>>>>> >>> * layout.cc (Layout::choose_output_section): Create NOLOAD
>>>>> sections as
>>>>> >>> SHT_NOBITS and removed special handling of NOLOAD sections.
>>>>> >>> (Layout::make_output_section_for_script): Create NOLOAD as
>>>>> SHT_NOBIT
>>>>> >>> with SHF_ALLOC set.
>>>>> >>> * output.cc (Output_section::Output_section): Removed member
>>>>> is_noload.
>>>>> >>> (Output_section::do_reset_address_and_file_offset): Removed
>>>>> special
>>>>> >>> handling of NOLOAD.
>>>>> >>> * output.h (Output_section): Removed is_noload() and
>>>>> set_is_noload().
>>>>> >>> removed member is_noload_.
>>>>> >>> * script-sections.cc
>>>>> (Output_section_definition::set_section_addresses):
>>>>> >>> removed special handling of NOLOAD.
>>>>> >>> (Sort_output_sections::operator()): Removed sorting of NOLOAD
>>>>> sections.
>>>>> >>>