Google
  Web www.spinics.net

Toolchain for armv5b (big-endian+soft-float)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


I used the crosstool (http://www.kegel.com/crosstool/) to build
gcc-3.3.2+glibc2.3.2 toolchain for armv5b with big endian and soft-float.
The .dat files and patches are attached.

I succeeded to build the toolchain. The kernel and busybox (statically
linked) are running properly. However, some daemons (samba, lpd, ftp
daemon...) core dump when I use shared library in these program. If the
program is statically linked, it has no problem.

Does anyone have the same experience?

---------------
armv5b.dat
---------------
KERNELCONFIG=$PWD/ixp425-config
TARGET=armv5b-linux
TARGET_CFLAGS="-O"
BINUTILS_DIR=binutils-2.14.90.0.7
BINUTILS_URL=http://www.kernel.org/pub/linux/devel/binutils
GCC_DIR=gcc-3.3.2
GCC_EXTRA_CONFIG="--nfp --without-fp --with-cpu=xscale --with-softfloat-supp
ort=internal --with-inhibit-libc"
GLIBC_DIR=glibc-2.3.2
LINUX_DIR=linux-2.4.x
GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.2
GLIBC_EXTRA_CONFIG="--nfp --with-cpu=xscale  --without-fp"

--------------------------------
gcc-3.3.2-glibc-2.3.2.dat
--------------------------------
BINUTILS_DIR=binutils-2.14.90.0.5
BINUTILS_URL=http://www.kernel.org/pub/linux/devel/binutils
GCC_DIR=gcc-3.3.2
GLIBC_DIR=glibc-2.3.2
LINUX_DIR=linux-2.4.21
GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.2

------------------------
Patch for gcc-3.3.2
------------------------
diff -ubr gcc-3.3.2/gcc/config/arm/arm.h
../build/armv5b-linux/gcc-3.3.2-glibc-2.3.2/gcc-3.3.2/gcc/config/arm/arm.h
--- gcc-3.3.2/gcc/config/arm/arm.h 2002-11-15 19:21:36.000000000 +0800
+++ gcc-3.3.2/gcc/config/arm/arm.h 2003-11-22 17:58:15.000000000 +0800
@@ -577,9 +577,11 @@
 extern int arm_is_6_or_7;

 #ifndef TARGET_DEFAULT
-#define TARGET_DEFAULT  (ARM_FLAG_APCS_FRAME)
+#define TARGET_DEFAULT  (ARM_FLAG_APCS_FRAME | ARM_FLAG_SOFT_FLOAT)
 #endif

+#define CPP_FLOAT_DEFAULT_SPEC "-D__SOFTFP__"
+
 /* The frame pointer register used in gcc has nothing to do with debugging;
    that is controlled by the APCS-FRAME option.  */
 #define CAN_DEBUG_WITHOUT_FP
diff -ubr gcc-3.3.2/gcc/config/arm/linux-elf.h
../build/armv5b-linux/gcc-3.3.2-glibc-2.3.2/gcc-3.3.2/gcc/config/arm/linux-e
lf.h
--- gcc-3.3.2/gcc/config/arm/linux-elf.h 2003-09-16 23:39:23.000000000 +0800
+++ gcc-3.3.2/gcc/config/arm/linux-elf.h 2003-11-22 18:01:43.000000000 +0800
@@ -32,13 +32,13 @@

 /* Default is to use APCS-32 mode.  */
 #undef  TARGET_DEFAULT
-#define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS)
+#define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS |
ARM_FLAG_BIG_END)

-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
+#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p "

 #undef  MULTILIB_DEFAULTS
 #define MULTILIB_DEFAULTS \
- { "marm", "mlittle-endian", "mhard-float", "mapcs-32",
"mno-thumb-interwork" }
+ { "marm", "mbig-endian", "msoft-float", "mapcs-32",
"mno-thumb-interwork" }

 #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"

@@ -52,7 +52,7 @@
    %{shared:-lc} \
    %{!shared:%{profile:-lc_p}%{!profile:-lc}}"

-#define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
+#define LIBGCC_SPEC "-lgcc"

 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
    the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
@@ -86,7 +86,7 @@
    %{rdynamic:-export-dynamic} \
    %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
    -X \
