[U-Boot] [PATCH v1] arm: keep all sections in ELF file

Albert ARIBAUD albert.u.boot at aribaud.net
Sat Dec 7 06:55:09 CET 2013


On Thu,  7 Nov 2013 14:21:46 +0100, Albert ARIBAUD
<albert.u.boot at aribaud.net> wrote:

> Current LDS files /DISCARD/ a lot of sections when linking ELF
> files, causing diagnostic tools such as readelf or objdump to
> produce partial output. Keep all section at link stage, filter
> only at objcopy time so that .bin remains minimal.
> 
> Signed-off-by: Albert ARIBAUD <albert.u.boot at aribaud.net>
> ---
> This is a repost of the previously posted RFC.
> 
> I have verified on an intermediate form of the patch (with .hash
> and .got.plt kept in place) that the change was binary invariant
> wrt master branch of ARM repo.
> 
> Please test on your HW to make sure the .bin is functional across
> a selection of boards.
> 
>  Makefile                                    |  2 +-
>  arch/arm/config.mk                          |  3 +++
>  arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds   | 16 +++++++++-------
>  arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds | 16 +++++++++-------
>  arch/arm/cpu/ixp/u-boot.lds                 | 15 +++++++++------
>  arch/arm/cpu/u-boot-spl.lds                 | 15 +++++++++------
>  arch/arm/cpu/u-boot.lds                     | 18 ++++++++++--------
>  board/actux1/u-boot.lds                     | 15 +++++++++------
>  board/actux2/u-boot.lds                     | 15 +++++++++------
>  board/actux3/u-boot.lds                     | 15 +++++++++------
>  board/dvlhost/u-boot.lds                    | 15 +++++++++------
>  board/freescale/mx31ads/u-boot.lds          | 18 +++++++++---------
>  board/ti/am335x/u-boot.lds                  | 15 +++++++++------
>  board/vpac270/u-boot-spl.lds                | 18 +++++++++---------
>  14 files changed, 113 insertions(+), 83 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index dc04179..4720db5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -428,7 +428,7 @@ $(obj)u-boot.hex:	$(obj)u-boot
>  		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
>  
>  $(obj)u-boot.srec:	$(obj)u-boot
> -		$(OBJCOPY) -O srec $< $@
> +		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
>  
>  $(obj)u-boot.bin:	$(obj)u-boot
>  		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
> diff --git a/arch/arm/config.mk b/arch/arm/config.mk
> index bdabcf4..fd3e5fb 100644
> --- a/arch/arm/config.mk
> +++ b/arch/arm/config.mk
> @@ -103,3 +103,6 @@ ALL-y += checkarmreloc
>  # such usage by requiring word relocations.
>  PLATFORM_CPPFLAGS += $(call cc-option, -mword-relocations)
>  endif
> +
> +# limit ourselves to the sections we want in the .bin.
> +OBJCFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rel.dyn
> diff --git a/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds b/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
> index 40bcc31..80fb9bd 100644
> --- a/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
> +++ b/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
> @@ -51,11 +51,13 @@ SECTIONS
>  
>  	_end = .;
>  
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynsym*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.hash*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds b/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds
> index 4927736..76b499d 100644
> --- a/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds
> +++ b/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds
> @@ -51,11 +51,13 @@ SECTIONS
>  
>  	_end = .;
>  
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynsym*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.hash*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/arch/arm/cpu/ixp/u-boot.lds b/arch/arm/cpu/ixp/u-boot.lds
> index c8d2e12..676ae2c 100644
> --- a/arch/arm/cpu/ixp/u-boot.lds
> +++ b/arch/arm/cpu/ixp/u-boot.lds
> @@ -79,10 +79,13 @@ SECTIONS
>  		KEEP(*(.__bss_end));
>  	}
>  
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds
> index 36cc54a..4880d0f 100644
> --- a/arch/arm/cpu/u-boot-spl.lds
> +++ b/arch/arm/cpu/u-boot-spl.lds
> @@ -51,12 +51,15 @@ SECTIONS
>  		__bss_end = .;
>  	}
>  
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
>  
>  #if defined(CONFIG_SPL_MAX_SIZE)
> diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds
> index 23bf030..9463a33 100644
> --- a/arch/arm/cpu/u-boot.lds
> +++ b/arch/arm/cpu/u-boot.lds
> @@ -91,12 +91,14 @@ SECTIONS
>  		KEEP(*(.__bss_end));
>  	}
>  
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> -	/DISCARD/ : { *(.ARM.exidx*) }
> -	/DISCARD/ : { *(.gnu.linkonce.armexidx.*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.hash : { *(.hash) }
> +	.got.plt : { *(.got.plt) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/board/actux1/u-boot.lds b/board/actux1/u-boot.lds
> index a656fa9..12e018f 100644
> --- a/board/actux1/u-boot.lds
> +++ b/board/actux1/u-boot.lds
> @@ -87,10 +87,13 @@ SECTIONS
>  		KEEP(*(.__bss_end));
>  	}
>  
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/board/actux2/u-boot.lds b/board/actux2/u-boot.lds
> index 7a17176..300273b 100644
> --- a/board/actux2/u-boot.lds
> +++ b/board/actux2/u-boot.lds
> @@ -87,10 +87,13 @@ SECTIONS
>  		KEEP(*(.__bss_end));
>  	}
>  
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/board/actux3/u-boot.lds b/board/actux3/u-boot.lds
> index aadfdd2..9c97c53 100644
> --- a/board/actux3/u-boot.lds
> +++ b/board/actux3/u-boot.lds
> @@ -87,10 +87,13 @@ SECTIONS
>  		KEEP(*(.__bss_end));
>  	}
>  
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/board/dvlhost/u-boot.lds b/board/dvlhost/u-boot.lds
> index 40c9c80..057d94b 100644
> --- a/board/dvlhost/u-boot.lds
> +++ b/board/dvlhost/u-boot.lds
> @@ -87,10 +87,13 @@ SECTIONS
>  		KEEP(*(.__bss_end));
>  	}
>  
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/board/freescale/mx31ads/u-boot.lds b/board/freescale/mx31ads/u-boot.lds
> index 3acc4ca..6cfca2d 100644
> --- a/board/freescale/mx31ads/u-boot.lds
> +++ b/board/freescale/mx31ads/u-boot.lds
> @@ -90,13 +90,13 @@ SECTIONS
>  		KEEP(*(.__bss_end));
>  	}
>  
> -	/DISCARD/ : { *(.bss*) }
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynsym*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.hash*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/board/ti/am335x/u-boot.lds b/board/ti/am335x/u-boot.lds
> index a173f62..9f96a43 100644
> --- a/board/ti/am335x/u-boot.lds
> +++ b/board/ti/am335x/u-boot.lds
> @@ -108,10 +108,13 @@ SECTIONS
>  		KEEP(*(.__bss_end));
>  	}
>  
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }
> diff --git a/board/vpac270/u-boot-spl.lds b/board/vpac270/u-boot-spl.lds
> index 7eac497..08c78b3 100644
> --- a/board/vpac270/u-boot-spl.lds
> +++ b/board/vpac270/u-boot-spl.lds
> @@ -62,13 +62,13 @@ SECTIONS
>  		__bss_end = .;
>  	}
>  
> -	/DISCARD/ : { *(.bss*) }
> -	/DISCARD/ : { *(.dynsym) }
> -	/DISCARD/ : { *(.dynstr*) }
> -	/DISCARD/ : { *(.dynsym*) }
> -	/DISCARD/ : { *(.dynamic*) }
> -	/DISCARD/ : { *(.hash*) }
> -	/DISCARD/ : { *(.plt*) }
> -	/DISCARD/ : { *(.interp*) }
> -	/DISCARD/ : { *(.gnu*) }
> +	.dynsym _end : { *(.dynsym) }
> +	.dynbss : { *(.dynbss) }
> +	.dynstr : { *(.dynstr*) }
> +	.dynamic : { *(.dynamic*) }
> +	.hash : { *(.hash*) }
> +	.plt : { *(.plt*) }
> +	.interp : { *(.interp*) }
> +	.gnu : { *(.gnu*) }
> +	.ARM.exidx : { *(.ARM.exidx*) }
>  }

Applied to u-boot-arm/master.

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list