binutils/binultils: import binutils-2.20 patches from OE
authorJoachim Nilsson <jocke@vmlinux.org>
Thu Jan 07 01:08:08 2010 +0100 (2010-01-07)
changeset 1700eccc37dd1a25
parent 1699 10e9f9b59289
child 1701 5c246abe7716
binutils/binultils: import binutils-2.20 patches from OE

This is a set of patches for binutils-2.20 that have been "ported", or rather
shamelessly stolen, from the OpenEmbedded project:

http://cgit.openembedded.org/cgit.cgi/openembedded/tree/recipes/binutils/binutils-2.20

Tried and tested on Arm (big-endian Xscale, and little-endian i.MX27) with GCC 4.4.2

Signed-off-by: Joachim Nilsson <jocke@vmlinux.org>
patches/binutils/2.20/240-ld_makefile.patch
patches/binutils/2.20/250-arm-eabi-conf.patch
patches/binutils/2.20/260-arm-non-empty-know.patch
patches/binutils/2.20/270-better_file_error.patch
patches/binutils/2.20/280-unexport_LD_LIBRARY_PATH.patch
patches/binutils/2.20/290-ld-stub-crash.patch
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/binutils/2.20/240-ld_makefile.patch	Thu Jan 07 01:08:08 2010 +0100
     1.3 @@ -0,0 +1,25 @@
     1.4 +Description: correct where ld scripts are installed
     1.5 +Author: Chris Chimelis <chris@debian.org>
     1.6 +
     1.7 +--- binutils-2.16.91.0.1/ld/Makefile.am
     1.8 ++++ binutils-2.16.91.0.1/ld/Makefile.am
     1.9 +@@ -20,7 +20,7 @@
    1.10 + # We put the scripts in the directory $(scriptdir)/ldscripts.
    1.11 + # We can't put the scripts in $(datadir) because the SEARCH_DIR
    1.12 + # directives need to be different for native and cross linkers.
    1.13 +-scriptdir = $(tooldir)/lib
    1.14 ++scriptdir = $(libdir)
    1.15 + 
    1.16 + EMUL = @EMUL@
    1.17 + EMULATION_OFILES = @EMULATION_OFILES@
    1.18 +--- binutils-2.16.91.0.1/ld/Makefile.in
    1.19 ++++ binutils-2.16.91.0.1/ld/Makefile.in
    1.20 +@@ -268,7 +268,7 @@
    1.21 + # We put the scripts in the directory $(scriptdir)/ldscripts.
    1.22 + # We can't put the scripts in $(datadir) because the SEARCH_DIR
    1.23 + # directives need to be different for native and cross linkers.
    1.24 +-scriptdir = $(tooldir)/lib
    1.25 ++scriptdir = $(libdir)
    1.26 + BASEDIR = $(srcdir)/..
    1.27 + BFDDIR = $(BASEDIR)/bfd
    1.28 + INCDIR = $(BASEDIR)/include
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/patches/binutils/2.20/250-arm-eabi-conf.patch	Thu Jan 07 01:08:08 2010 +0100
     2.3 @@ -0,0 +1,24 @@
     2.4 +diff -u binutils-2.20.orig/configure binutils-2.20/configure
     2.5 +--- binutils-2.20.orig/configure	2010-01-05 11:15:44.000000000 +0100
     2.6 ++++ binutils-2.20/configure	2010-01-05 12:25:41.000000000 +0100
     2.7 +@@ -3086,7 +3086,7 @@
     2.8 +     noconfigdirs="$noconfigdirs target-libffi target-qthreads"
     2.9 +     libgloss_dir=arm
    2.10 +     ;;
    2.11 +-  arm*-*-linux-gnueabi)
    2.12 ++  arm*-*-linux-*gnueabi)
    2.13 +     noconfigdirs="$noconfigdirs target-qthreads"
    2.14 +     case ${with_newlib} in
    2.15 +       no) noconfigdirs="$noconfigdirs target-newlib target-libgloss"
    2.16 +diff -u binutils-2.20.orig/configure.ac binutils-2.20/configure.ac
    2.17 +--- binutils-2.20.orig/configure.ac	2010-01-05 11:15:44.000000000 +0100
    2.18 ++++ binutils-2.20/configure.ac	2010-01-05 12:25:51.000000000 +0100
    2.19 +@@ -573,7 +573,7 @@
    2.20 +     noconfigdirs="$noconfigdirs target-libffi target-qthreads"
    2.21 +     libgloss_dir=arm
    2.22 +     ;;
    2.23 +-  arm*-*-linux-gnueabi)
    2.24 ++  arm*-*-linux-*gnueabi)
    2.25 +     noconfigdirs="$noconfigdirs target-qthreads"
    2.26 +     case ${with_newlib} in
    2.27 +       no) noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/patches/binutils/2.20/260-arm-non-empty-know.patch	Thu Jan 07 01:08:08 2010 +0100
     3.3 @@ -0,0 +1,18 @@
     3.4 +This is backported partially from 2.20 branch
     3.5 +
     3.6 +http://sourceware.org/ml/binutils-cvs/2009-10/msg00173.html
     3.7 +
     3.8 +-Khem
     3.9 +Index: binutils-2.20/gas/as.h
    3.10 +===================================================================
    3.11 +--- binutils-2.20.orig/gas/as.h	2009-10-22 00:27:08.700469349 -0700
    3.12 ++++ binutils-2.20/gas/as.h	2009-10-22 00:28:04.068416318 -0700
    3.13 +@@ -238,7 +238,7 @@ typedef addressT valueT;
    3.14 + #define know(p) gas_assert(p)	/* Verify our assumptions!  */
    3.15 + #endif /* not yet defined */
    3.16 + #else
    3.17 +-#define know(p)			/* know() checks are no-op.ed  */
    3.18 ++#define know(p) do {} while (0)	/* know() checks are no-op.ed  */
    3.19 + #endif
    3.20 + 
    3.21 + /* input_scrub.c */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/patches/binutils/2.20/270-better_file_error.patch	Thu Jan 07 01:08:08 2010 +0100
     4.3 @@ -0,0 +1,43 @@
     4.4 +#!/bin/sh -e
     4.5 +## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
     4.6 +##
     4.7 +## All lines beginning with `## DP:' are a description of the patch.
     4.8 +## DP: Specify which filename is causing an error if the filename is a
     4.9 +## DP: directory. (#45832)
    4.10 +
    4.11 +if [ $# -ne 1 ]; then
    4.12 +    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    4.13 +    exit 1
    4.14 +fi
    4.15 +
    4.16 +[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
    4.17 +patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
    4.18 +
    4.19 +case "$1" in
    4.20 +       -patch) patch $patch_opts -p1 < $0;;
    4.21 +       -unpatch) patch $patch_opts -p1 -R < $0;;
    4.22 +        *)
    4.23 +                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    4.24 +                exit 1;;
    4.25 +esac
    4.26 +
    4.27 +exit 0
    4.28 +
    4.29 +@DPATCH@
    4.30 +diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
    4.31 +--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c	2003-07-23 16:08:09.000000000 +0100
    4.32 ++++ binutils-2.14.90.0.6/bfd/opncls.c	2003-09-10 22:35:00.000000000 +0100
    4.33 +@@ -150,6 +150,13 @@
    4.34 + {
    4.35 +   bfd *nbfd;
    4.36 +   const bfd_target *target_vec;
    4.37 ++  struct stat s;
    4.38 ++
    4.39 ++  if (stat (filename, &s) == 0)
    4.40 ++    if (S_ISDIR(s.st_mode)) {
    4.41 ++      bfd_set_error (bfd_error_file_not_recognized);
    4.42 ++      return NULL;
    4.43 ++    }
    4.44 + 
    4.45 +   nbfd = _bfd_new_bfd ();
    4.46 +   if (nbfd == NULL)
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/patches/binutils/2.20/280-unexport_LD_LIBRARY_PATH.patch	Thu Jan 07 01:08:08 2010 +0100
     5.3 @@ -0,0 +1,95 @@
     5.4 +Description:
     5.5 +
     5.6 +This patch is needed in situations where build system is running same version of
     5.7 +binutils that is intended to be built  cross-native ( build != host = target)
     5.8 + and has shared libraries enabled. binutils/binutils
     5.9 +Makefile has some tools which are built to run on build system. Toplevel makefile
    5.10 +for binutils passes HOST_EXPORTS to sub-makefiles which also include RPATH_ENVVARS
    5.11 +containing LD_LIBRARY_PATH which is modified so that it also includes host libraries
    5.12 +like opcodes and libbfd which are just built for the host system. 
    5.13 +
    5.14 +Now the problem is that same LD_LIBRARY_PATH value gets set in environment even
    5.15 +for the tools that are being built for build system using CC_FOR_BUILD and the tools
    5.16 +like as,ld it invokes from build machine get the LD_LIBRARY_PATH set to search
    5.17 +the newly build host libraries like opcodes and bfd and if host is like a big endian
    5.18 +system say (mips-linux) the build system linker and assembler do not run because
    5.19 +ld.so tries to load these shared libraries instead of the ones from /usr/lib for 
    5.20 +the build tools. 
    5.21 +
    5.22 +This patch fixes the issue by clearing LD_LIBRARY_PATH for BUILD tools
    5.23 +
    5.24 +This patch would be needed on other versions of binutils. I just cared about 2.20
    5.25 +May be upstream is also interested in such a patch.
    5.26 +
    5.27 +-Khem
    5.28 +
    5.29 +Index: binutils-2.20/binutils/Makefile.am
    5.30 +===================================================================
    5.31 +--- binutils-2.20.orig/binutils/Makefile.am	2009-12-30 15:30:35.302438121 -0800
    5.32 ++++ binutils-2.20/binutils/Makefile.am	2009-12-30 15:33:09.154420373 -0800
    5.33 +@@ -251,24 +251,24 @@ sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sy
    5.34 + 	./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
    5.35 + 
    5.36 + sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
    5.37 +-	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    5.38 ++	LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    5.39 + 
    5.40 + syslex.o: syslex.c sysinfo.h config.h
    5.41 + 	if [ -r syslex.c ]; then \
    5.42 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
    5.43 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
    5.44 + 	else \
    5.45 +-	  $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
    5.46 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
    5.47 + 	fi
    5.48 + 
    5.49 + sysinfo.o: sysinfo.c
    5.50 + 	if [ -r sysinfo.c ]; then \
    5.51 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
    5.52 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
    5.53 + 	else \
    5.54 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
    5.55 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
    5.56 + 	fi
    5.57 + 
    5.58 + bin2c$(EXEEXT_FOR_BUILD):
    5.59 +-	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    5.60 ++	LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    5.61 + 
    5.62 + embedspu: embedspu.sh
    5.63 + 	sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@
    5.64 +Index: binutils-2.20/binutils/Makefile.in
    5.65 +===================================================================
    5.66 +--- binutils-2.20.orig/binutils/Makefile.in	2009-12-30 15:30:44.582922535 -0800
    5.67 ++++ binutils-2.20/binutils/Makefile.in	2009-12-30 15:33:47.322422313 -0800
    5.68 +@@ -1193,24 +1193,24 @@ sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sy
    5.69 + 	./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
    5.70 + 
    5.71 + sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
    5.72 +-	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    5.73 ++	LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    5.74 + 
    5.75 + syslex.o: syslex.c sysinfo.h config.h
    5.76 + 	if [ -r syslex.c ]; then \
    5.77 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
    5.78 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
    5.79 + 	else \
    5.80 +-	  $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
    5.81 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
    5.82 + 	fi
    5.83 + 
    5.84 + sysinfo.o: sysinfo.c
    5.85 + 	if [ -r sysinfo.c ]; then \
    5.86 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
    5.87 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
    5.88 + 	else \
    5.89 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
    5.90 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
    5.91 + 	fi
    5.92 + 
    5.93 + bin2c$(EXEEXT_FOR_BUILD):
    5.94 +-	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    5.95 ++	LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    5.96 + 
    5.97 + embedspu: embedspu.sh
    5.98 + 	sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/patches/binutils/2.20/290-ld-stub-crash.patch	Thu Jan 07 01:08:08 2010 +0100
     6.3 @@ -0,0 +1,22 @@
     6.4 +diff -p -c -u -r1.196 elf32-arm.c
     6.5 +--- a/bfd/elf32-arm.c	22 May 2009 11:58:44 -0000	1.196
     6.6 ++++ b/bfd/elf32-arm.c	12 Jun 2009 13:18:20 -0000
     6.7 +@@ -3175,11 +3175,15 @@ arm_type_of_stub (struct bfd_link_info *
     6.8 + 
     6.9 + 	  /* We have an extra 2-bytes reach because of
    6.10 + 	     the mode change (bit 24 (H) of BLX encoding).  */
    6.11 ++	  /* A stub is needed only if this call is not throught a PLT
    6.12 ++	     entry, because PLT stubs handle mode switching
    6.13 ++	     already.  */
    6.14 + 	  if (branch_offset > (ARM_MAX_FWD_BRANCH_OFFSET + 2)
    6.15 + 	      || (branch_offset < ARM_MAX_BWD_BRANCH_OFFSET)
    6.16 +-	      || ((r_type == R_ARM_CALL) && !globals->use_blx)
    6.17 +-	      || (r_type == R_ARM_JUMP24)
    6.18 +-	      || (r_type == R_ARM_PLT32))
    6.19 ++	      || ( (((r_type == R_ARM_CALL) && !globals->use_blx)
    6.20 ++		    || (r_type == R_ARM_JUMP24)
    6.21 ++		    || (r_type == R_ARM_PLT32))
    6.22 ++		   && !use_plt))
    6.23 + 	    {
    6.24 + 	      stub_type = (info->shared | globals->pic_veneer)
    6.25 + 		/* PIC stubs.  */