-   %{mbig-endian:-EB}" \
+   %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
    SUBTARGET_EXTRA_LINK_SPEC

 #define TARGET_OS_CPP_BUILTINS()  \
@@ -111,8 +111,8 @@
   while (0)

 /* NWFPE always understands FPA instructions.  */
-#undef  FP_DEFAULT
-#define FP_DEFAULT FP_SOFT3
+
+

 /* Call the function profiler with a given profile label.  */
 #undef  ARM_FUNCTION_PROFILER
@@ -122,7 +122,9 @@
 }

 #undef  CC1_SPEC
-#define CC1_SPEC "%{profile:-p}"
+#define CC1_SPEC "%{profile:-p} %{!msoft-float:-msoft-float}
%{!mbig-endian: -mbig-endian}"
+#undef ASM_SPEC
+#define ASM_SPEC "%{!mbig-endian: -EB} %{mcpu=*:-m%*} %{march=*:-m%*}
%{mapcs-*:-mapcs-%*} %{mapcs-float:-mfloat} %{!mno-fpu:-mno-fpu}
%{mthumb-interwork:-mthumb-interwork} %(subtarget_extra_asm_spec)"

 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
diff -ubr gcc-3.3.2/gcc/config/arm/t-linux
../build/armv5b-linux/gcc-3.3.2-glibc-2.3.2/gcc-3.3.2/gcc/config/arm/t-linux
--- gcc-3.3.2/gcc/config/arm/t-linux 2001-05-17 11:15:49.000000000 +0800
+++ gcc-3.3.2/gcc/config/arm/t-linux 2003-11-22 17:54:14.000000000 +0800
@@ -9,8 +9,8 @@
 LIB1ASMSRC = arm/lib1funcs.asm
 LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx

-# MULTILIB_OPTIONS = mhard-float/msoft-float
-# MULTILIB_DIRNAMES = hard-float soft-float
+EXTRA_MULTILIB_PARTS = crtbegin.o crtbeginS.o crtend.o crtendS.o crti.o
crtn.o
+

 # If you want to build both APCS variants as multilib options this is how
 # to do it.
@@ -21,3 +21,35 @@

 # LIBGCC = stmp-multilib
 # INSTALL_LIBGCC = install-multilib
+
+FPBIT = fp-bit.c
+DPBIT = dp-bit.c
+
+fp-bit.c: $(srcdir)/config/fp-bit.c
+ echo '#define FLOAT' > fp-bit.c
+ echo '#ifndef __ARMEB__' >> fp-bit.c
+ echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
+ echo '#endif' >> fp-bit.c
+ cat $(srcdir)/config/fp-bit.c >> fp-bit.c
+
+dp-bit.c: $(srcdir)/config/fp-bit.c
+ echo '#ifndef __ARMEB__' > dp-bit.c
+ echo '#define FLOAT_BIT_ORDER_MISMATCH' >> dp-bit.c
+ echo '#define FLOAT_WORD_ORDER_MISMATCH' >> dp-bit.c
+ echo '#endif' >> dp-bit.c
+ cat $(srcdir)/config/fp-bit.c >> dp-bit.c
+
+# Currently there is a bug somewhere in GCC's alias analysis
+# or scheduling code that is breaking _fpmul_parts in fp-bit.c.
+# Disabling function inlining is a workaround for this problem.
+TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc -fno-inline
+
+# Assemble startup files.
+$(T)crti.o: $(srcdir)/config/arm/crti.asm $(GCC_PASSES)
+ $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+ -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/arm/crti.asm
+
+$(T)crtn.o: $(srcdir)/config/arm/crtn.asm $(GCC_PASSES)
+ $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+ -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/arm/crtn.asm
+

---------------------------
Patch for glibc-2.3.2
---------------------------
diff -ubr glibc-2.3.2/sysdeps/arm/strlen.S
/synosrc/crosstool-0.25/build/armv5b-linux/gcc-3.3.2-glibc-2.3.2/glibc-2.3.2
/sysdeps/arm/strlen.S
--- glibc-2.3.2/sysdeps/arm/strlen.S 2001-07-08 03:21:19.000000000 +0800
+++ glibc-2.3.2/sysdeps/arm/strlen.S 2003-11-20 11:36:31.000000000 +0800
@@ -53,11 +53,20 @@
  ldrne   r2, [r1], $4            @ and we continue to the next word
  bne     Laligned                @
 Llastword:    @ drop through to here once we find a
