All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [RFC V1] arm: config: enforce -fno-pic for gcc
@ 2015-12-05  7:53 Peng Fan
  2015-12-14  7:28 ` Peng Fan
  2016-01-29 16:42 ` Albert ARIBAUD
  0 siblings, 2 replies; 4+ messages in thread
From: Peng Fan @ 2015-12-05  7:53 UTC (permalink / raw)
  To: u-boot

Android's tool chain enable the -mandroid at default.
This option will enable the -fpic, which cause uboot compilation
failure:
"
 LD      u-boot
 u-boot contains unexpected relocations: R_ARM_ABS32
 R_ARM_RELATIVE
"

In my testcase, arm-linux-androideabi-gcc-4.9 internally
enables '-fpic', so when compiling code, there will be
relocation entries using type R_ARM_GOT_BREL and .got
section. When linking all the built-in.o using ld, there
will be R_ARM_ABS32 relocation entry and .got section
in the final u-boot elf image. This can not be handled
by u-boot, since u-boot only expects R_ARM_RELATIVE
relocation entry.
arm-poky-linux-gnueabi-gcc-4.9 default does not enable '-fpic',
so there is not .got section and R_ARM_GOT_BREL in built-in.o.
And in the final u-boot elf image, all relocation entries are
R_ARM_RELATIVE.

we can pass '-fno-pic' to xxx-gcc to disable pic. whether
the toolchain internally enables or disables pic, '-fno-pic'
can work well.

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
---
 arch/arm/config.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index 0550225..2b6322a 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -106,6 +106,7 @@ 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
 
 # limit ourselves to the sections we want in the .bin.
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [RFC V1] arm: config: enforce -fno-pic for gcc
  2015-12-05  7:53 [U-Boot] [RFC V1] arm: config: enforce -fno-pic for gcc Peng Fan
@ 2015-12-14  7:28 ` Peng Fan
  2015-12-31  7:07   ` Peng Fan
  2016-01-29 16:42 ` Albert ARIBAUD
  1 sibling, 1 reply; 4+ messages in thread
From: Peng Fan @ 2015-12-14  7:28 UTC (permalink / raw)
  To: u-boot

Hi Albert,

Do you have any comments on this patch?

Regards,
Peng.

On Sat, Dec 05, 2015 at 03:53:46PM +0800, Peng Fan wrote:
>Android's tool chain enable the -mandroid at default.
>This option will enable the -fpic, which cause uboot compilation
>failure:
>"
> LD      u-boot
> u-boot contains unexpected relocations: R_ARM_ABS32
> R_ARM_RELATIVE
>"
>
>In my testcase, arm-linux-androideabi-gcc-4.9 internally
>enables '-fpic', so when compiling code, there will be
>relocation entries using type R_ARM_GOT_BREL and .got
>section. When linking all the built-in.o using ld, there
>will be R_ARM_ABS32 relocation entry and .got section
>in the final u-boot elf image. This can not be handled
>by u-boot, since u-boot only expects R_ARM_RELATIVE
>relocation entry.
>arm-poky-linux-gnueabi-gcc-4.9 default does not enable '-fpic',
>so there is not .got section and R_ARM_GOT_BREL in built-in.o.
>And in the final u-boot elf image, all relocation entries are
>R_ARM_RELATIVE.
>
>we can pass '-fno-pic' to xxx-gcc to disable pic. whether
>the toolchain internally enables or disables pic, '-fno-pic'
>can work well.
>
>Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
>Cc: Albert Aribaud <albert.u.boot@aribaud.net>
>---
> arch/arm/config.mk | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/arch/arm/config.mk b/arch/arm/config.mk
>index 0550225..2b6322a 100644
>--- a/arch/arm/config.mk
>+++ b/arch/arm/config.mk
>@@ -106,6 +106,7 @@ 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
> 
> # limit ourselves to the sections we want in the .bin.
>-- 
>2.6.2
>
>

-- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [RFC V1] arm: config: enforce -fno-pic for gcc
  2015-12-14  7:28 ` Peng Fan
