[U-Boot] [PATCH] Introduce a new linker flag LDFLAGS_FINAL

From: Haiying Wang Haiying.Wang@freescale.com
commit 8aba9dceebb14144e07d19593111ee3a999c37fc Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS
breaks the usage of --gc-section to build nand_spl. We still need linker option --gc-section for every uboot image, not only the main one. LDFLAGS_FINAL passes the --gc-sections to each uboot image.
Signed-off-by: Scott Wood scottwood@freescale.com Signed-off-by: Haiying Wang Haiying.Wang@freescale.com --- arch/blackfin/config.mk | 2 +- arch/i386/config.mk | 2 +- arch/nios2/config.mk | 2 +- arch/powerpc/config.mk | 2 +- arch/sh/config.mk | 2 +- config.mk | 3 ++- nand_spl/board/amcc/acadia/Makefile | 4 ++-- nand_spl/board/amcc/bamboo/Makefile | 4 ++-- nand_spl/board/amcc/canyonlands/Makefile | 4 ++-- nand_spl/board/amcc/kilauea/Makefile | 4 ++-- nand_spl/board/amcc/sequoia/Makefile | 4 ++-- nand_spl/board/davinci/da8xxevm/Makefile | 4 ++-- nand_spl/board/freescale/mpc8313erdb/Makefile | 6 +++--- nand_spl/board/freescale/mpc8315erdb/Makefile | 6 +++--- nand_spl/board/freescale/mpc8536ds/Makefile | 4 ++-- nand_spl/board/freescale/mpc8569mds/Makefile | 4 ++-- nand_spl/board/freescale/mpc8572ds/Makefile | 4 ++-- nand_spl/board/freescale/mx31pdk/Makefile | 4 ++-- nand_spl/board/freescale/p1_p2_rdb/Makefile | 5 +++-- nand_spl/board/karo/tx25/Makefile | 4 ++-- nand_spl/board/samsung/smdk6400/Makefile | 4 ++-- nand_spl/board/sheldon/simpc8313/Makefile | 6 +++--- 22 files changed, 43 insertions(+), 41 deletions(-)
diff --git a/arch/blackfin/config.mk b/arch/blackfin/config.mk index 0cba294..f4503ea 100644 --- a/arch/blackfin/config.mk +++ b/arch/blackfin/config.mk @@ -30,7 +30,7 @@ CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE))) PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN
-LDFLAGS_u-boot += --gc-sections +LDFLAGS_FINAL += --gc-sections LDFLAGS += -m elf32bfin PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
diff --git a/arch/i386/config.mk b/arch/i386/config.mk index 3fb97c1..2848435 100644 --- a/arch/i386/config.mk +++ b/arch/i386/config.mk @@ -36,5 +36,5 @@ PLATFORM_CPPFLAGS += $(call cc-option, -mpreferred-stack-boundary=2) PLATFORM_CPPFLAGS += -DCONFIG_I386 -D__I386__
LDFLAGS += --cref -LDFLAGS_u-boot += --gc-sections +LDFLAGS_FINAL += --gc-sections PLATFORM_RELFLAGS += -ffunction-sections diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk index fa93180..d241a96 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_u-boot += --gc-sections +LDFLAGS_FINAL += --gc-sections PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk index 64191c7..31e4416 100644 --- a/arch/powerpc/config.mk +++ b/arch/powerpc/config.mk @@ -24,7 +24,7 @@ CROSS_COMPILE ?= ppc_8xx-
STANDALONE_LOAD_ADDR = 0x40000 -LDFLAGS_u-boot = --gc-sections +LDFLAGS_FINAL += --gc-sections PLATFORM_RELFLAGS += -mrelocatable -ffunction-sections -fdata-sections PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__ PLATFORM_LDFLAGS += -n diff --git a/arch/sh/config.mk b/arch/sh/config.mk index 4ef85e3..6318e77 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 +LDFLAGS_FINAL += --gc-sections LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds diff --git a/config.mk b/config.mk index 5147c35..caa6221 100644 --- a/config.mk +++ b/config.mk @@ -205,8 +205,9 @@ endif AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
LDFLAGS += $(PLATFORM_LDFLAGS) +LDFLAGS_FINAL += -Bstatic $(LDFLAGS)
-LDFLAGS_u-boot += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS) +LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL) ifneq ($(CONFIG_SYS_TEXT_BASE),) LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) endif diff --git a/nand_spl/board/amcc/acadia/Makefile b/nand_spl/board/amcc/acadia/Makefile index f8ca654..92ace9d 100644 --- a/nand_spl/board/amcc/acadia/Makefile +++ b/nand_spl/board/amcc/acadia/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -51,7 +51,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/amcc/bamboo/Makefile b/nand_spl/board/amcc/bamboo/Makefile index 438dfbf..abae2ae 100644 --- a/nand_spl/board/amcc/bamboo/Makefile +++ b/nand_spl/board/amcc/bamboo/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -50,7 +50,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/amcc/canyonlands/Makefile b/nand_spl/board/amcc/canyonlands/Makefile index 40034e1..d40a46d 100644 --- a/nand_spl/board/amcc/canyonlands/Makefile +++ b/nand_spl/board/amcc/canyonlands/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -55,7 +55,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/amcc/kilauea/Makefile b/nand_spl/board/amcc/kilauea/Makefile index 3835f3f..3a96e51 100644 --- a/nand_spl/board/amcc/kilauea/Makefile +++ b/nand_spl/board/amcc/kilauea/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -50,7 +50,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/amcc/sequoia/Makefile b/nand_spl/board/amcc/sequoia/Makefile index 9120f15..9022a51 100644 --- a/nand_spl/board/amcc/sequoia/Makefile +++ b/nand_spl/board/amcc/sequoia/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -50,7 +50,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/davinci/da8xxevm/Makefile b/nand_spl/board/davinci/da8xxevm/Makefile index 4cae223..6cd0f2b 100644 --- a/nand_spl/board/davinci/da8xxevm/Makefile +++ b/nand_spl/board/davinci/da8xxevm/Makefile @@ -29,7 +29,7 @@ CONFIG_NAND_SPL = y include $(TOPDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_PRELOADER -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_PRELOADER -DCONFIG_NAND_SPL
@@ -56,7 +56,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/freescale/mpc8313erdb/Makefile b/nand_spl/board/freescale/mpc8313erdb/Makefile index cf81099..5565a89 100644 --- a/nand_spl/board/freescale/mpc8313erdb/Makefile +++ b/nand_spl/board/freescale/mpc8313erdb/Makefile @@ -28,8 +28,8 @@ PAD_TO := 0xfff04000 include $(TOPDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds \ - -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds \ + -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -55,7 +55,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/freescale/mpc8315erdb/Makefile b/nand_spl/board/freescale/mpc8315erdb/Makefile index cf81099..5565a89 100644 --- a/nand_spl/board/freescale/mpc8315erdb/Makefile +++ b/nand_spl/board/freescale/mpc8315erdb/Makefile @@ -28,8 +28,8 @@ PAD_TO := 0xfff04000 include $(TOPDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds \ - -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds \ + -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -55,7 +55,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/freescale/mpc8536ds/Makefile b/nand_spl/board/freescale/mpc8536ds/Makefile index 9c9d63e..99db1b4 100644 --- a/nand_spl/board/freescale/mpc8536ds/Makefile +++ b/nand_spl/board/freescale/mpc8536ds/Makefile @@ -30,7 +30,7 @@ PAD_TO := 0xfff01000 include $(TOPDIR)/config.mk
LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds -LDFLAGS = -Bstatic -T $(LDSCRIPT) -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(LDSCRIPT) -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -56,7 +56,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/freescale/mpc8569mds/Makefile b/nand_spl/board/freescale/mpc8569mds/Makefile index 9c9d63e..99db1b4 100644 --- a/nand_spl/board/freescale/mpc8569mds/Makefile +++ b/nand_spl/board/freescale/mpc8569mds/Makefile @@ -30,7 +30,7 @@ PAD_TO := 0xfff01000 include $(TOPDIR)/config.mk
LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds -LDFLAGS = -Bstatic -T $(LDSCRIPT) -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(LDSCRIPT) -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -56,7 +56,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/freescale/mpc8572ds/Makefile b/nand_spl/board/freescale/mpc8572ds/Makefile index e2181e9..b101627 100644 --- a/nand_spl/board/freescale/mpc8572ds/Makefile +++ b/nand_spl/board/freescale/mpc8572ds/Makefile @@ -30,7 +30,7 @@ PAD_TO := 0xfff01000 include $(TOPDIR)/config.mk
LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds -LDFLAGS = -Bstatic -T $(LDSCRIPT) -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(LDSCRIPT) -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -56,7 +56,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/freescale/mx31pdk/Makefile b/nand_spl/board/freescale/mx31pdk/Makefile index 3568e8c..edafc18 100644 --- a/nand_spl/board/freescale/mx31pdk/Makefile +++ b/nand_spl/board/freescale/mx31pdk/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/config.mk include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_PRELOADER -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_PRELOADER -DCONFIG_NAND_SPL
@@ -31,7 +31,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) \ -Map $(nandobj)u-boot-spl.map \ -o $@
diff --git a/nand_spl/board/freescale/p1_p2_rdb/Makefile b/nand_spl/board/freescale/p1_p2_rdb/Makefile index 9c9d63e..ce7aa99 100644 --- a/nand_spl/board/freescale/p1_p2_rdb/Makefile +++ b/nand_spl/board/freescale/p1_p2_rdb/Makefile @@ -30,7 +30,8 @@ PAD_TO := 0xfff01000 include $(TOPDIR)/config.mk
LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds -LDFLAGS = -Bstatic -T $(LDSCRIPT) -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(LDSCRIPT) -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \ + $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -56,7 +57,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/karo/tx25/Makefile b/nand_spl/board/karo/tx25/Makefile index 140440d..11656f0 100644 --- a/nand_spl/board/karo/tx25/Makefile +++ b/nand_spl/board/karo/tx25/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_PRELOADER -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_PRELOADER -DCONFIG_NAND_SPL
@@ -52,7 +52,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) \ -Map $(nandobj)u-boot-spl.map \ -o $@
diff --git a/nand_spl/board/samsung/smdk6400/Makefile b/nand_spl/board/samsung/smdk6400/Makefile index 18cee10..1c496ec 100644 --- a/nand_spl/board/samsung/smdk6400/Makefile +++ b/nand_spl/board/samsung/smdk6400/Makefile @@ -30,7 +30,7 @@ include $(TOPDIR)/config.mk include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -55,7 +55,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl
diff --git a/nand_spl/board/sheldon/simpc8313/Makefile b/nand_spl/board/sheldon/simpc8313/Makefile index bc6dc65..434f7b7 100644 --- a/nand_spl/board/sheldon/simpc8313/Makefile +++ b/nand_spl/board/sheldon/simpc8313/Makefile @@ -28,8 +28,8 @@ NAND_SPL := y include $(TOPDIR)/config.mk
LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds -LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds \ - -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds \ + -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_NAND_SPL
@@ -55,7 +55,7 @@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) $(PLATFORM_LIBS) \ + cd $(LNDIR) && $(LD) $(LDFLAGS_spl) $(__OBJS) $(PLATFORM_LIBS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl

Dear Haiying.Wang@freescale.com,
In message 1296498767-26408-1-git-send-email-Haiying.Wang@freescale.com you wrote:
From: Haiying Wang Haiying.Wang@freescale.com
commit 8aba9dceebb14144e07d19593111ee3a999c37fc Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS
breaks the usage of --gc-section to build nand_spl. We still need linker option --gc-section for every uboot image, not only the main one. LDFLAGS_FINAL passes the --gc-sections to each uboot image.
If I understand the intention of the LDFLAGS_u-boot setting corrrectly, then you would have to add a "LDFLAGS_nand_spl" setting.
If you introduce a new LDFLAGS_FINAL instead, then why do we have to keep LDFLAGS_u-boot - isn't LDFLAGS_u-boot also for "final" linking of the U-Boot image?
[Btw: "final" is probably not a technically correct term for all the use cases I see below.]
...
diff --git a/config.mk b/config.mk index 5147c35..caa6221 100644 --- a/config.mk +++ b/config.mk @@ -205,8 +205,9 @@ endif AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
LDFLAGS += $(PLATFORM_LDFLAGS) +LDFLAGS_FINAL += -Bstatic $(LDFLAGS)
-LDFLAGS_u-boot += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS) +LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
Is it intentional that you change PLATFORM_LDFLAGS into LDFLAGS here?
Are you sure that this change is correct for all affected boards?
How has this change been tested?
-LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL)
Arghhh... Here you introduce yet another setting, LDFLAGS_spl ?
This is not mentioned in the commit message. And why do we need it? Isn't LDFLAGS_FINAL enough?
Will I soon see patches to also add LDFLAGS_tpl?
This is becoming a mess. We need to find a simple, clean way to solve this. I'm on the verge of reverting the LDFLAGS_u-boot commit.
Best regards,
Wolfgang Denk