+#ifdef __ARMEB__
+ tst     r2, $0xff000000         @ word that has a zero byte in it
+ addne   r0, r0, $1              @
+ tstne   r2, $0x00ff0000         @ and add up to 3 bytes on to it
+ addne   r0, r0, $1              @
+ tstne   r2, $0x0000ff00         @ (if first three all non-zero, 4th
+ addne   r0, r0, $1              @  must be zero)
+#else
  tst     r2, $0x000000ff         @ word that has a zero byte in it
  addne   r0, r0, $1              @
  tstne   r2, $0x0000ff00         @ and add up to 3 bytes on to it
  addne   r0, r0, $1              @
  tstne   r2, $0x00ff0000         @ (if first three all non-zero, 4th
  addne   r0, r0, $1              @  must be zero)
+#endif
  RETINSTR(mov,pc,lr)
 END(strlen)

--------------------------------------
Patch for binutils-2.14.90.7
--------------------------------------
diff -ubr binutils-2.14.90.0.7/gas/configure
binutils-2.14.90.0.7.new/gas/configure
--- binutils-2.14.90.0.7/gas/configure 2003-10-30 01:37:48.000000000 +0800
+++ binutils-2.14.90.0.7/gas/configure 2003-11-22 18:22:11.000000000 +0800
@@ -3963,7 +3963,7 @@
       am33_2.0)  cpu_type=mn10300 endian=little ;;
       alpha*)  cpu_type=alpha ;;
       arm*b|xscale*b|strongarm*b) cpu_type=arm endian=big ;;
-      arm*|xscale*|strongarm*)    cpu_type=arm endian=little ;;
+      arm*|xscale*|strongarm*)    cpu_type=arm endian=big ;;
       c4x*)  cpu_type=tic4x ;;
       hppa*)  cpu_type=hppa ;;
       i[3-7]86)  cpu_type=i386 arch=i386;;
diff -ubr binutils-2.14.90.0.7/ld/configure.tgt
binutils-2.14.90.0.7.new/ld/configure.tgt
--- binutils-2.14.90.0.7/ld/configure.tgt 2003-10-30 01:37:48.000000000
+0800
+++ binutils-2.14.90.0.7/ld/configure.tgt 2003-11-22 18:21:22.000000000
+0800
@@ -255,7 +255,7 @@
 arm-*-kaos*)  targ_emul=armelf ;;
 arm9e-*-elf)  targ_emul=armelf ;;
 arm-*-oabi)  targ_emul=armelf_oabi ;;
-arm*b-*-linux-gnu*) targ_emul=armelfb_linux; targ_extra_emuls=armelfb ;;
+arm*b-*-linux-gnu*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
 arm*-*-linux-gnu*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
 arm*-*-uclinux*) targ_emul=armelf_linux; targ_extra_emuls=armelf ;;
 arm*-*-conix*)  targ_emul=armelf ;;
diff -ubr binutils-2.14.90.0.7/ld/emulparams/armelf_linux.sh
binutils-2.14.90.0.7.new/ld/emulparams/armelf_linux.sh
--- binutils-2.14.90.0.7/ld/emulparams/armelf_linux.sh 2003-10-30
01:37:48.000000000 +0800
+++ binutils-2.14.90.0.7/ld/emulparams/armelf_linux.sh 2003-11-22
18:19:43.000000000 +0800
@@ -1,6 +1,6 @@
 ARCH=arm
 SCRIPT_NAME=elf
-OUTPUT_FORMAT="elf32-littlearm"
+OUTPUT_FORMAT="elf32-bigarm"
 BIG_OUTPUT_FORMAT="elf32-bigarm"
 LITTLE_OUTPUT_FORMAT="elf32-littlearm"
 MAXPAGESIZE=0x8000


-------------------------------------------------------------------
Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ/Etiquette:       http://www.arm.linux.org.uk/armlinux/mailinglists.php

[Linux ARM]     [Linux ARM MSM]     [Linux ARM Kernel]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Tools]     [DDR & Rambus]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

Add to Google Google PageRank Checking tool