All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS
@ 2011-01-06  1:23 Nobuhiro Iwamatsu
  2011-01-07  3:40 ` Mike Frysinger
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nobuhiro Iwamatsu @ 2011-01-06  1:23 UTC (permalink / raw)
  To: u-boot

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@gentoo.org>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
---
 updated changelog.

 Makefile                  |    2 +-
 arch/blackfin/config.mk   |    3 ++-
 arch/i386/config.mk       |    3 ++-
 arch/nios2/config.mk      |    2 +-
 arch/powerpc/config.mk    |    4 ++--
 arch/sh/config.mk         |    2 +-
 arch/sh/cpu/sh2/config.mk |    4 +++-
 config.mk                 |    8 +++++---
 8 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 9055028..d6884ea 100644
--- a/Makefile
+++ b/Makefile
@@ -369,7 +369,7 @@ $(obj)u-boot.dis:	$(obj)u-boot
 GEN_UBOOT = \
 		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
 		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
-		cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
+		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \
 			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
 			-Map u-boot.map -o u-boot
 $(obj)u-boot:	depend \
diff --git a/arch/blackfin/config.mk b/arch/blackfin/config.mk
index ab117ca..0cba294 100644
--- a/arch/blackfin/config.mk
+++ b/arch/blackfin/config.mk
@@ -30,7 +30,8 @@ CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE)))
 PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic
 PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN
 
-LDFLAGS += --gc-sections -m elf32bfin
+LDFLAGS_u-boot += --gc-sections
+LDFLAGS += -m elf32bfin
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
 
 PLATFORM_CPPFLAGS += -DBFIN_CPU='"$(CONFIG_BFIN_CPU)"'
diff --git a/arch/i386/config.mk b/arch/i386/config.mk
index 8743f1a..2da1666 100644
--- a/arch/i386/config.mk
+++ b/arch/i386/config.mk
@@ -35,5 +35,6 @@ PLATFORM_CPPFLAGS += $(call cc-option, -fno-stack-protector)
 PLATFORM_CPPFLAGS += $(call cc-option, -mpreferred-stack-boundary=2)
 PLATFORM_CPPFLAGS += -DCONFIG_I386 -D__I386__
 
-LDFLAGS += --cref --gc-sections
+LDFLAGS += --cref 
+LDFLAGS_u-boot += --gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections
diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk
index aba96b3..fa93180 100644
--- a/arch/nios2/config.mk
+++ b/arch/nios2/config.mk
@@ -31,5 +31,5 @@ PLATFORM_CPPFLAGS += -G0
 
 LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds
 
-LDFLAGS += --gc-sections
+LDFLAGS_u-boot += --gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk
index 2912604..64191c7 100644
--- a/arch/powerpc/config.mk
+++ b/arch/powerpc/config.mk
@@ -24,10 +24,10 @@
 CROSS_COMPILE ?= ppc_8xx-
 
 STANDALONE_LOAD_ADDR = 0x40000
-
+LDFLAGS_u-boot = --gc-sections
 PLATFORM_RELFLAGS += -mrelocatable -ffunction-sections -fdata-sections
 PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
-PLATFORM_LDFLAGS  += -n --gc-sections
+PLATFORM_LDFLAGS  += -n
 
 ifdef CONFIG_SYS_LDSCRIPT
 # need to strip off double quotes
diff --git a/arch/sh/config.mk b/arch/sh/config.mk
index 415c949..4ef85e3 100644
--- a/arch/sh/config.mk
+++ b/arch/sh/config.mk
@@ -30,5 +30,5 @@ endif
 
 PLATFORM_CPPFLAGS += -DCONFIG_SH -D__SH__
 PLATFORM_LDFLAGS += -e $(CONFIG_SYS_TEXT_BASE) --defsym reloc_dst=$(CONFIG_SYS_TEXT_BASE)
-
+LDFLAGS_u-boot = --gc-sections
 LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds
diff --git a/arch/sh/cpu/sh2/config.mk b/arch/sh/cpu/sh2/config.mk
index 52d5a0f..f2d40aa 100644
--- a/arch/sh/cpu/sh2/config.mk
+++ b/arch/sh/cpu/sh2/config.mk
@@ -21,6 +21,8 @@
 # MA 02111-1307 USA
 #
 #
+ENDIANNESS += -EB
+
 PLATFORM_CPPFLAGS += -m3e -mb
 PLATFORM_RELFLAGS += -ffixed-r13
-PLATFORM_LDFLAGS += -EB
+PLATFORM_LDFLAGS += $(ENDIANNESS)
diff --git a/config.mk b/config.mk
index 66f8fe6..5147c35 100644
--- a/config.mk
+++ b/config.mk
@@ -204,9 +204,11 @@ endif
 
 AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
 
-LDFLAGS += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS)
+LDFLAGS += $(PLATFORM_LDFLAGS)
+
+LDFLAGS_u-boot += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS)
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
-LDFLAGS += -Ttext $(CONFIG_SYS_TEXT_BASE)
+LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
 endif
 
 # 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 $@ )
 
 #########################################################################
-- 
1.7.2.3

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

* [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS
  2011-01-06  1:23 [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS Nobuhiro Iwamatsu
@ 2011-01-07  3:40 ` Mike Frysinger
  2011-01-25 21:22 ` Wolfgang Denk
  2011-01-27 17:53 ` Remy Bohmer
  2 siblings, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2011-01-07  3:40 UTC (permalink / raw)
  To: u-boot