On Mon, 31 Jan 2011 20:33:09 +0100 Wolfgang Denk wd@denx.de wrote:
Dear Haiying.Wang@freescale.com,
In message 1296498767-26408-1-git-send-email-Haiying.Wang@freescale.com you wrote:
From: Haiying Wang Haiying.Wang@freescale.com
commit 8aba9dceebb14144e07d19593111ee3a999c37fc Divides variable of linker flags to LDFLAGS-u-boot and LDFLAGS
breaks the usage of --gc-section to build nand_spl. We still need linker option --gc-section for every uboot image, not only the main one. LDFLAGS_FINAL passes the --gc-sections to each uboot image.
If I understand the intention of the LDFLAGS_u-boot setting corrrectly, then you would have to add a "LDFLAGS_nand_spl" setting.
If you introduce a new LDFLAGS_FINAL instead, then why do we have to keep LDFLAGS_u-boot - isn't LDFLAGS_u-boot also for "final" linking of the U-Boot image?
[Btw: "final" is probably not a technically correct term for all the use cases I see below.]
I meant final as compared to partial links, not anything to do with spl versus tpl versus the main image.
Do you have a better wording?
diff --git a/config.mk b/config.mk index 5147c35..caa6221 100644 --- a/config.mk +++ b/config.mk @@ -205,8 +205,9 @@ endif AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
LDFLAGS += $(PLATFORM_LDFLAGS) +LDFLAGS_FINAL += -Bstatic $(LDFLAGS)
-LDFLAGS_u-boot += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS) +LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
Is it intentional that you change PLATFORM_LDFLAGS into LDFLAGS here?
Are you sure that this change is correct for all affected boards?
How has this change been tested?
As I understand it, it has only been limited to PLATFORM_LDFLAGS since the LDFLAGS_u-boot commit. Was that change intentional, and widely tested?
-LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL)
Arghhh... Here you introduce yet another setting, LDFLAGS_spl ?
This is not mentioned in the commit message. And why do we need it? Isn't LDFLAGS_FINAL enough?
No, it's not enough. The whole point is to separate options which should apply to all final (non-partial) links, versus options which are specific to a particular image.
This is the point where we add in the options that are specific to the spl image.
With :=, we could preserve the LDFLAGS name, but it seemed better to avoid muddying up what LDFLAGS means, if it's now supposed to mean options that are used in partial linking -- and it makes things look more consistent with what's done in the main image.
Or we could not use a variable for this and stick it on the ld command line, but is that really an improvement?
Will I soon see patches to also add LDFLAGS_tpl?
Of course. :-)
This is becoming a mess. We need to find a simple, clean way to solve this. I'm on the verge of reverting the LDFLAGS_u-boot commit.
What's the alternative solution, when we have some options that need to be set during partial link, others which cannot be set during partial link but must be set during final link, and a couple more (text address and linker script) which are specific to the individual image?
I think introducing the additional variables makes things less messy, because it means each variable has a specific, unambiguous purpose.
-Scott

