[U-Boot] [PATCH 2/2] arm: config: enforce -fno-pic for SPL and normal U-Boot

Tom Rini trini at konsulko.com
Mon Jul 3 16:16:56 UTC 2017


On Mon, Jul 03, 2017 at 09:14:08PM +0800, Peng Fan wrote:

> If not pass -fno-pic to toolchains, some toolchains may generate
> .got and .got.plt sections, but when generate binaries, we
> did not take .got and .got.plt into consideration, then
> SPL or normal U-Boot boot failure because image corrupted.
> 
> Need to pass -fno-pic to disable generating .got and .got.plt
> sections.
> 
> Signed-off-by: Peng Fan <peng.fan at nxp.com>
> Cc: Albert Aribaud <albert.u.boot at aribaud.net>
> Cc: Tom Rini <trini at konsulko.com>
> ---
>  arch/arm/config.mk | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/config.mk b/arch/arm/config.mk
> index 1a77779..66ae403 100644
> --- a/arch/arm/config.mk
> +++ b/arch/arm/config.mk
> @@ -130,9 +130,10 @@ ALL-y += checkarmreloc
>  # instruction. Relocation is not supported for that case, so disable
>  # such usage by requiring word relocations.
>  PLATFORM_CPPFLAGS += $(call cc-option, -mword-relocations)
> -PLATFORM_CPPFLAGS += $(call cc-option, -fno-pic)
>  endif
>  
> +PLATFORM_CPPFLAGS += $(call cc-option, -fno-pic)
> +
>  # limit ourselves to the sections we want in the .bin.
>  ifdef CONFIG_ARM64
>  OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \

Something is "up" here and I need you to dig harder and perhaps see if
we're missing something in the linker scripts?  The very next line of
context here is:
                -j .u_boot_list -j .rela.dyn -j .got -j .got.plt

Meaning that we intentionally copy .got / .got.plt into the resulting
binary.  And I see that we took in 397d7d5a1be1 from you back in 2016
saying that we needed this in SPL.  But 5a942a152776 put the got/got.plt
sections (for 32bit ARM) in intentionally as some relocations do need
it.  And in 4b0d506ed3b4 Philipp seems to have seen the same problem you
have, but fixed it with adding got/got.plt to the sections list we copy
in (the above hunk of context).

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170703/c4d28b15/attachment.sig>


More information about the U-Boot mailing list