arm: config: enforce -fno-pic for gcc
RFC 1/1 arm: config: enforce -fno-pic for gcc
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.
--- arch/arm/config.mk | 1 + 1 file changed, 1 insertion(+)
arch/arm/config.mk +1 -0
@@ -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.
Signature · 1 line
2.6.2
Hi Albert,
Do you have any comments on this patch?
Regards,
Peng.
Quoted 48 lines · Peng Fan
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_ABS32R_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_BRELand .got section. When linking all the built-in.o using ld, there will beR_ARM_ABS32relocation entry and .got section in the final u-boot elf image. This can not be handled by u-boot, since u-boot only expectsR_ARM_RELATIVErelocation entry.
arm-poky-linux-gnueabi-gcc-4.9 default does not enable '-fpic', so there is not .got section andR_ARM_GOT_BRELin built-in.o. And in the final u-boot elf image, all relocation entries areR_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 <[email protected]>Cc Albert Aribaud <[email protected]>---
arch/arm/config.mk| 1 +1 file changed, 1 insertion(+)arch/arm/config.mk +1
-0@@ -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.Signature · 1 line
2.6.2
Hi Albert,
Gentle ping! Sorry for missing to mail you when I sent out the patch.
Thanks,
Peng.
Quoted 62 lines · Peng Fan
Hi Albert,
Do you have any comments on this patch?
Regards,
Peng.Quoted 48 lines · Peng Fan
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_ABS32R_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_BRELand .got section. When linking all the built-in.o using ld, there will beR_ARM_ABS32relocation entry and .got section in the final u-boot elf image. This can not be handled by u-boot, since u-boot only expectsR_ARM_RELATIVErelocation entry.
arm-poky-linux-gnueabi-gcc-4.9 default does not enable '-fpic', so there is not .got section andR_ARM_GOT_BRELin built-in.o. And in the final u-boot elf image, all relocation entries areR_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 <[email protected]>Cc Albert Aribaud <[email protected]>---
arch/arm/config.mk| 1 +1 file changed, 1 insertion(+)arch/arm/config.mk +1
-0@@ -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.Signature · 1 line
2.6.2Signature · 4 lines
_______________________________________________ U-Boot mailing list U-Boot at lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Hello Peng,
Quoted 8 lines · Peng Fan
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_ABS32R_ARM_RELATIVE
"
Any idea why Android's toolchain has -fpic enabled?
Quoted 3 lines
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,
Signature · 1 line
Albert.