add $(ENDIANNESS) option when link hello_world example
PATCH 1/1 add $(ENDIANNESS) option when link hello_world example
Hi
form the document about OUTPUT_FORMAT(default, big, little)
If neither -EB nor -EL are used, output format will be the first argument. If -EB is used, the output format will be the second argument. If -EL is used, the output format will be the third argument.
so change the mips.lds third argument to little and add $(ENDIANNESS) to linker args.
this patch have tested with "./MAKEALL mips mips_el"
--- arch/mips/config.mk | 2 +- examples/standalone/mips.lds | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/config.mk +1 -1
@@ -23,7 +23,7 @@ CROSS_COMPILE ?= mips_4KC- -STANDALONE_LOAD_ADDR = 0x80200000 -T mips.lds +STANDALONE_LOAD_ADDR = 0x80200000 -T mips.lds $(ENDIANNESS) PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
examples/standalone/mips.lds +1 -1
@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) SECTIONS {
Signature · 1 line
1.7.0.4
PATCH 1/1 add $(ENDIANNESS) option when link hello_world example
Quoted 9 lines · Xiangfu Liu
form the document about
OUTPUT_FORMAT(default, big, little)
If neither -EB nor -EL are used, output format will be the first argument. If -EB is used, the output format will be the second argument. If -EL is used, the output format will be the third argument.so change the
mips.ldsthird argument to little and add $(ENDIANNESS) to linker args.this patch have tested with "./MAKEALL mips
mips_el"
Little endian build is one of the outstanding issues for MIPS ports[1].
There are several technical issues, 1) lack of powerful configration infrastructure (it's drastically improved these days, so not a problem any more), 2) *LDFLAGS things are not propageted throughout the build system properly, especially through examples/standalone (it seems this issue is also addressed via distributed STANDALONE_LOAD_ADDR). Or in some cases, 3) you might want to generate u-boot image with different endiannness from toolchain's default (native build vs. non-native). And finally 4) ELDK toolchains vs. non-ELDK tools issues. As for #4, you'll see troublesome -dumpspecs outputs from ELDK toolchain[2].
[1] http://search.gmane.org/?query=mips+little+endian&group=gmane.comp.boot-loaders.u-boot
[2] http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/31998
Anyway, to move discussion forward we need to sort out what's the most priority, what's next, what's nice to have, and what's not.
Quoted 18 lines
arch/mips/config.mk +1
-1@@ -23,7 +23,7 @@ CROSS_COMPILE ?= mips_4KC- -STANDALONE_LOAD_ADDR = 0x80200000 -T mips.lds +STANDALONE_LOAD_ADDR = 0x80200000 -T mips.lds $(ENDIANNESS) PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__examples/standalone/mips.lds +0
-0
examples/standalone/mips.lds line 30
Quoted 8 lines
examples/standalone/mips.lds +1
-1@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) SECTIONS {
Attached is one of my holding patches for little endian builds. This looks mostly good and works for me, but won't work for ELDK toolchain.
Having additional hooks for ELDK tools somewhere in config.mk files would probably work, but I don't have enough spare time these days. Someone please cook it up into appropriate shape, please?
Shinya
--- Makefile | 1 + arch/mips/config.mk | 27 +++++++++++++++++++++++++-- arch/mips/cpu/config.mk | 8 -------- board/dbau1x00/u-boot.lds | 2 +- board/gth2/u-boot.lds | 2 +- board/incaip/u-boot.lds | 2 +- board/pb1x00/u-boot.lds | 2 +- board/purple/u-boot.lds | 2 +- board/qemu-mips/u-boot.lds | 2 +- examples/standalone/mips.lds | 2 +- include/configs/pb1x00.h | 2 ++ 11 files changed, 35 insertions(+), 17 deletions(-)
Makefile +1 -0
@@ -2306,6 +2306,7 @@ dbau1550_config : unconfig dbau1550_el_config : unconfig @mkdir -p $(obj)include @echo "#define CONFIG_DBAU1550 1" >$(obj)include/config.h + @echo "#define CONFIG_CPU_LITTLE_ENDIAN" >>$(obj)include/config.h @$(MKCONFIG) -a dbau1x00 mips mips dbau1x00 gth2_config : unconfig
arch/mips/config.mk +25 -2
@@ -23,8 +23,6 @@ CROSS_COMPILE ?= mips_4KC- -STANDALONE_LOAD_ADDR = 0x80200000 -T mips.lds - PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__ #
@@ -50,3 +48,28 @@ PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__ PLATFORM_CPPFLAGS += -G 0 -mabicalls -fpic PLATFORM_CPPFLAGS += -msoft-float PLATFORM_LDFLAGS += -G 0 -static -n -nostdlib + +# +# We explicitly add the endianness specifier if needed, this allows +# to compile kernels with a toolchain for the other endianness. We +# carefully avoid to add it redundantly because gcc 3.3/3.4 complains +# when fed the toolchain default! +# +# Certain gcc versions upto gcc 4.1.1 (probably 4.2-subversion as of +# 2006-10-10 don't properly change the predefined symbols if -EB / -EL +# are used, so we kludge that here. A bug has been filed at +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29413. +# +UNDEF_ALL += -UMIPSEB -U_MIPSEB -U__MIPSEB -U__MIPSEB__ +UNDEF_ALL += -UMIPSEL -U_MIPSEL -U__MIPSEL -U__MIPSEL__ +PREDEF_BE += -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__ +PREDEF_LE += -DMIPSEL -D_MIPSEL -D__MIPSEL -D__MIPSEL__ +ifdef CONFIG_CPU_LITTLE_ENDIAN +PLATFORM_CPPFLAGS += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(UNDEF_ALL) $(PREDEF_LE)) +PLATFORM_LDFLAGS += -EL +else +PLATFORM_CPPFLAGS += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB $(UNDEF_ALL) $(PREDEF_BE)) +PLATFORM_LDFLAGS += -EB +endif + +STANDALONE_LOAD_ADDR = 0x80200000 -T mips.lds $(PLATFORM_LDFLAGS)
arch/mips/cpu/config.mk +0 -8
@@ -28,12 +28,4 @@ else \ echo "-march=4kc -mtune=4kc"; \ fi) -ifneq (,$(findstring 4KCle,$(CROSS_COMPILE))) -ENDIANNESS = -EL -else -ENDIANNESS = -EB -endif - -MIPSFLAGS += $(ENDIANNESS) - PLATFORM_CPPFLAGS += $(MIPSFLAGS)
board/dbau1x00/u-boot.lds +1 -1
@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONS
board/gth2/u-boot.lds +1 -1
@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONS
board/incaip/u-boot.lds +1 -1
@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONS
board/pb1x00/u-boot.lds +1 -1
@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONS
board/purple/u-boot.lds +1 -1
@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONS
board/qemu-mips/u-boot.lds +1 -1
@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONS
examples/standalone/mips.lds +1 -1
@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) SECTIONS {
include/configs/pb1x00.h +2 -0
@@ -28,6 +28,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#define CONFIG_CPU_LITTLE_ENDIAN +#define CONFIG_MIPS32 1/* MIPS32 CPU core */ #define CONFIG_PB1X00 1#define CONFIG_SOC_AU1X00 1/* alchemy series cpu */
PATCH 1/1 add $(ENDIANNESS) option when link hello_world example
Hi Shinya
thanks for the links and patch.
comment inline :)
Quoted 12 lines · Shinya Kuribayashi
Little endian build is one of the outstanding issues for MIPS ports[1].
There are several technical issues, 1) lack of powerful configration infrastructure (it's drastically improved these days, so not a problem any more), 2) *LDFLAGS things are not propageted throughout the build system properly, especially through examples/standalone (it seems this issue is also addressed via distributed
STANDALONE_LOAD_ADDR). Or in some cases, 3) you might want to generate u-boot image with different endiannness from toolchain's default (native build vs. non-native). And finally 4) ELDK toolchains vs. non-ELDK tools issues. As for #4, you'll see troublesome -dumpspecs outputs from ELDK toolchain[2].
Quoted 5 lines
[1] http://search.gmane.org/?query=mips+little+endian&group=gmane.comp.boot-loaders.u-boot
[2] http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/31998Anyway, to move discussion forward we need to sort out what's the most priority, what's next, what's nice to have, and what's not.
what about split this patch to two:
one is all *.lds files,
the other one is for the argument,
arch/mips/config.mk PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__ · line 74
Quoted 13 lines
arch/mips/config.mk +12
-0+UNDEF_ALL += -UMIPSEB -U_MIPSEB -U__MIPSEB -U__MIPSEB__ +UNDEF_ALL += -UMIPSEL -U_MIPSEL -U__MIPSEL -U__MIPSEL__ +PREDEF_BE += -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__ +PREDEF_LE += -DMIPSEL -D_MIPSEL -D__MIPSEL -D__MIPSEL__ +ifdef CONFIG_CPU_LITTLE_ENDIAN +PLATFORM_CPPFLAGS += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(UNDEF_ALL) $(PREDEF_LE)) +PLATFORM_LDFLAGS += -EL +else +PLATFORM_CPPFLAGS += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*'&& echo -EB $(UNDEF_ALL) $(PREDEF_BE)) +PLATFORM_LDFLAGS += -EB +endif +
I have one question here. if we decete the board cpu by CONFIG_CPU_LITTLE_ENDIAN. why we need check the toolchina again. what about just like this? :
+PLATFORM_CPPFLAGS += -$(UNDEF_ALL) +ifdef CONFIG_CPU_LITTLE_ENDIAN +PLATFORM_CPPFLAGS += -EL $(PREDEF_LE)) +PLATFORM_LDFLAGS += -EL +else +PLATFORM_CPPFLAGS += -EB $(PREDEF_BE)) +PLATFORM_LDFLAGS += -EB +endif +
the original U-Boot is detect -EL/-EB by toolchain name. maybe the CONFIG_CPU_LITTLE_ENDIAN option is better.
this will not broken the ELDK compile.
Hi Shinya
I will try to make those two patch tomorrow. test, then send again. what do you think. do you have any advice to me? :)
Quoted 122 lines
arch/mips/config.mk +1
-0+STANDALONE_LOAD_ADDR = 0x80200000 -T mips.lds $(PLATFORM_LDFLAGS)arch/mips/cpu/config.mk +0
-8@@ -28,12 +28,4 @@ else \ echo "-march=4kc -mtune=4kc"; \ fi) -ifneq (,$(findstring 4KCle,$(CROSS_COMPILE))) -ENDIANNESS = -EL -else -ENDIANNESS = -EB -endif - -MIPSFLAGS += $(ENDIANNESS) - PLATFORM_CPPFLAGS += $(MIPSFLAGS)board/dbau1x00/u-boot.lds +1
-1@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONSboard/gth2/u-boot.lds +1
-1@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONSboard/incaip/u-boot.lds +1
-1@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONSboard/pb1x00/u-boot.lds +1
-1@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONSboard/purple/u-boot.lds +1
-1@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONSboard/qemu-mips/u-boot.lds +1
-1@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONSexamples/standalone/mips.lds +1
-1@@ -24,7 +24,7 @@ /* OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) SECTIONS {include/configs/pb1x00.h +2
-0@@ -28,6 +28,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#define CONFIG_CPU_LITTLE_ENDIAN +#define CONFIG_MIPS32 1/* MIPS32 CPU core */ #define CONFIG_PB1X00 1#define CONFIG_SOC_AU1X00 1/* alchemy series cpu */
Signature · 3 lines
Best Regards Xiangfu Liu http://www.openmobilefree.net
PATCH 1/1 add $(ENDIANNESS) option when link hello_world example
Quoted 3 lines · Xiangfu Liu
what about split this patch to two:
one is all *.lds files,
the other one is for the argument,
Sounds good.
Quoted 3 lines
I have one question here. if we decete the board cpu by
CONFIG_CPU_LITTLE_ENDIAN.
why we need check the toolchina again.
The answer is described right above:
+# We explicitly add the endianness specifier if needed, this allows +# to compile kernels with a toolchain for the other endianness. We +# carefully avoid to add it redundantly because gcc 3.3/3.4 complains +# when fed the toolchain default!
+#
+# Certain gcc versions upto gcc 4.1.1 (probably 4.2-subversion as of +# 2006-10-10 don't properly change the predefined symbols if -EB / -EL +# are used, so we kludge that here. A bug has been filed at +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29413.
This part is copied from Linux/MIPS kernel, and has been working with the wide range of GCC versions for years.
Quoted 2 lines
the original U-Boot is detect -EL/-EB by toolchain name. maybe the
CONFIG_CPU_LITTLE_ENDIANoption is better.
True. CONFIG_CPU_LITTLE_ENDIAN (and CONFIG_CPU_BIG_ENDIAN) configs are also derived from Linux/MIPS kernel, and IMO they're right steps toward cross-endian build support. U-Boot, however, tends to think it less important, so don't hold your breath about this approach to be accepted. Cross-endian build is common practice for MIPS people, but might be uncommon for other architectures.
Note that CONFIG_CPU_LITTLE_ENDIAN works not only for cross-endian builds, but also toolchain default endian builds with non-ELDK tools. If CONFIG_CPU_LITTLE_ENDIAN is not accepted, we have to think an alternative way.