@ 2015-12-31  7:07   ` Peng Fan
  0 siblings, 0 replies; 4+ messages in thread
From: Peng Fan @ 2015-12-31  7:07 UTC (permalink / raw)
  To: u-boot

Hi Albert,

Gentle ping! Sorry for missing to mail you when I sent out the patch.

Thanks,
Peng.
On Mon, Dec 14, 2015 at 03:28:56PM +0800, Peng Fan wrote:
>Hi Albert,
>
>Do you have any comments on this patch?
>
>Regards,
>Peng.
>
>On Sat, Dec 05, 2015 at 03:53:46PM +0800, Peng Fan wrote:
>>Android's tool chain enable the -mandroid at default.
>>This option will enable the -fpic, which cause uboot compilation
>>failure:
>>"
>> LD      u-boot
>> u-boot contains unexpected relocations: R_ARM_ABS32
>> R_ARM_RELATIVE
>>"
>>
>>In my testcase, arm-linux-androideabi-gcc-4.9 internally
>>enables '-fpic', so when compiling code, there will be
>>relocation entries using type R_ARM_GOT_BREL and .got
>>section. When linking all the built-in.o using ld, there
>>will be R_ARM_ABS32 relocation entry and .got section
>>in the final u-boot elf image. This can not be handled
>>by u-boot, since u-boot only expects R_ARM_RELATIVE
>>relocation entry.
>>arm-poky-linux-gnueabi-gcc-4.9 default does not enable '-fpic',
>>so there is not .got section and R_ARM_GOT_BREL in built-in.o.
>>And in the final u-boot elf image, all relocation entries are
>>R_ARM_RELATIVE.
>>
>>we can pass '-fno-pic' to xxx-gcc to disable pic. whether
>>the toolchain internally enables or disables pic, '-fno-pic'
>>can work well.
>>
>>Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
>>Cc: Albert Aribaud <albert.u.boot@aribaud.net>
>>---
>> arch/arm/config.mk | 1 +
>> 1 file changed, 1 insertion(+)
>>
>>diff --git a/arch/arm/config.mk b/arch/arm/config.mk
>>index 0550225..2b6322a 100644
>>--- a/arch/arm/config.mk
>>+++ b/arch/arm/config.mk
>>@@ -106,6 +106,7 @@ 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
>> 
>> # limit ourselves to the sections we want in the .bin.
>>-- 
>>2.6.2
>>
>>
>
>-- 
>_______________________________________________
>U-Boot mailing list
>U-Boot at lists.denx.de
>http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [RFC V1] arm: config: enforce -fno-pic for gcc
  2015-12-05  7:53 [U-Boot] [RFC V1] arm: config: enforce -fno-pic for gcc Peng Fan
  2015-12-14  7:28 ` Peng Fan
@ 2016-01-29 16:42 ` Albert ARIBAUD
  1 sibling, 0 replies; 4+ messages in thread
From: Albert ARIBAUD @ 2016-01-29 16:42 UTC (permalink / raw)
  To: u-boot

Hello Peng,

On Sat, 5 Dec 2015 15:53:46 +0800, Peng Fan <Peng.Fan@freescale.com>
wrote:
> Android's tool chain enable the -mandroid at default.
> This option will enable the -fpic, which cause uboot compilation
> failure:
> "
>  LD      u-boot
>  u-boot contains unexpected relocations: R_ARM_ABS32
>  R_ARM_RELATIVE
> "

Any idea why Android's toolchain has -fpic enabled?

> we can pass '-fno-pic' to xxx-gcc to disable pic. whether
> the toolchain internally enables or disables pic, '-fno-pic'
> can work well.

No problem apparently with this RFC. If you submit a non-RFC patch
I will apply it.

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-29 16:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-05  7:53 [U-Boot] [RFC V1] arm: config: enforce -fno-pic for gcc Peng Fan
2015-12-14  7:28 ` Peng Fan
2015-12-31  7:07   ` Peng Fan
2016-01-29 16:42 ` Albert ARIBAUD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.