Patchwork [U-Boot] armv7: fix linker file for newer ld support

login
register
mail settings
Submitter Alexander Holler
Date Nov. 2, 2010, 3:23 a.m.
Message ID <1288668221-3255-1-git-send-email-holler@ahsoftware.de>
Download mbox | patch
Permalink /patch/71975/
State Superseded
Headers show

Comments

Alexander Holler - Nov. 2, 2010, 3:23 a.m.
Signed-off-by: Alexander Holler <holler@ahsoftware.de>
---
 arch/arm/cpu/armv7/u-boot.lds |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
Steve Sakoman - Nov. 2, 2010, 4:05 a.m.
On Mon, Nov 1, 2010 at 8:23 PM, Alexander Holler <holler@ahsoftware.de> wrote:
> Signed-off-by: Alexander Holler <holler@ahsoftware.de>
> ---
>  arch/arm/cpu/armv7/u-boot.lds |   15 ++++++++-------
>  1 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/u-boot.lds b/arch/arm/cpu/armv7/u-boot.lds
> index 88a0fec..34e0a79 100644
> --- a/arch/arm/cpu/armv7/u-boot.lds
> +++ b/arch/arm/cpu/armv7/u-boot.lds
> @@ -54,13 +54,6 @@ SECTIONS
>                *(.data.rel.ro)
>        }
>        . = ALIGN(4);
> -       __rel_dyn_start = .;
> -       .rel.dyn : { *(.rel.dyn) }
> -       __rel_dyn_end = .;
> -
> -       __dynsym_start = .;
> -       .dynsym : { *(.dynsym) }
> -
>        __got_start = .;
>        . = ALIGN(4);
>        .got : { *(.got) }
> @@ -74,4 +67,12 @@ SECTIONS
>        __bss_start = .;
>        .bss : { *(.bss) }
>        _end = .;
> +
> +       . = ALIGN(4);
> +       __rel_dyn_start = .;
> +       .rel.dyn : { *(.rel*) }
> +       __rel_dyn_end = .;
> +
> +       __dynsym_start = .;
> +       .dynsym : { *(.dynsym) }
>  }
> --

I've been using gcc 4.3.3, so I haven't run into the issue that this
patch is attempting to fix.

I tested this patch using gcc 4.3.3, and while it produces a usable
image, it causes the size of the image to grow from 227K to 433K!

So perhaps we need a patch that uses a more restrictive wildcard.

Steve
Albert ARIBAUD - Nov. 2, 2010, 4:28 p.m.
Le 02/11/2010 14:08, Steve Sakoman a écrit :
> On Tue, Nov 2, 2010 at 12:48 AM, Albert ARIBAUD<albert.aribaud@free.fr>  wrote:
>> Le 02/11/2010 05:05, Steve Sakoman a écrit :
>>
>>> I've been using gcc 4.3.3, so I haven't run into the issue that this
>>> patch is attempting to fix.
>>>
>>> I tested this patch using gcc 4.3.3, and while it produces a usable
>>> image, it causes the size of the image to grow from 227K to 433K!
>>>
>>> So perhaps we need a patch that uses a more restrictive wildcard.
>>>
>>> Steve
>>
>> Thanks for pointing this out, Steve. That'll go into V3 of my patch set I
>> guess, as Alexander's patch derives from mine and I most probably hit the
>> same size increase issue as he does.
>>
>> Wolfgang: that may mean the tx25 config file patch is unneeded. Stay tuned.
>
> I should have stated that I was using gcc 4.3.3 and binutils 2.18.50,
> since indeed it does seem to be binutils related.
>
> I have had a couple of reports that the following patch works with
> recent gcc/binutils without increasing the size of the binary.
>
> Could others check and report results?
>
> Steve
>
>
> ARMV7: Fix build issue with recent versions of gcc/binutils
> ---
>
> diff --git a/arch/arm/cpu/armv7/u-boot.lds b/arch/arm/cpu/armv7/u-boot.lds
> index 88a0fec..e690b58 100644
> --- a/arch/arm/cpu/armv7/u-boot.lds
> +++ b/arch/arm/cpu/armv7/u-boot.lds
> @@ -55,7 +55,7 @@ SECTIONS
>   	}
>   	. = ALIGN(4);
>   	__rel_dyn_start = .;
> -	.rel.dyn : { *(.rel.dyn) }
> +	.rel.dyn : { *(.rel.*) }
>   	__rel_dyn_end = .;
>
>   	__dynsym_start = .;

