changeset 1704:3675adfb4e36 draft

Add basic elf2flt support to simple-cross-compiler.sh and sh2eb.
author Rob Landley <rob@landley.net>
date Fri, 07 Nov 2014 08:49:26 -0600
parents 828d2e318e26
children 012df19f8569
files download.sh simple-cross-compiler.sh sources/patches/elf2flt-make.patch sources/sections/binutils.build sources/sections/elf2flt.build sources/targets/sh2eb
diffstat 6 files changed, 62 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/download.sh	Mon Oct 27 22:00:11 2014 -0500
+++ b/download.sh	Fri Nov 07 08:49:26 2014 -0600
@@ -39,10 +39,18 @@
 # _version_ of binutils. This tarball has prebuilt release files
 # so it builds without optional dependencies such as lex and yacc.
 
-URL=http://landley.net/aboriginal/mirror/binutils-397a64b3.tar.bz2
+URL=http://landley.net/aboriginal/mirror/binutils-397a64b3.tar.bz2 \
 SHA1=f74f1ce2e62c516ba832f99a94289930be7869cf \
 maybe_fork "download || dienow"
 
+# elf2flt needed for nommu targets which can't mmap() the elf segments.
+# The upstream cvs on uclinux.org went away, and binutils uses a random
+# git repository with no tarballs.
+
+URL=http://landley.net/aboriginal/mirror/elf2flt-21c6a418.tar.gz \
+SHA1=62bcd6acefe5ea34938e9357fc2853ac1181bf10 \
+maybe_fork "download || dienow"
+
 # 4.2.1 was the last GPLv2 release of gcc
 
 URL=ftp://ftp.gnu.org/gnu/gcc/gcc-4.2.1/gcc-core-4.2.1.tar.bz2 \
--- a/simple-cross-compiler.sh	Mon Oct 27 22:00:11 2014 -0500
+++ b/simple-cross-compiler.sh	Fri Nov 07 08:49:26 2014 -0600
@@ -27,6 +27,7 @@
 # Build binutils, gcc, and ccwrap
 
 build_section binutils