Dear Scott Wood,
In message 20110131135548.50d65759@udp111988uds.am.freescale.net you wrote:
[Btw: "final" is probably not a technically correct term for all the use cases I see below.]
I meant final as compared to partial links, not anything to do with spl versus tpl versus the main image.
Do you have a better wording?
Not really. ld documentation also talks about "final binary" or "final executable". Note that I'm not insisting on a change here.
LDFLAGS += $(PLATFORM_LDFLAGS) +LDFLAGS_FINAL += -Bstatic $(LDFLAGS)
-LDFLAGS_u-boot += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS) +LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
Is it intentional that you change PLATFORM_LDFLAGS into LDFLAGS here?
Are you sure that this change is correct for all affected boards?
How has this change been tested?
As I understand it, it has only been limited to PLATFORM_LDFLAGS since the LDFLAGS_u-boot commit. Was that change intentional, and widely tested?
Can you please be more specific? I don't see where "the LDFLAGS_u-boot commit" (you mean 8aba9dc ?) would change any related code. The relevant hunk looks like this:
@@ -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
and this does not make any changes of PLATFORM_LDFLAGS into LDFLAGS or vice versa.
Best regards,
Wolfgang Denk

On Tue, 2011-02-01 at 08:34 +0100, Wolfgang Denk wrote:
Can you please be more specific? I don't see where "the LDFLAGS_u-boot commit" (you mean 8aba9dc ?) would change any related code. The relevant hunk looks like this:
@@ -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
and this does not make any changes of PLATFORM_LDFLAGS into LDFLAGS or vice versa.
But PLATFORM_LDFLAGS has been changed in $(CPUDIR)/config.mk.
You can see in commit 8aba9dc:
--- 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
Here, --gc-sections is set only for LDFLAGS_u-boot, the PLATFORM_LDFLAGS does have --gc-sections, So in toplevel config.mk:
+LDFLAGS += $(PLATFORM_LDFLAGS)
And later in this config.mk,
@@ -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 $@ )
LDFLAGS is added in cmd_link_o_target which made changes to build nand_spl.
Haiying