Weird... This patch seems indeed more restrictive than mine, but the 
input sections collected in .rel.dyn are actually the same for both.

We can gain a bit less than 60k by overlapping .bss and .rel.dyn, but 
certainly not 200k!

OTOH, it happened during my 'cross-build' tests (using one chain's gcc 
with another chain's ld) that the resulting u-boot was drastically 
reduced; but I chalked that to my misusing of the build tools.

Steve, can you indicate which toolchain excatly exhibits the 
230k-to-430k issue, and which board I should build?

Amicalement,
Steve Sakoman - Nov. 2, 2010, 4:56 p.m.
On Tue, Nov 2, 2010 at 9:28 AM, Albert ARIBAUD <albert.aribaud@free.fr> wrote:
> Le 02/11/2010 14:08, Steve Sakoman a écrit :
>>
>> On Tue, Nov 2, 2010 at 12:48 AM, Albert ARIBAUD<albert.aribaud@free.fr>
>>  wrote:
>>>
>>> Le 02/11/2010 05:05, Steve Sakoman a écrit :
>>>
>>>> I've been using gcc 4.3.3, so I haven't run into the issue that this
>>>> patch is attempting to fix.
>>>>
>>>> I tested this patch using gcc 4.3.3, and while it produces a usable
>>>> image, it causes the size of the image to grow from 227K to 433K!
>>>>
>>>> So perhaps we need a patch that uses a more restrictive wildcard.
>>>>
>>>> Steve
>>>
>>> Thanks for pointing this out, Steve. That'll go into V3 of my patch set I
>>> guess, as Alexander's patch derives from mine and I most probably hit the
>>> same size increase issue as he does.
>>>
>>> Wolfgang: that may mean the tx25 config file patch is unneeded. Stay
>>> tuned.
>>
>> I should have stated that I was using gcc 4.3.3 and binutils 2.18.50,
>> since indeed it does seem to be binutils related.
>>
>> I have had a couple of reports that the following patch works with
>> recent gcc/binutils without increasing the size of the binary.
>>
>> Could others check and report results?
>>
>> Steve
>>
>>
>> ARMV7: Fix build issue with recent versions of gcc/binutils
>> ---
>>
>> diff --git a/arch/arm/cpu/armv7/u-boot.lds b/arch/arm/cpu/armv7/u-boot.lds
>> index 88a0fec..e690b58 100644
>> --- a/arch/arm/cpu/armv7/u-boot.lds
>> +++ b/arch/arm/cpu/armv7/u-boot.lds
>> @@ -55,7 +55,7 @@ SECTIONS
>>        }
>>        . = ALIGN(4);
>>        __rel_dyn_start = .;
>> -       .rel.dyn : { *(.rel.dyn) }
>> +       .rel.dyn : { *(.rel.*) }
>>        __rel_dyn_end = .;
>>
>>        __dynsym_start = .;
>
> Weird... This patch seems indeed more restrictive than mine, but the input
> sections collected in .rel.dyn are actually the same for both.
>
> We can gain a bit less than 60k by overlapping .bss and .rel.dyn, but
> certainly not 200k!
>
> OTOH, it happened during my 'cross-build' tests (using one chain's gcc with
> another chain's ld) that the resulting u-boot was drastically reduced; but I
> chalked that to my misusing of the build tools.
>
> Steve, can you indicate which toolchain excatly exhibits the 230k-to-430k
> issue, and which board I should build?

I used  gcc 4.3.3 and binutils 2.18.50 and built beagle and overo.

Steve
Måns Rullgård - Nov. 2, 2010, 5 p.m.
Albert ARIBAUD <albert.aribaud@free.fr> writes:

> Le 02/11/2010 14:08, Steve Sakoman a écrit :
>> On Tue, Nov 2, 2010 at 12:48 AM, Albert ARIBAUD<albert.aribaud@free.fr>  wrote:
>>> Le 02/11/2010 05:05, Steve Sakoman a écrit :
>>>
>>>> I've been using gcc 4.3.3, so I haven't run into the issue that this
>>>> patch is attempting to fix.
>>>>
>>>> I tested this patch using gcc 4.3.3, and while it produces a usable
>>>> image, it causes the size of the image to grow from 227K to 433K!
>>>>
>>>> So perhaps we need a patch that uses a more restrictive wildcard.
>>>>
>>>> Steve
>>>
>>> Thanks for pointing this out, Steve. That'll go into V3 of my patch set I
>>> guess, as Alexander's patch derives from mine and I most probably hit the
>>> same size increase issue as he does.
>>>
>>> Wolfgang: that may mean the tx25 config file patch is unneeded. Stay tuned.
>>
>> I should have stated that I was using gcc 4.3.3 and binutils 2.18.50,
>> since indeed it does seem to be binutils related.
>>
>> I have had a couple of reports that the following patch works with
>> recent gcc/binutils without increasing the size of the binary.
>>
>> Could others check and report results?
>>
>> Steve
>>
>>
>> ARMV7: Fix build issue with recent versions of gcc/binutils
>> ---
>>
>> diff --git a/arch/arm/cpu/armv7/u-boot.lds b/arch/arm/cpu/armv7/u-boot.lds
>> index 88a0fec..e690b58 100644
>> --- a/arch/arm/cpu/armv7/u-boot.lds
>> +++ b/arch/arm/cpu/armv7/u-boot.lds
>> @@ -55,7 +55,7 @@ SECTIONS
>>   	}
>>   	. = ALIGN(4);
>>   	__rel_dyn_start = .;
>> -	.rel.dyn : { *(.rel.dyn) }
>> +	.rel.dyn : { *(.rel.*) }
>>   	__rel_dyn_end = .;
>>
>>   	__dynsym_start = .;
>
> Weird... This patch seems indeed more restrictive than mine, but the 
> input sections collected in .rel.dyn are actually the same for both.
>
> We can gain a bit less than 60k by overlapping .bss and .rel.dyn, but 
> certainly not 200k!
>
> OTOH, it happened during my 'cross-build' tests (using one chain's gcc 
> with another chain's ld) that the resulting u-boot was drastically 
> reduced; but I chalked that to my misusing of the build tools.
>
> Steve, can you indicate which toolchain excatly exhibits the 
> 230k-to-430k issue, and which board I should build?

The problem is that the first patch posted here places .rel.dyn after
.bss, so when dumping u-boot.img, all of .bss is included in the file.
Keeping it before .bss allows the flat binary to omit .bss as usual.

Using the patch quoted above, I get a working u-boot from all
combinations of gcc and binutils I cared to try, including gcc
4.5-linaro with binutils 2.20.1.

Patch

diff --git a/arch/arm/cpu/armv7/u-boot.lds b/arch/arm/cpu/armv7/u-boot.lds
index 88a0fec..34e0a79 100644
--- a/arch/arm/cpu/armv7/u-boot.lds
+++ b/arch/arm/cpu/armv7/u-boot.lds
@@ -54,13 +54,6 @@  SECTIONS
 		*(.data.rel.ro)
 	}
 	. = ALIGN(4);
-	__rel_dyn_start = .;
-	.rel.dyn : { *(.rel.dyn) }
-	__rel_dyn_end = .;
-
-	__dynsym_start = .;
-	.dynsym : { *(.dynsym) }
-
 	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
@@ -74,4 +67,12 @@  SECTIONS
 	__bss_start = .;
 	.bss : { *(.bss) }
 	_end = .;
+
+	. = ALIGN(4);
+	__rel_dyn_start = .;
+	.rel.dyn : { *(.rel*) }
+	__rel_dyn_end = .;
+
+	__dynsym_start = .;
+	.dynsym : { *(.dynsym) }
 }