[U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS

Remy Bohmer linux at bohmer.net
Thu Jan 27 18:53:37 CET 2011


Hi,

2011/1/6 Nobuhiro Iwamatsu <iwamatsu at nigauri.org>:
> Linker needs to use the proper endian/bfd flags even when doing partial linking.
> LDFLAGS_u-boot sets linker option which is called it when U-boot is built
> (u-boot final).
> LDFLAGS sets necessary option by partial linking (use in cmd_link_o_target).
>
> CC: Mike Frysinger <vapier at gentoo.org>
> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
> ---

This patch breaks compilation for some ARM based boards, I get for
example this error:
===============================================================
make -C examples/standalone all
make[1]: Entering directory `/home/bohm/Workarea/u-boot/examples/standalone'
arm-none-eabi-gcc  -g  -Os   -fno-common -ffixed-r8 -msoft-float
-D__KERNEL__ -DCONFIG_SYS_TEXT_BASE=0x23f00000
-I/home/bohm/Workarea/u-boot/include -fno-builtin -ffreestanding
-nostdinc -isystem
/home/bohm/x-tools/CodeSourcery/arm-2009q1/bin/../lib/gcc/arm-none-eabi/4.3.3/include
-pipe  -DCONFIG_ARM -D__ARM__ -marm  -mabi=aapcs-linux
-mno-thumb-interwork -march=armv5te  -Wall -Wstrict-prototypes
-fno-stack-protector -fno-toplevel-reorder   -o hello_world.o
hello_world.c -c
arm-none-eabi-gcc  -g  -Os   -fno-common -ffixed-r8 -msoft-float
-D__KERNEL__ -DCONFIG_SYS_TEXT_BASE=0x23f00000
-I/home/bohm/Workarea/u-boot/include -fno-builtin -ffreestanding
-nostdinc -isystem
/home/bohm/x-tools/CodeSourcery/arm-2009q1/bin/../lib/gcc/arm-none-eabi/4.3.3/include
-pipe  -DCONFIG_ARM -D__ARM__ -marm  -mabi=aapcs-linux
-mno-thumb-interwork -march=armv5te  -Wall -Wstrict-prototypes
-fno-stack-protector -fno-toplevel-reorder   -o stubs.o stubs.c -c
arm-none-eabi-ld  -pie -r -o libstubs.o  stubs.o

----> arm-none-eabi-ld: -r and -shared may not be used together

make[1]: *** [libstubs.o] Error 1
make[1]: Leaving directory `/home/bohm/Workarea/u-boot/examples/standalone'
make: *** [examples/standalone] Error 2
===============================================================

It seems that the ' -pie' and '-r' flags may not be used together.

The ' -r' flag is defined at line 263 in config.mk:
cmd_link_o_target = $(if $(strip $1),\
                      $(LD) $(LDFLAGS) -r -o $@ $1,\
                      rm -f $@; $(AR) rcs $@ )

This patch now includes $(LDFLAGS) which was previously not included:
>  # Location of a usable BFD library, where we define "usable" as
> @@ -259,7 +261,7 @@ $(obj)%.s:  %.c
>
>  # If the list of objects to link is empty, just create an empty built-in.o
>  cmd_link_o_target = $(if $(strip $1),\
> -                     $(LD) -r -o $@ $1 ,\
> +                     $(LD) $(LDFLAGS) -r -o $@ $1,\
>                      rm -f $@; $(AR) rcs $@ )
>

Since it is included the following flag is added from arch/arm/config.mk:
PLATFORM_LDFLAGS += -pie

This results in the error as listed above.

Any suggestions how to fix it?

Kind regards,

Remy


More information about the U-Boot mailing list