+[ ! -z "$ELF2FLT" ] && build_section elf2flt
 build_section gcc
 build_section ccwrap
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/patches/elf2flt-make.patch	Fri Nov 07 08:49:26 2014 -0600
@@ -0,0 +1,38 @@
+Remove nonexistent header (which apparently has no symbols we need),
+and teach makefile that the prefix can be something other than full target name.
+
+diff -ruN elf2flt/ld-elf2flt.c elf2flt.bak/ld-elf2flt.c
+--- elf2flt/ld-elf2flt.c	2012-10-03 21:32:38.000000000 -0500
++++ elf2flt.bak/ld-elf2flt.c	2014-11-06 23:42:35.703148578 -0600
+@@ -24,7 +24,6 @@
+ #include <unistd.h>
+ #include <errno.h>
+ #include <libiberty.h>
+-#include <filenames.h>
+ 
+ #include "stubs.h"
+ const char *elf2flt_progname;
+diff -ruN elf2flt/Makefile.in elf2flt.bak/Makefile.in
+--- elf2flt/Makefile.in	2012-10-03 21:32:38.000000000 -0500
++++ elf2flt.bak/Makefile.in	2014-11-07 08:12:07.914832959 -0600
+@@ -97,15 +97,15 @@
+ 	$(INSTALL) -d $(bindir)
+ 	$(INSTALL) -d $(target_bindir)
+ 	$(INSTALL) -d $(target_libdir)
+-	$(INSTALL) -m 755 $(PROG_FLTHDR) $(bindir)/$(TARGET)-$(PROG_FLTHDR)
++	$(INSTALL) -m 755 $(PROG_FLTHDR) $(bindir)/$(PREFIX)$(PROG_FLTHDR)
+ 	$(INSTALL) -m 755 $(PROG_FLTHDR) $(target_bindir)/$(PROG_FLTHDR)
+-	$(INSTALL) -m 755 $(PROG_ELF2FLT) $(bindir)/$(TARGET)-$(PROG_ELF2FLT)
++	$(INSTALL) -m 755 $(PROG_ELF2FLT) $(bindir)/$(PREFIX)$(PROG_ELF2FLT)
+ 	$(INSTALL) -m 755 $(PROG_ELF2FLT) $(target_bindir)/$(PROG_ELF2FLT)
+-	[ -f $(bindir)/$(TARGET)-ld.real$(EXEEXT) ] || \
+-		mv $(bindir)/$(TARGET)-ld$(EXEEXT) $(bindir)/$(TARGET)-ld.real$(EXEEXT)
++	[ -f $(bindir)/$(PREFIX)ld.real$(EXEEXT) ] || \
++		mv $(bindir)/$(PREFIX)ld$(EXEEXT) $(bindir)/$(PREFIX)ld.real$(EXEEXT)
+ 	[ -f $(target_bindir)/ld.real$(EXEEXT) ] || \
+ 		mv $(target_bindir)/ld$(EXEEXT) $(target_bindir)/ld.real$(EXEEXT)
+-	$(INSTALL) -m 755 $(PROG_LD_ELF2FLT) $(bindir)/$(TARGET)-ld$(EXEEXT)
++	$(INSTALL) -m 755 $(PROG_LD_ELF2FLT) $(bindir)/$(PREFIX)ld$(EXEEXT)
+ 	$(INSTALL) -m 755 $(PROG_LD_ELF2FLT) $(target_bindir)/ld$(EXEEXT)
+ 	$(INSTALL) -m 644 $(SRC_LDFILE) $(target_libdir)/$(LDFILE)
+ 
--- a/sources/sections/binutils.build	Mon Oct 27 22:00:11 2014 -0500
+++ b/sources/sections/binutils.build	Fri Nov 07 08:49:26 2014 -0600
@@ -1,8 +1,13 @@
 # Build binutils, which provides the linker and assembler and such.
 
+if [ ! -z "$ELF2FLT" ]
+then
+  BINUTILS_FLAGS="$BINUTILS_FLAGS --enable-install-libbfd"
+fi
+
 function configure_binutils()
 {
-  AR=ar AS=as LD=ld NM=nm OBJDUMP=objdump OBJCOPY=objcopy \
+#  AR=ar AS=as LD=ld NM=nm OBJDUMP=objdump OBJCOPY=objcopy \
     "$CURSRC/configure" --prefix="$STAGE_DIR" "$@" --target="$CROSS_TARGET" \
     --disable-nls --disable-shared --disable-multilib --disable-werror \
     --with-lib-path=lib --program-prefix="$TOOLCHAIN_PREFIX" $BINUTILS_FLAGS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/sections/elf2flt.build	Fri Nov 07 08:49:26 2014 -0600
@@ -0,0 +1,7 @@
+./configure --with-bfd-include-dir="$STAGE_DIR/include" \
+  --with-binutils-include-dir="$STAGE_DIR/include" \
+  --with-libbfd="$STAGE_DIR/lib/libbfd.a" \
+  --with-libiberty="$STAGE_DIR/lib/libiberty.a" \
+  --target="$ELF2FLT" --prefix="$STAGE_DIR" &&
+make -j $CPUS &&
+make install TARGET="$CROSS_TARGET" PREFIX="$TOOLCHAIN_PREFIX"
--- a/sources/targets/sh2eb	Mon Oct 27 22:00:11 2014 -0500
+++ b/sources/targets/sh2eb	Fri Nov 07 08:49:26 2014 -0600
@@ -6,6 +6,7 @@
 KERNEL_PATH=arch/${KARCH}/boot/zImage
 GCC_FLAGS= #"--with-cpu=m4-nofpu"
 BINUTILS_FLAGS=
+ELF2FLT=sh-unknown-linux
 QEMU_TEST=$KARCH
 #CROSS_TARGET=sh2-unknown-linux