On Tue, 1 Feb 2011 08:34:01 +0100 Wolfgang Denk wd@denx.de wrote:
Dear Scott Wood,
In message 20110131135548.50d65759@udp111988uds.am.freescale.net you wrote:
As I understand it, it has only been limited to PLATFORM_LDFLAGS since the LDFLAGS_u-boot commit. Was that change intentional, and widely tested?
Can you please be more specific? I don't see where "the LDFLAGS_u-boot commit" (you mean 8aba9dc ?) would change any related code. The relevant hunk looks like this:
@@ -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
Prior to the introduction of LDFLAGS_u-boot, was LDFLAGS not what was used? So before, anything that board/cpu code adds directly to LDFLAGS (maybe they're supposed to use PLATFORM_LDFLAGS, but not all do) was used in the final link. After 8aba9dc, only things in PLATFORM_LDFLAGS plus -Bstatic and -T are used in the final link.
-Scott

Dear Scott Wood,
In message 20110201102446.23b4a2e9@udp111988uds.am.freescale.net you wrote:
Prior to the introduction of LDFLAGS_u-boot, was LDFLAGS not what was used? So before, anything that board/cpu code adds directly to LDFLAGS (maybe they're supposed to use PLATFORM_LDFLAGS, but not all do) was used in the final link. After 8aba9dc, only things in PLATFORM_LDFLAGS plus -Bstatic and -T are used in the final link.
And this is correct for all boards?
Best regards,
Wolfgang Denk

On Tue, 1 Feb 2011 20:32:29 +0100 Wolfgang Denk wd@denx.de wrote:
Dear Scott Wood,
In message 20110201102446.23b4a2e9@udp111988uds.am.freescale.net you wrote:
Prior to the introduction of LDFLAGS_u-boot, was LDFLAGS not what was used? So before, anything that board/cpu code adds directly to LDFLAGS (maybe they're supposed to use PLATFORM_LDFLAGS, but not all do) was used in the final link. After 8aba9dc, only things in PLATFORM_LDFLAGS plus -Bstatic and -T are used in the final link.
And this is correct for all boards?
By "this" do you mean the switch to PLATFORM_LDFLAGS in 8aba9dc, or the switch back to LDFLAGS? It's not obvious to me that the dropping of board/cpu modifications to LDFLAGS except during partial link was an intentional change, or a correct one for all boards.
The only case I see where it makes any difference at all is arch/i386, which does LDFLAGS += --cref. From the description of --cref in the linker manual, it probably actually belongs in LDFLAGS_FINAL, though I'm not sure if it's harmless to include it in partial link or not. Currently, with 8aba9dc, it's included *only* in partial link.
It's also not clear to me what this option has to do with i386... it looks like an arch-neutral debugging feature that doesn't affect the actual u-boot image at all (the output goes into the map file).
-Scott

Dear Scott Wood,
In message 20110201135136.0817fe5a@udp111988uds.am.freescale.net you wrote:
Prior to the introduction of LDFLAGS_u-boot, was LDFLAGS not what was used? So before, anything that board/cpu code adds directly to LDFLAGS (maybe they're supposed to use PLATFORM_LDFLAGS, but not all do) was used in the final link. After 8aba9dc, only things in PLATFORM_LDFLAGS plus -Bstatic and -T are used in the final link.
And this is correct for all boards?
By "this" do you mean the switch to PLATFORM_LDFLAGS in 8aba9dc, or the switch back to LDFLAGS? It's not obvious to me that the dropping of
I don;t understand why you contine to talk about "switch to PLATFORM_LDFLAGS in 8aba9dc". There was no such switch - at least I cannot see it.
I see only a switch in your patch. This is why I'm asking.
Best regards,
Wolfgang Denk

On Tue, 1 Feb 2011 21:20:50 +0100 Wolfgang Denk wd@denx.de wrote:
Dear Scott Wood,
In message 20110201135136.0817fe5a@udp111988uds.am.freescale.net you wrote:
Prior to the introduction of LDFLAGS_u-boot, was LDFLAGS not what was used? So before, anything that board/cpu code adds directly to LDFLAGS (maybe they're supposed to use PLATFORM_LDFLAGS, but not all do) was used in the final link. After 8aba9dc, only things in PLATFORM_LDFLAGS plus -Bstatic and -T are used in the final link.
And this is correct for all boards?
By "this" do you mean the switch to PLATFORM_LDFLAGS in 8aba9dc, or the switch back to LDFLAGS? It's not obvious to me that the dropping of
I don;t understand why you contine to talk about "switch to PLATFORM_LDFLAGS in 8aba9dc". There was no such switch - at least I cannot see it.
I see only a switch in your patch. This is why I'm asking.
Before 8aba9dc, the flags for the final link were produced by taking the existing LDFLAGS, and adding: -Bstatic -T <linkerscript> $(PLATFORM_LDFLAGS) -Ttext <addr>.
This included anything that cpu/board code added to LDFLAGS -- some architectures added --gc-sections, x86 added --cref, etc. Since the above flags are added to LDFLAGS, rather than replacing them, these flags got used in the final link.
Commit 8aba9dc introduces LDFLAGS_u-boot, so that LDFLAGS is no longer the source for the flags for the final link. It generates LDFLAGS_u-boot using PLATFORM_LDFLAGS, not LDFLAGS. It converts most of the board/cpu updates to LDFLAGS into LDFLAGS_u-boot, but it missed --cref.
I don't see any other LDFLAGS changes in board/cpu code, so the distinction between using LDFLAGS and PLATFORM_LDFLAGS should have no other impact on current boards. However, the patch appears to be intended to support platform linker flags that need to be used during partial link, which would involve board/cpu additions to LDFLAGS. This change would break that only if those options need to be used for partial link *only*, and cannot be used in the final link. In such a case I'd suggest using something like LDFLAGS_PARTIAL to make this explicit. But I'd be surprised if that were actually the case.
If you're looking to cut down on the number of variables, it's not clear to me what PLATFORM_LDFLAGS is supposed to mean distinct from adding to LDFLAGS.
-Scott

Dear Wolfgang,
On Tue, 2011-02-01 at 14:40 -0600, Scott Wood wrote:
On Tue, 1 Feb 2011 21:20:50 +0100 Wolfgang Denk wd@denx.de wrote:
Dear Scott Wood,
In message 20110201135136.0817fe5a@udp111988uds.am.freescale.net you wrote:
Prior to the introduction of LDFLAGS_u-boot, was LDFLAGS not what was used? So before, anything that board/cpu code adds directly to LDFLAGS (maybe they're supposed to use PLATFORM_LDFLAGS, but not all do) was used in the final link. After 8aba9dc, only things in PLATFORM_LDFLAGS plus -Bstatic and -T are used in the final link.
And this is correct for all boards?
By "this" do you mean the switch to PLATFORM_LDFLAGS in 8aba9dc, or the switch back to LDFLAGS? It's not obvious to me that the dropping of
I don;t understand why you contine to talk about "switch to PLATFORM_LDFLAGS in 8aba9dc". There was no such switch - at least I cannot see it.
I see only a switch in your patch. This is why I'm asking.
Before 8aba9dc, the flags for the final link were produced by taking the existing LDFLAGS, and adding: -Bstatic -T <linkerscript> $(PLATFORM_LDFLAGS) -Ttext <addr>.
This included anything that cpu/board code added to LDFLAGS -- some architectures added --gc-sections, x86 added --cref, etc. Since the above flags are added to LDFLAGS, rather than replacing them, these flags got used in the final link.
Commit 8aba9dc introduces LDFLAGS_u-boot, so that LDFLAGS is no longer the source for the flags for the final link. It generates LDFLAGS_u-boot using PLATFORM_LDFLAGS, not LDFLAGS. It converts most of the board/cpu updates to LDFLAGS into LDFLAGS_u-boot, but it missed --cref.
I don't see any other LDFLAGS changes in board/cpu code, so the distinction between using LDFLAGS and PLATFORM_LDFLAGS should have no other impact on current boards. However, the patch appears to be intended to support platform linker flags that need to be used during partial link, which would involve board/cpu additions to LDFLAGS. This change would break that only if those options need to be used for partial link *only*, and cannot be used in the final link. In such a case I'd suggest using something like LDFLAGS_PARTIAL to make this explicit. But I'd be surprised if that were actually the case.
If you're looking to cut down on the number of variables, it's not clear to me what PLATFORM_LDFLAGS is supposed to mean distinct from adding to LDFLAGS.
-Scott
Do you have time to read Scott's email and give us any further recommendation? We do need to solve the issues of partial linking caused by commit 8aba9dc.
Thanks.
Haiying

On Tuesday, February 01, 2011 15:40:13 Scott Wood wrote:
Before 8aba9dc, the flags for the final link were produced by taking the existing LDFLAGS, and adding: -Bstatic -T <linkerscript> $(PLATFORM_LDFLAGS) -Ttext <addr>.
i think you're skipping a fairly large piece of the picture -- the whole reason for 8aba9dc commit in the first place: commit 6d8962e814 (introduction of partial linking). before that commit, the linker was only used in one place: the final u-boot link. because of that, LDFLAGS was only used in one place. so people put both target-specific (u-boot) and linker-specific (ld) flags into the same place (LDFLAGS). but with partial linking, that was no longer possible. we needed a way to differentiate between the two and thus LDFLAGS_$@ was born.
so commit 8aba9dc is not something made for fun, but to fix real bugs people were seeing while building with bi-endian toolchains (arm/superh/mips/probably others), or bi-abi toolchains (blackfin/arm/probably others).
This included anything that cpu/board code added to LDFLAGS -- some architectures added --gc-sections, x86 added --cref, etc. Since the above flags are added to LDFLAGS, rather than replacing them, these flags got used in the final link.
Commit 8aba9dc introduces LDFLAGS_u-boot, so that LDFLAGS is no longer the source for the flags for the final link. It generates LDFLAGS_u-boot using PLATFORM_LDFLAGS, not LDFLAGS. It converts most of the board/cpu updates to LDFLAGS into LDFLAGS_u-boot, but it missed --cref.
err, i dont think this is correct. LDFLAGS is no longer the *only* source for the final link. if you look at the actual target, you'll see it using $(LDFLAGS) $(LDFLAGS_$(@F)).
I don't see any other LDFLAGS changes in board/cpu code, so the distinction between using LDFLAGS and PLATFORM_LDFLAGS should have no other impact on current boards. However, the patch appears to be intended to support platform linker flags that need to be used during partial link, which would involve board/cpu additions to LDFLAGS. This change would break that only if those options need to be used for partial link *only*, and cannot be used in the final link. In such a case I'd suggest using something like LDFLAGS_PARTIAL to make this explicit. But I'd be surprised if that were actually the case.
if Linux hasnt had an issue with flags that are valid only during partial linking, then i dont think u-boot will either.
If you're looking to cut down on the number of variables, it's not clear to me what PLATFORM_LDFLAGS is supposed to mean distinct from adding to LDFLAGS.
historically, ive never really seen much (any?) value in the split between PLATFORM_XXX and XXX. i say we kill all the PLATFORM_XXX cruft.
ultimately, LDFLAGS_FINAL makes sense to me. we cant override LD, nor can we override LDFLAGS, and it sucks if people have to duplicate flags in multiple variables when all they care about is the final link. it's unavoidable pain imo born of attempting to build & finally link multiple applications in a single tree. -mike

On Tue, 15 Feb 2011 04:02:44 -0500 Mike Frysinger vapier@gentoo.org wrote:
so commit 8aba9dc is not something made for fun, but to fix real bugs people were seeing while building with bi-endian toolchains (arm/superh/mips/probably others), or bi-abi toolchains (blackfin/arm/probably others).
Sure. But it had a side effect, and this patch is an attempt to fix that side effect without affecting the real purpose of 8aba9dc.
This included anything that cpu/board code added to LDFLAGS -- some architectures added --gc-sections, x86 added --cref, etc. Since the above flags are added to LDFLAGS, rather than replacing them, these flags got used in the final link.
Commit 8aba9dc introduces LDFLAGS_u-boot, so that LDFLAGS is no longer the source for the flags for the final link. It generates LDFLAGS_u-boot using PLATFORM_LDFLAGS, not LDFLAGS. It converts most of the board/cpu updates to LDFLAGS into LDFLAGS_u-boot, but it missed --cref.
err, i dont think this is correct. LDFLAGS is no longer the *only* source for the final link. if you look at the actual target, you'll see it using $(LDFLAGS) $(LDFLAGS_$(@F)).
Ah. So why is PLATFORM_LDFLAGS added into both LDFLAGS and LDFLAGS_u-boot? :-P
-Scott

On Tuesday, February 15, 2011 19:51:00 Scott Wood wrote:
On Tue, 15 Feb 2011 04:02:44 -0500 Mike Frysinger wrote:
This included anything that cpu/board code added to LDFLAGS -- some architectures added --gc-sections, x86 added --cref, etc. Since the above flags are added to LDFLAGS, rather than replacing them, these flags got used in the final link.
Commit 8aba9dc introduces LDFLAGS_u-boot, so that LDFLAGS is no longer the source for the flags for the final link. It generates LDFLAGS_u-boot using PLATFORM_LDFLAGS, not LDFLAGS. It converts most of the board/cpu updates to LDFLAGS into LDFLAGS_u-boot, but it missed --cref.
err, i dont think this is correct. LDFLAGS is no longer the *only* source for the final link. if you look at the actual target, you'll see it using $(LDFLAGS) $(LDFLAGS_$(@F)).
Ah. So why is PLATFORM_LDFLAGS added into both LDFLAGS and LDFLAGS_u-boot? :-P
i'm not saying PLATFORM_LDFLAGS makes sense. it certainly seems like we've outgrown the PLATFORM_XXX flags and could be cleaned up. -mike

On 02/02/11 06:51, Scott Wood wrote:
On Tue, 1 Feb 2011 20:32:29 +0100 Wolfgang Denk wd@denx.de wrote:
Dear Scott Wood,
In message 20110201102446.23b4a2e9@udp111988uds.am.freescale.net you wrote:
Prior to the introduction of LDFLAGS_u-boot, was LDFLAGS not what was used? So before, anything that board/cpu code adds directly to LDFLAGS (maybe they're supposed to use PLATFORM_LDFLAGS, but not all do) was used in the final link. After 8aba9dc, only things in PLATFORM_LDFLAGS plus -Bstatic and -T are used in the final link.
And this is correct for all boards?
By "this" do you mean the switch to PLATFORM_LDFLAGS in 8aba9dc, or the switch back to LDFLAGS? It's not obvious to me that the dropping of board/cpu modifications to LDFLAGS except during partial link was an intentional change, or a correct one for all boards.
The only case I see where it makes any difference at all is arch/i386, which does LDFLAGS += --cref. From the description of --cref in the linker manual, it probably actually belongs in LDFLAGS_FINAL, though I'm not sure if it's harmless to include it in partial link or not. Currently, with 8aba9dc, it's included *only* in partial link.
It's also not clear to me what this option has to do with i386... it looks like an arch-neutral debugging feature that doesn't affect the actual u-boot image at all (the output goes into the map file).
--cref can be dropped from x86 - I really should send a patch to rename i386 to x86 ;)
Since x86 is currently a very simple platform to maintain (one CPU, one board) and I have been dealing with breakages do to non x86 cleanups for a while, I have no problem with tweaking the x86 linker options to be more arch neutral.
Regards,
Graeme

On Mon, 2011-01-31 at 20:33 +0100, Wolfgang Denk wrote:
If I understand the intention of the LDFLAGS_u-boot setting corrrectly, then you would have to add a "LDFLAGS_nand_spl" setting.
No, I don't want to add a LDFLAGS_nand_spl for nand_spl only, I need LDFLAGS_FINAL to be passed to nand spl, tpl, and final uboot images.
If you introduce a new LDFLAGS_FINAL instead, then why do we have to keep LDFLAGS_u-boot - isn't LDFLAGS_u-boot also for "final" linking of the U-Boot image?
LDFLAGS_FINAL does not provide the whole set of linker options to U-Boot image, so it does not replace the LDFLAGS_u-boot, in patch:
-LDFLAGS_u-boot += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS) +LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
[Btw: "final" is probably not a technically correct term for all the use cases I see below.]
did not think of any better term.
...
diff --git a/config.mk b/config.mk index 5147c35..caa6221 100644 --- a/config.mk +++ b/config.mk @@ -205,8 +205,9 @@ endif AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
LDFLAGS += $(PLATFORM_LDFLAGS) +LDFLAGS_FINAL += -Bstatic $(LDFLAGS)
-LDFLAGS_u-boot += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS) +LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
Is it intentional that you change PLATFORM_LDFLAGS into LDFLAGS here?
Yes. it LDFLAGS_FINAL here includes "-Bstatic $(PLATFORM_LDFLAGS)".
Are you sure that this change is correct for all affected boards?
Can not 100% sure because I can not test all the affected boards.
How has this change been tested?
I only can test powerpc by MAKEALL.
-LDFLAGS = -Bstatic -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) +LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL)
Arghhh... Here you introduce yet another setting, LDFLAGS_spl ?
This is an intentional name change. LDFLAGS_spl is used here as LDFLAGS_u-boot, but for nand spl linkage. Actually it is not a new FLAGS, just add *_spl* here so that it can be differed from the LDFlAGS in toplevel config.mk.
This is not mentioned in the commit message. And why do we need it? Isn't LDFLAGS_FINAL enough?
As said, it is not a new flag, just a name change.
Will I soon see patches to also add LDFLAGS_tpl?
Yes, in patch 3/6.
This is becoming a mess. We need to find a simple, clean way to solve this. I'm on the verge of reverting the LDFLAGS_u-boot commit.
We just want to make sure gc-sections works for all the uboot images. :)
Haiying

Dear Haiying Wang,
In message 1296504850.2049.434.camel@haiying-laptop you wrote:
If you introduce a new LDFLAGS_FINAL instead, then why do we have to keep LDFLAGS_u-boot - isn't LDFLAGS_u-boot also for "final" linking of the U-Boot image?
LDFLAGS_FINAL does not provide the whole set of linker options to U-Boot image, so it does not replace the LDFLAGS_u-boot, in patch:
I have problems to understan the intentions behind all these many different linker flag settings, nd this while we are discussing it. In two weeks from now I will understand none of this any more.
Either this can be made simpler. If you are sure this is not possible, then we need some detailed documentation of all this, at least in the README, but eventually as a separate doc/README.*
LDFLAGS += $(PLATFORM_LDFLAGS) +LDFLAGS_FINAL += -Bstatic $(LDFLAGS)
-LDFLAGS_u-boot += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS) +LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
Is it intentional that you change PLATFORM_LDFLAGS into LDFLAGS here?
Yes. it LDFLAGS_FINAL here includes "-Bstatic $(PLATFORM_LDFLAGS)".
No. Pleasse see 5 lines above: it is "-Bstatic $(LDFLAGS)".
Are you sure that this change is correct for all affected boards?
Can not 100% sure because I can not test all the affected boards.
Yes, you can. Run MAKEALL for all ppc boards and compare the System.map and u-boot.map files before and after your change. This is still no guarantee to cover 100% of the potential issues, but as close as we can get with reasonable effort.
How has this change been tested?
I only can test powerpc by MAKEALL.
+LDFLAGS_spl := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS_FINAL)
Arghhh... Here you introduce yet another setting, LDFLAGS_spl ?
This is an intentional name change. LDFLAGS_spl is used here as LDFLAGS_u-boot, but for nand spl linkage. Actually it is not a new FLAGS, just add *_spl* here so that it can be differed from the LDFlAGS in toplevel config.mk.
This is not mentioned in the commit message. And why do we need it? Isn't LDFLAGS_FINAL enough?
As said, it is not a new flag, just a name change.
Anyway. It was not mentioned in the commit message, and not explained anywhere else.
We _really_ need to thoroughly document all this stuff or soon nobody will understand nothing of this anymore.
Will I soon see patches to also add LDFLAGS_tpl?
Yes, in patch 3/6.
:-(
Best regards,
Wolfgang Denk
participants (6)
-
Graeme Russ
-
Haiying Wang
-
Haiying.Wang@freescale.com
-
Mike Frysinger
-
Scott Wood
-
Wolfgang Denk