On Wednesday, January 05, 2011 20:23:54 Nobuhiro Iwamatsu wrote:
> --- a/arch/i386/config.mk
> +++ b/arch/i386/config.mk
> @@ -35,5 +35,6 @@ PLATFORM_CPPFLAGS += $(call cc-option,
> -fno-stack-protector) PLATFORM_CPPFLAGS += $(call cc-option,
> -mpreferred-stack-boundary=2) PLATFORM_CPPFLAGS += -DCONFIG_I386
> -D__I386__
> 
> -LDFLAGS += --cref --gc-sections
> +LDFLAGS += --cref

this adds a trailing space

otherwise, this makes Blackfin work better ... i'll s-o-b the v3 patch ;)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110106/497ed4bc/attachment.pgp 

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

* [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS
  2011-01-06  1:23 [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS Nobuhiro Iwamatsu
  2011-01-07  3:40 ` Mike Frysinger
@ 2011-01-25 21:22 ` Wolfgang Denk
  2011-01-27 17:53 ` Remy Bohmer
  2 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2011-01-25 21:22 UTC (permalink / raw)
  To: u-boot

Dear Nobuhiro Iwamatsu,

In message <1294277034-6509-1-git-send-email-iwamatsu@nigauri.org> you wrote:
> 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@gentoo.org>
> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> ---
>  updated changelog.
> 
>  Makefile                  |    2 +-
>  arch/blackfin/config.mk   |    3 ++-
>  arch/i386/config.mk       |    3 ++-
>  arch/nios2/config.mk      |    2 +-
>  arch/powerpc/config.mk    |    4 ++--
>  arch/sh/config.mk         |    2 +-
>  arch/sh/cpu/sh2/config.mk |    4 +++-
>  config.mk                 |    8 +++++---
>  8 files changed, 17 insertions(+), 11 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de

There were meetings. There were always meetings. And they were  dull,
which is part of the reason they were meetings. Dull likes company.
                                    - Terry Pratchett, _Making_Money_

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

* [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS
  2011-01-06  1:23 [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS Nobuhiro Iwamatsu
  2011-01-07  3:40 ` Mike Frysinger
  2011-01-25 21:22 ` Wolfgang Denk
@ 2011-01-27 17:53 ` Remy Bohmer
  2011-01-27 18:07   ` Remy Bohmer
  2 siblings, 1 reply; 6+ messages in thread
From: Remy Bohmer @ 2011-01-27 17:53 UTC (permalink / raw)
  To: u-boot

Hi,

2011/1/6 Nobuhiro Iwamatsu <iwamatsu@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@gentoo.org>
> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@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

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

* [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS
  2011-01-27 17:53 ` Remy Bohmer
@ 2011-01-27 18:07   ` Remy Bohmer
  2011-01-27 23:32     ` Nobuhiro Iwamatsu
  0 siblings, 1 reply; 6+ messages in thread
From: Remy Bohmer @ 2011-01-27 18:07 UTC (permalink / raw)
  To: u-boot

Hi,

2011/1/27 Remy Bohmer <linux@bohmer.net>:
> Hi,
>
> 2011/1/6 Nobuhiro Iwamatsu <iwamatsu@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@gentoo.org>
>> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
>> ---
>
> This patch breaks compilation for some ARM based boards, I get for
> example this error:

Never mind...
This patch already solves this problem:
http://comments.gmane.org/gmane.comp.boot-loaders.u-boot/93537

Kind regards,

Remy

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

* [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS
  2011-01-27 18:07   ` Remy Bohmer
@ 2011-01-27 23:32     ` Nobuhiro Iwamatsu
  0 siblings, 0 replies; 6+ messages in thread
From: Nobuhiro Iwamatsu @ 2011-01-27 23:32 UTC (permalink / raw)
  To: u-boot

Hi,

2011/1/28 Remy Bohmer <linux@bohmer.net>:
> Hi,
>
> 2011/1/27 Remy Bohmer <linux@bohmer.net>:
>> Hi,
>>
>> 2011/1/6 Nobuhiro Iwamatsu <iwamatsu@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@gentoo.org>
>>> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
>>> ---
>>
>> This patch breaks compilation for some ARM based boards, I get for
>> example this error:
>
> Never mind...
> This patch already solves this problem:
> http://comments.gmane.org/gmane.comp.boot-loaders.u-boot/93537
>

Sorry, and Thanks !

Nobuhiro



-- 
Nobuhiro Iwamatsu
?? iwamatsu at {nigauri.org / debian.org}
?? GPG ID: 40AD1FA6

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

end of thread, other threads:[~2011-01-27 23:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-06  1:23 [U-Boot] [PATCH v2] Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS Nobuhiro Iwamatsu
2011-01-07  3:40 ` Mike Frysinger
2011-01-25 21:22 ` Wolfgang Denk
2011-01-27 17:53 ` Remy Bohmer
2011-01-27 18:07   ` Remy Bohmer
2011-01-27 23:32     ` Nobuhiro Iwamatsu

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.