Commit f4fdfa901e6587875c9bf42dcd3367c98e6baa02

Authored by Peng Fan
Committed by guoyin.chen
1 parent badb1ea09d

MLK-11946 arm: config: disable pic when compiling code

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>

Showing 1 changed file with 1 additions and 0 deletions Side-by-side Diff

... ... @@ -106,6 +106,7 @@
106 106 # instruction. Relocation is not supported for that case, so disable
107 107 # such usage by requiring word relocations.
108 108 PLATFORM_CPPFLAGS += $(call cc-option, -mword-relocations)
  109 +PLATFORM_CPPFLAGS += $(call cc-option, -fno-pic)
109 110 endif
110 111  
111 112 # limit ourselves to the sections we want in the .bin.