Progress towards dynamic linking on RISC-V
[akaros.git] / tools / compilers / gcc-glibc / binutils-2.21.1-riscv.patch
index e274daf..ae48d06 100644 (file)
@@ -1,5 +1,5 @@
-diff -ruN binutils-2.21.1-orig/bfd/archures.c binutils-2.21.1/bfd/archures.c
---- binutils-2.21.1-orig/bfd/archures.c        2010-07-23 07:52:46.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/archures.c binutils-2.21.1/bfd/archures.c
+--- ../binutils-2.21.1-orig/bfd/archures.c     2010-07-23 07:52:46.000000000 -0700
 +++ binutils-2.21.1/bfd/archures.c     2011-10-22 18:46:17.000000000 -0700
 @@ -515,6 +515,7 @@
  extern const bfd_arch_info_type bfd_plugin_arch;
@@ -17,8 +17,8 @@ diff -ruN binutils-2.21.1-orig/bfd/archures.c binutils-2.21.1/bfd/archures.c
      &bfd_rs6000_arch,
      &bfd_rx_arch,
      &bfd_s390_arch,
-diff -ruN binutils-2.21.1-orig/bfd/bfd-in2.h binutils-2.21.1/bfd/bfd-in2.h
---- binutils-2.21.1-orig/bfd/bfd-in2.h 2011-06-27 00:39:01.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/bfd-in2.h binutils-2.21.1/bfd/bfd-in2.h
+--- ../binutils-2.21.1-orig/bfd/bfd-in2.h      2011-06-27 00:39:01.000000000 -0700
 +++ binutils-2.21.1/bfd/bfd-in2.h      2011-10-22 18:46:17.000000000 -0700
 @@ -1919,6 +1919,9 @@
  #define bfd_mach_ppc_e500mc    5001
@@ -45,8 +45,8 @@ diff -ruN binutils-2.21.1-orig/bfd/bfd-in2.h binutils-2.21.1/bfd/bfd-in2.h
  /* This is used to tell the dynamic linker to copy the value out of
  the dynamic object into the runtime process image.  */
    BFD_RELOC_MICROBLAZE_COPY,
-diff -ruN binutils-2.21.1-orig/bfd/config.bfd binutils-2.21.1/bfd/config.bfd
---- binutils-2.21.1-orig/bfd/config.bfd        2011-04-01 05:02:42.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/config.bfd binutils-2.21.1/bfd/config.bfd
+--- ../binutils-2.21.1-orig/bfd/config.bfd     2011-04-01 05:02:42.000000000 -0700
 +++ binutils-2.21.1/bfd/config.bfd     2011-10-22 18:46:17.000000000 -0700
 @@ -96,6 +96,7 @@
  pdp11*)                targ_archs=bfd_pdp11_arch ;;
@@ -71,8 +71,8 @@ diff -ruN binutils-2.21.1-orig/bfd/config.bfd binutils-2.21.1/bfd/config.bfd
    rx-*-elf)
      targ_defvec=bfd_elf32_rx_le_vec
      targ_selvecs="bfd_elf32_rx_be_vec bfd_elf32_rx_le_vec"
-diff -ruN binutils-2.21.1-orig/bfd/configure binutils-2.21.1/bfd/configure
---- binutils-2.21.1-orig/bfd/configure 2011-06-27 01:57:12.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/configure binutils-2.21.1/bfd/configure
+--- ../binutils-2.21.1-orig/bfd/configure      2011-06-27 01:57:12.000000000 -0700
 +++ binutils-2.21.1/bfd/configure      2011-10-22 18:47:51.000000000 -0700
 @@ -15239,6 +15239,7 @@
      bfd_elf32_littlemips_vec)         tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
@@ -90,8 +90,8 @@ diff -ruN binutils-2.21.1-orig/bfd/configure binutils-2.21.1/bfd/configure
      bfd_elf64_mmix_vec)       tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
      bfd_elf64_powerpc_vec)    tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
      bfd_elf64_powerpcle_vec)  tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
-diff -ruN binutils-2.21.1-orig/bfd/configure.in binutils-2.21.1/bfd/configure.in
---- binutils-2.21.1-orig/bfd/configure.in      2011-06-27 01:57:10.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/configure.in binutils-2.21.1/bfd/configure.in
+--- ../binutils-2.21.1-orig/bfd/configure.in   2011-06-27 01:57:10.000000000 -0700
 +++ binutils-2.21.1/bfd/configure.in   2011-10-22 18:46:17.000000000 -0700
 @@ -730,6 +730,7 @@
      bfd_elf32_littlemips_vec)         tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
@@ -109,8 +109,8 @@ diff -ruN binutils-2.21.1-orig/bfd/configure.in binutils-2.21.1/bfd/configure.in
      bfd_elf64_mmix_vec)       tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
      bfd_elf64_powerpc_vec)    tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
      bfd_elf64_powerpcle_vec)  tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
-diff -ruN binutils-2.21.1-orig/bfd/cpu-riscv.c binutils-2.21.1/bfd/cpu-riscv.c
---- binutils-2.21.1-orig/bfd/cpu-riscv.c       1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/cpu-riscv.c binutils-2.21.1/bfd/cpu-riscv.c
+--- ../binutils-2.21.1-orig/bfd/cpu-riscv.c    1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/bfd/cpu-riscv.c    2011-10-22 18:50:03.000000000 -0700
 @@ -0,0 +1,78 @@
 +/* bfd back-end for mips support
@@ -191,8 +191,8 @@ diff -ruN binutils-2.21.1-orig/bfd/cpu-riscv.c binutils-2.21.1/bfd/cpu-riscv.c
 +
 +const bfd_arch_info_type bfd_riscv_arch =
 +N (64, 64, 0, "riscv", TRUE, &arch_info_struct[0]);
-diff -ruN binutils-2.21.1-orig/bfd/elf32-riscv.c binutils-2.21.1/bfd/elf32-riscv.c
---- binutils-2.21.1-orig/bfd/elf32-riscv.c     1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/elf32-riscv.c binutils-2.21.1/bfd/elf32-riscv.c
+--- ../binutils-2.21.1-orig/bfd/elf32-riscv.c  1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/bfd/elf32-riscv.c  2011-10-22 18:50:03.000000000 -0700
 @@ -0,0 +1,2300 @@
 +/* MIPS-specific support for 32-bit ELF
@@ -2495,9 +2495,9 @@ diff -ruN binutils-2.21.1-orig/bfd/elf32-riscv.c binutils-2.21.1/bfd/elf32-riscv
 +#define ELF_COMMONPAGESIZE            0x1000
 +
 +#include "elf32-target.h"
-diff -ruN binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv.c
---- binutils-2.21.1-orig/bfd/elf64-riscv.c     1969-12-31 16:00:00.000000000 -0800
-+++ binutils-2.21.1/bfd/elf64-riscv.c  2011-10-22 18:50:03.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv.c
+--- ../binutils-2.21.1-orig/bfd/elf64-riscv.c  1969-12-31 16:00:00.000000000 -0800
++++ binutils-2.21.1/bfd/elf64-riscv.c  2011-10-31 18:59:25.000000000 -0700
 @@ -0,0 +1,3298 @@
 +/* MIPS-specific support for 64-bit ELF
 +   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
@@ -3777,10 +3777,10 @@ diff -ruN binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv
 +       FALSE),                /* pcrel_offset */
 +
 +  /* TLS general dynamic variable reference.  */
-+  HOWTO (R_RISCV_TLS_GD,              /* type */
++  HOWTO (R_RISCV_TLS_GD,      /* type */
 +       0,                     /* rightshift */
 +       2,                     /* size (0 = byte, 1 = short, 2 = long) */
-+       RISCV_IMM_BITS,                        /* bitsize */
++       RISCV_IMM_BITS,        /* bitsize */
 +       FALSE,                 /* pc_relative */
 +       OP_SH_IMMEDIATE,       /* bitpos */
 +       complain_overflow_signed, /* complain_on_overflow */
@@ -3795,14 +3795,14 @@ diff -ruN binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv
 +  HOWTO (R_RISCV_TLS_LDM,     /* type */
 +       0,                     /* rightshift */
 +       2,                     /* size (0 = byte, 1 = short, 2 = long) */
-+       RISCV_IMM_BITS,                        /* bitsize */
++       RISCV_IMM_BITS,        /* bitsize */
 +       FALSE,                 /* pc_relative */
 +       OP_SH_IMMEDIATE,       /* bitpos */
 +       complain_overflow_signed, /* complain_on_overflow */
 +       _bfd_riscv_elf_generic_reloc, /* special_function */
 +       "R_RISCV_TLS_LDM",     /* name */
 +       TRUE,                  /* partial_inplace */
-+       (RISCV_IMM_REACH-1) << OP_SH_IMMEDIATE,        /* src_mask */
++       0,                     /* src_mask */
 +       (RISCV_IMM_REACH-1) << OP_SH_IMMEDIATE,        /* dst_mask */
 +       FALSE),                /* pcrel_offset */
 +
@@ -3810,14 +3810,14 @@ diff -ruN binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv
 +  HOWTO (R_RISCV_TLS_DTPREL_HI16,     /* type */
 +       0,                     /* rightshift */
 +       2,                     /* size (0 = byte, 1 = short, 2 = long) */
-+       RISCV_BIGIMM_BITS,                     /* bitsize */
++       RISCV_BIGIMM_BITS,     /* bitsize */
 +       FALSE,                 /* pc_relative */
 +       OP_SH_BIGIMMEDIATE,    /* bitpos */
 +       complain_overflow_signed, /* complain_on_overflow */
 +       _bfd_riscv_elf_generic_reloc, /* special_function */
 +       "R_RISCV_TLS_DTPREL_HI16",     /* name */
 +       TRUE,                  /* partial_inplace */
-+       ((1<<RISCV_BIGIMM_BITS)-1) << OP_SH_BIGIMMEDIATE,      /* src_mask */
++       0,                     /* src_mask */
 +       ((1<<RISCV_BIGIMM_BITS)-1) << OP_SH_BIGIMMEDIATE,      /* dst_mask */
 +       FALSE),                /* pcrel_offset */
 +
@@ -3825,14 +3825,14 @@ diff -ruN binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv
 +  HOWTO (R_RISCV_TLS_DTPREL_LO16,     /* type */
 +       0,                     /* rightshift */
 +       2,                     /* size (0 = byte, 1 = short, 2 = long) */
-+       RISCV_IMM_BITS,                        /* bitsize */
++       RISCV_IMM_BITS,        /* bitsize */
 +       FALSE,                 /* pc_relative */
 +       OP_SH_IMMEDIATE,       /* bitpos */
 +       complain_overflow_signed, /* complain_on_overflow */
 +       _bfd_riscv_elf_generic_reloc, /* special_function */
 +       "R_RISCV_TLS_DTPREL_LO16",     /* name */
 +       TRUE,                  /* partial_inplace */
-+       (RISCV_IMM_REACH-1) << OP_SH_IMMEDIATE,        /* src_mask */
++       0,                     /* src_mask */
 +       (RISCV_IMM_REACH-1) << OP_SH_IMMEDIATE,        /* dst_mask */
 +       FALSE),                /* pcrel_offset */
 +
@@ -3840,14 +3840,14 @@ diff -ruN binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv
 +  HOWTO (R_RISCV_TLS_GOTTPREL,        /* type */
 +       0,                     /* rightshift */
 +       2,                     /* size (0 = byte, 1 = short, 2 = long) */
-+       RISCV_IMM_BITS,                        /* bitsize */
++       RISCV_IMM_BITS,        /* bitsize */
 +       FALSE,                 /* pc_relative */
 +       OP_SH_IMMEDIATE,       /* bitpos */
 +       complain_overflow_signed, /* complain_on_overflow */
 +       _bfd_riscv_elf_generic_reloc, /* special_function */
 +       "R_RISCV_TLS_GOTTPREL",        /* name */
 +       TRUE,                  /* partial_inplace */
-+       (RISCV_IMM_REACH-1) << OP_SH_IMMEDIATE,        /* src_mask */
++       0,                     /* src_mask */
 +       (RISCV_IMM_REACH-1) << OP_SH_IMMEDIATE,        /* dst_mask */
 +       FALSE),                /* pcrel_offset */
 +
@@ -3871,14 +3871,14 @@ diff -ruN binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv
 +  HOWTO (R_RISCV_TLS_TPREL_HI16,      /* type */
 +       0,                     /* rightshift */
 +       2,                     /* size (0 = byte, 1 = short, 2 = long) */
-+       RISCV_BIGIMM_BITS,                     /* bitsize */
++       RISCV_BIGIMM_BITS,     /* bitsize */
 +       FALSE,                 /* pc_relative */
 +       OP_SH_BIGIMMEDIATE,    /* bitpos */
 +       complain_overflow_signed, /* complain_on_overflow */
 +       _bfd_riscv_elf_generic_reloc, /* special_function */
 +       "R_RISCV_TLS_TPREL_HI16", /* name */
 +       TRUE,                  /* partial_inplace */
-+       ((1<<RISCV_BIGIMM_BITS)-1) << OP_SH_BIGIMMEDIATE,      /* src_mask */
++       0,                     /* src_mask */
 +       ((1<<RISCV_BIGIMM_BITS)-1) << OP_SH_BIGIMMEDIATE,      /* dst_mask */
 +       FALSE),                /* pcrel_offset */
 +
@@ -3886,14 +3886,14 @@ diff -ruN binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv
 +  HOWTO (R_RISCV_TLS_TPREL_LO16,      /* type */
 +       0,                     /* rightshift */
 +       2,                     /* size (0 = byte, 1 = short, 2 = long) */
-+       RISCV_IMM_BITS,                        /* bitsize */
++       RISCV_IMM_BITS,        /* bitsize */
 +       FALSE,                 /* pc_relative */
 +       OP_SH_IMMEDIATE,       /* bitpos */
 +       complain_overflow_signed, /* complain_on_overflow */
 +       _bfd_riscv_elf_generic_reloc, /* special_function */
 +       "R_RISCV_TLS_TPREL_LO16", /* name */
 +       TRUE,                  /* partial_inplace */
-+       (RISCV_IMM_REACH-1) << OP_SH_IMMEDIATE,        /* src_mask */
++       0,                     /* src_mask */
 +       (RISCV_IMM_REACH-1) << OP_SH_IMMEDIATE,        /* dst_mask */
 +       FALSE),                /* pcrel_offset */
 +
@@ -5797,11 +5797,10 @@ diff -ruN binutils-2.21.1-orig/bfd/elf64-riscv.c binutils-2.21.1/bfd/elf64-riscv
 +#define ELF_COMMONPAGESIZE            0x1000
 +
 +#include "elf64-target.h"
-diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.c binutils-2.21.1/bfd/elfxx-riscv.c
---- binutils-2.21.1-orig/bfd/elfxx-riscv.c     1969-12-31 16:00:00.000000000 -0800
-+++ binutils-2.21.1/bfd/elfxx-riscv.c  2011-10-22 18:50:03.000000000 -0700
-@@ -0,0 +1,9383 @@
-+/* vim: set ts=8 */
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/elfxx-riscv.c binutils-2.21.1/bfd/elfxx-riscv.c
+--- ../binutils-2.21.1-orig/bfd/elfxx-riscv.c  1969-12-31 16:00:00.000000000 -0800
++++ binutils-2.21.1/bfd/elfxx-riscv.c  2011-11-01 23:35:35.000000000 -0700
+@@ -0,0 +1,9403 @@
 +/* MIPS-specific support for ELF
 +   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 +   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
@@ -6472,8 +6471,22 @@ diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.c binutils-2.21.1/bfd/elfxx-riscv
 +  (ELF32_R_INFO (s, t))
 +#endif
 +
++#define IS_STORE_RELOC(bfd, reloc, opcode) \
++  ((ELF_R_TYPE (bfd, reloc) == R_RISCV_LO16           \
++    || ELF_R_TYPE (bfd, reloc) == R_RISCV_TLS_TPREL_LO16      \
++    || ELF_R_TYPE (bfd, reloc) == R_RISCV_TLS_DTPREL_LO16)    \
++   && OPCODE_IS_STORE(opcode))
++
 +#define MATCH_LREG(abfd) (ABI_64_P(abfd) ? MATCH_LD : MATCH_LW)
 +
++#define OPCODE_MATCHES(OPCODE, OP) \
++  (((OPCODE) & MASK_##OP) == MATCH_##OP)
++
++#define OPCODE_IS_STORE(OPCODE) \
++  (OPCODE_MATCHES(OPCODE, SD)  || OPCODE_MATCHES(OPCODE, SW) || \
++   OPCODE_MATCHES(OPCODE, SH)  || OPCODE_MATCHES(OPCODE, SB) || \
++   OPCODE_MATCHES(OPCODE, FSW) || OPCODE_MATCHES(OPCODE, FSD))
++
 +/* The format of the first PLT entry.  */
 +
 +#define RISCV_PLT0_ENTRY_INSNS 8
@@ -7228,14 +7241,25 @@ diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.c binutils-2.21.1/bfd/elfxx-riscv
 +    reloc_entry->addend += val;
 +  else
 +    {
-+      bfd_byte *location = (bfd_byte *) data + reloc_entry->address;
++      bfd_byte *loc = (bfd_byte *) data + reloc_entry->address;
++      struct reloc_howto_struct howto = *reloc_entry->howto;
 +
 +      /* Add in the separate addend, if any.  */
 +      val += reloc_entry->addend;
 +
-+      /* Add VAL to the relocation field.  */
-+      status = _bfd_relocate_contents (reloc_entry->howto, abfd, val,
-+                                     location);
++      /* Fix up dst_mask and value for R_RISCV_LO16 relocs on stores. */
++      if (IS_STORE_RELOC (abfd, howto.type,
++              bfd_big_endian(abfd) ? bfd_getb32(loc) : bfd_getl32(loc)))
++      {
++        val >>= OP_SH_IMMEDIATE;
++        val = ((val >> RISCV_IMMLO_BITS) << OP_SH_IMMHI) |
++              ((val & ((1<<RISCV_IMMLO_BITS)-1)) << OP_SH_IMMLO);
++        howto.dst_mask = (OP_MASK_IMMHI << OP_SH_IMMHI) | 
++                         (OP_MASK_IMMLO << OP_SH_IMMLO);
++      }
++
++      /* Add VAL to the reloc field.  */
++      status = _bfd_relocate_contents (&howto, abfd, val, loc);
 +
 +      if (status != bfd_reloc_ok)
 +      return status;
@@ -9968,16 +9992,18 @@ diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.c binutils-2.21.1/bfd/elfxx-riscv
 +    case R_RISCV_TLS_DTPREL_LO16:
 +    case R_RISCV_TLS_DTPREL32:
 +    case R_RISCV_TLS_DTPREL64:
-+      value = (symbol + addend - dtprel_base (info)) & howto->dst_mask;
++      value = ((addend + symbol - dtprel_base (info))
++              << OP_SH_IMMEDIATE) & howto->dst_mask;
 +      break;
 +
 +    case R_RISCV_TLS_TPREL_HI16:
-+      value = ((mips_elf_high (addend + symbol - tprel_base (info))
-+              << OP_SH_BIGIMMEDIATE) & howto->dst_mask);
++      value = (mips_elf_high (addend + symbol - tprel_base (info))
++             << OP_SH_BIGIMMEDIATE) & howto->dst_mask;
 +      break;
 +
 +    case R_RISCV_TLS_TPREL_LO16:
-+      value = (symbol + addend - tprel_base (info)) & howto->dst_mask;
++      value = ((symbol + addend - tprel_base (info))
++              << OP_SH_IMMEDIATE) & howto->dst_mask;
 +      break;
 +
 +    case R_RISCV_HI16:
@@ -10151,20 +10177,14 @@ diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.c binutils-2.21.1/bfd/elfxx-riscv
 +  /* Obtain the current value.  */
 +  x = mips_elf_obtain_contents (howto, relocation, input_bfd, contents);
 +
-+  /* Fix up dst_mask and value for R_MIPS_LO16 relocs on stores. */
-+  if(ELF_R_TYPE (input_bfd, relocation->r_info) == R_MIPS_LO16 &&
-+     ((x & MASK_SD)  == MATCH_SD  ||
-+      (x & MASK_SW)  == MATCH_SW  ||
-+      (x & MASK_SH)  == MATCH_SH  ||
-+      (x & MASK_SB)  == MATCH_SB  ||
-+      (x & MASK_FSW) == MATCH_FSW ||
-+      (x & MASK_FSD) == MATCH_FSD))
-+  {
-+    value >>= OP_SH_IMMEDIATE;
-+    value = ((value >> RISCV_IMMLO_BITS) << OP_SH_IMMHI) |
-+            ((value & ((1<<RISCV_IMMLO_BITS)-1)) << OP_SH_IMMLO);
-+    dst_mask = (OP_MASK_IMMHI << OP_SH_IMMHI) | (OP_MASK_IMMLO << OP_SH_IMMLO);
-+  }
++  /* Fix up dst_mask and value for R_RISCV_LO16 relocs on stores. */
++  if (IS_STORE_RELOC (input_bfd, relocation->r_info, x))
++    {
++      value >>= OP_SH_IMMEDIATE;
++      value = ((value >> RISCV_IMMLO_BITS) << OP_SH_IMMHI) |
++            ((value & ((1<<RISCV_IMMLO_BITS)-1)) << OP_SH_IMMLO);
++      dst_mask = (OP_MASK_IMMHI << OP_SH_IMMHI) | (OP_MASK_IMMLO << OP_SH_IMMLO);
++    }
 +
 +  /* Clear the field we are setting.  */
 +  x &= ~dst_mask;
@@ -12731,7 +12751,7 @@ diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.c binutils-2.21.1/bfd/elfxx-riscv
 +
 +  if (stub->stub_section != htab->strampoline)
 +    {
-+      /* This is a simple LUI/ADIDU stub.  Zero out the beginning
++      /* This is a simple LUI/ADDI stub.  Zero out the beginning
 +       of the section and write the two instructions at the end.  */
 +      memset (loc, 0, offset);
 +      loc += offset;
@@ -12742,9 +12762,9 @@ diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.c binutils-2.21.1/bfd/elfxx-riscv
 +    {
 +      /* This is trampoline.  */
 +      loc += offset;
-+      bfd_put_32 (hti->output_bfd, RISCV_LTYPE (LUI, 19, RISCV_LUI_HIGH_PART(target)), loc);
-+      bfd_put_32 (hti->output_bfd, RISCV_ITYPE (ADDI, 19, 19, RISCV_CONST_LOW_PART(target)), loc + 4);
-+      bfd_put_32 (hti->output_bfd, RISCV_JTYPE (J, RISCV_JUMP_TARGET(target)), loc + 8);
++      bfd_put_32 (hti->output_bfd, RISCV_LTYPE (LUI, 18, RISCV_LUI_HIGH_PART(target)), loc);
++      bfd_put_32 (hti->output_bfd, RISCV_ITYPE (ADDI, 19, 18, RISCV_CONST_LOW_PART(target)), loc + 4);
++      bfd_put_32 (hti->output_bfd, RISCV_ITYPE (JALR_J, 0, 18, RISCV_CONST_LOW_PART(target)), loc + 8);
 +      bfd_put_32 (hti->output_bfd, 0, loc + 12);
 +    }
 +  return TRUE;
@@ -15184,8 +15204,8 @@ diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.c binutils-2.21.1/bfd/elfxx-riscv
 +      i_ehdrp->e_ident[EI_ABIVERSION] = 1;
 +    }
 +}
-diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.h binutils-2.21.1/bfd/elfxx-riscv.h
---- binutils-2.21.1-orig/bfd/elfxx-riscv.h     1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/elfxx-riscv.h binutils-2.21.1/bfd/elfxx-riscv.h
+--- ../binutils-2.21.1-orig/bfd/elfxx-riscv.h  1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/bfd/elfxx-riscv.h  2011-10-22 18:50:03.000000000 -0700
 @@ -0,0 +1,150 @@
 +/* RISC-V ELF specific backend routines.
@@ -15338,8 +15358,8 @@ diff -ruN binutils-2.21.1-orig/bfd/elfxx-riscv.h binutils-2.21.1/bfd/elfxx-riscv
 +#define elf_backend_eh_frame_address_size _bfd_riscv_elf_eh_frame_address_size
 +#define elf_backend_merge_symbol_attribute  _bfd_riscv_elf_merge_symbol_attribute
 +#define elf_backend_post_process_headers _bfd_riscv_post_process_headers
-diff -ruN binutils-2.21.1-orig/bfd/targets.c binutils-2.21.1/bfd/targets.c
---- binutils-2.21.1-orig/bfd/targets.c 2010-10-22 05:08:28.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/bfd/targets.c binutils-2.21.1/bfd/targets.c
+--- ../binutils-2.21.1-orig/bfd/targets.c      2010-10-22 05:08:28.000000000 -0700
 +++ binutils-2.21.1/bfd/targets.c      2011-10-22 18:46:17.000000000 -0700
 @@ -624,6 +624,7 @@
  extern const bfd_target bfd_elf32_littlearm_vxworks_vec;
@@ -15357,8 +15377,8 @@ diff -ruN binutils-2.21.1-orig/bfd/targets.c binutils-2.21.1/bfd/targets.c
  extern const bfd_target bfd_elf64_mmix_vec;
  extern const bfd_target bfd_elf64_powerpc_vec;
  extern const bfd_target bfd_elf64_powerpcle_vec;
-diff -ruN binutils-2.21.1-orig/binutils/readelf.c binutils-2.21.1/binutils/readelf.c
---- binutils-2.21.1-orig/binutils/readelf.c    2011-03-16 01:36:01.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/binutils/readelf.c binutils-2.21.1/binutils/readelf.c
+--- ../binutils-2.21.1-orig/binutils/readelf.c 2011-03-16 01:36:01.000000000 -0700
 +++ binutils-2.21.1/binutils/readelf.c 2011-10-22 18:46:17.000000000 -0700
 @@ -123,6 +123,7 @@
  #include "elf/mep.h"
@@ -15408,8 +15428,8 @@ diff -ruN binutils-2.21.1-orig/binutils/readelf.c binutils-2.21.1/binutils/reade
        case EM_SH:
          switch ((e_flags & EF_SH_MACH_MASK))
            {
-diff -ruN binutils-2.21.1-orig/config.sub binutils-2.21.1/config.sub
---- binutils-2.21.1-orig/config.sub    2010-06-01 10:53:40.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/config.sub binutils-2.21.1/config.sub
+--- ../binutils-2.21.1-orig/config.sub 2010-06-01 10:53:40.000000000 -0700
 +++ binutils-2.21.1/config.sub 2011-10-22 18:46:17.000000000 -0700
 @@ -323,6 +323,9 @@
        ms1)
@@ -15421,9 +15441,9 @@ diff -ruN binutils-2.21.1-orig/config.sub binutils-2.21.1/config.sub
  
        # We use `pc' rather than `unknown'
        # because (1) that's what they normally are, and
-diff -ruN binutils-2.21.1-orig/gas/config/tc-riscv.c binutils-2.21.1/gas/config/tc-riscv.c
---- binutils-2.21.1-orig/gas/config/tc-riscv.c 1969-12-31 16:00:00.000000000 -0800
-+++ binutils-2.21.1/gas/config/tc-riscv.c      2011-10-22 22:13:39.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/gas/config/tc-riscv.c binutils-2.21.1/gas/config/tc-riscv.c
+--- ../binutils-2.21.1-orig/gas/config/tc-riscv.c      1969-12-31 16:00:00.000000000 -0800
++++ binutils-2.21.1/gas/config/tc-riscv.c      2011-11-01 20:58:24.000000000 -0700
 @@ -0,0 +1,4942 @@
 +/* tc-mips.c -- assemble code for a MIPS chip.
 +   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -15524,15 +15544,6 @@ diff -ruN binutils-2.21.1-orig/gas/config/tc-riscv.c binutils-2.21.1/gas/config/
 +
 +extern int target_big_endian;
 +
-+/* The name of the readonly data section.  */
-+#define RDATA_SECTION_NAME (OUTPUT_FLAVOR == bfd_target_ecoff_flavour \
-+                          ? ".rdata" \
-+                          : OUTPUT_FLAVOR == bfd_target_coff_flavour \
-+                          ? ".rdata" \
-+                          : OUTPUT_FLAVOR == bfd_target_elf_flavour \
-+                          ? ".rodata" \
-+                          : (abort (), ""))
-+
 +/* Information about an instruction, including its format, operands
 +   and fixups.  */
 +struct mips_cl_insn
@@ -15769,9 +15780,17 @@ diff -ruN binutils-2.21.1-orig/gas/config/tc-riscv.c binutils-2.21.1/gas/config/
 +  EXTRACT_BITS ((INSN).insn_opcode, OP_MASK_##FIELD, OP_SH_##FIELD)
 +
 +/* Determine if an instruction matches an opcode. */
++#define OPCODE_MATCHES(OPCODE, OP) \
++  (((OPCODE) & MASK_##OP) == MATCH_##OP)
++
 +#define INSN_MATCHES(INSN, OP) \
 +  (((INSN).insn_opcode & MASK_##OP) == MATCH_##OP)
 +
++#define OPCODE_IS_STORE(OPCODE) \
++  (OPCODE_MATCHES(OPCODE, SD)  || OPCODE_MATCHES(OPCODE, SW) || \
++   OPCODE_MATCHES(OPCODE, SH)  || OPCODE_MATCHES(OPCODE, SB) || \
++   OPCODE_MATCHES(OPCODE, FSW) || OPCODE_MATCHES(OPCODE, FSD))
++
 +/* Prototypes for static functions.  */
 +
 +#define internalError()                                                       \
@@ -16948,17 +16967,15 @@ diff -ruN binutils-2.21.1-orig/gas/config/tc-riscv.c binutils-2.21.1/gas/config/
 +          case BFD_RELOC_UNUSED:
 +          case BFD_RELOC_LO16:
 +          case BFD_RELOC_MIPS_GOT_DISP:
-+            // handle stores specially (split immediate)
-+        if(INSN_MATCHES(*ip, SD)  || INSN_MATCHES(*ip, SW) ||
-+           INSN_MATCHES(*ip, SH)  || INSN_MATCHES(*ip, SB) ||
-+           INSN_MATCHES(*ip, FSW) || INSN_MATCHES(*ip, FSD))
-+            {
-+              int value = address_expr->X_add_number & (RISCV_IMM_REACH-1);
-+              value = ((value >> RISCV_IMMLO_BITS) << OP_SH_IMMHI) |
-+                      ((value & ((1<<RISCV_IMMLO_BITS)-1)) << OP_SH_IMMLO);
-+              ip->insn_opcode |= value;
-+            }
-+          else
++                /* Stores have a split immediate field. */
++            if (OPCODE_IS_STORE(ip->insn_opcode))
++              {
++                int value = address_expr->X_add_number & (RISCV_IMM_REACH-1);
++                value = ((value >> RISCV_IMMLO_BITS) << OP_SH_IMMHI) |
++                        ((value & ((1<<RISCV_IMMLO_BITS)-1)) << OP_SH_IMMLO);
++                ip->insn_opcode |= value;
++              }
++            else
 +              ip->insn_opcode |= (address_expr->X_add_number & (RISCV_IMM_REACH-1)) << OP_SH_IMMEDIATE;
 +            break;
 +
@@ -18732,20 +18749,24 @@ diff -ruN binutils-2.21.1-orig/gas/config/tc-riscv.c binutils-2.21.1/gas/config/
 +
 +    case BFD_RELOC_LO16:
 +    case BFD_RELOC_MIPS16_LO16:
-+      /* FIXME: Now that embedded-PIC is gone, some of this code/comment
-+       may be safe to remove, but if so it's not obvious.  */
-+      /* When handling an embedded PIC switch statement, we can wind
-+       up deleting a LO16 reloc.  See the 'o' case in mips_ip.  */
-+      if (fixP->fx_done)
++      if (!fixP->fx_done)
++      break;
++
++      if (*valP + RISCV_IMM_REACH/2 > RISCV_IMM_REACH-1)
++        as_bad_where (fixP->fx_file, fixP->fx_line,
++                    _("relocation overflow"));
++
++      if (OPCODE_IS_STORE(insn)) /* Stores have a split immediate field. */
 +      {
-+        if (*valP + RISCV_IMM_REACH/2 > RISCV_IMM_REACH-1)
-+          as_bad_where (fixP->fx_file, fixP->fx_line,
-+                        _("relocation overflow"));
-+        if (target_big_endian)
-+          buf += 2;
-+        insn |= (*valP & ((1<<RISCV_IMM_BITS)-1)) << OP_SH_IMMEDIATE;
-+        md_number_to_chars ((char *) buf, insn, 4);
++        valueT value = *valP & (RISCV_IMM_REACH-1);
++        value = ((value >> RISCV_IMMLO_BITS) << OP_SH_IMMHI) |
++                ((value & ((1<<RISCV_IMMLO_BITS)-1)) << OP_SH_IMMLO);
++        insn |= value;
 +      }
++      else
++      insn |= (*valP & ((1<<RISCV_IMM_BITS)-1)) << OP_SH_IMMEDIATE;
++
++      md_number_to_chars ((char *) buf, insn, 4);
 +      break;
 +
 +    case BFD_RELOC_MIPS_JMP:
@@ -18943,8 +18964,7 @@ diff -ruN binutils-2.21.1-orig/gas/config/tc-riscv.c binutils-2.21.1/gas/config/
 +      break;
 +
 +    case 'r':
-+      seg = subseg_new (RDATA_SECTION_NAME,
-+                      (subsegT) get_absolute_expression ());
++      seg = subseg_new (".rodata", (subsegT) get_absolute_expression ());
 +      if (IS_ELF)
 +      {
 +        bfd_set_section_flags (stdoutput, seg, (SEC_ALLOC | SEC_LOAD
@@ -20367,8 +20387,8 @@ diff -ruN binutils-2.21.1-orig/gas/config/tc-riscv.c binutils-2.21.1/gas/config/
 +
 +  return regnum;
 +}
-diff -ruN binutils-2.21.1-orig/gas/config/tc-riscv.h binutils-2.21.1/gas/config/tc-riscv.h
---- binutils-2.21.1-orig/gas/config/tc-riscv.h 1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/gas/config/tc-riscv.h binutils-2.21.1/gas/config/tc-riscv.h
+--- ../binutils-2.21.1-orig/gas/config/tc-riscv.h      1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/gas/config/tc-riscv.h      2011-10-22 18:50:03.000000000 -0700
 @@ -0,0 +1,162 @@
 +/* tc-mips.h -- header file for tc-mips.c.
@@ -20533,8 +20553,8 @@ diff -ruN binutils-2.21.1-orig/gas/config/tc-riscv.h binutils-2.21.1/gas/config/
 +#define DWARF2_CIE_DATA_ALIGNMENT (-4)
 +
 +#endif /* TC_RISCV */
-diff -ruN binutils-2.21.1-orig/gas/configure.tgt binutils-2.21.1/gas/configure.tgt
---- binutils-2.21.1-orig/gas/configure.tgt     2011-04-01 05:02:42.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/gas/configure.tgt binutils-2.21.1/gas/configure.tgt
+--- ../binutils-2.21.1-orig/gas/configure.tgt  2011-04-01 05:02:42.000000000 -0700
 +++ binutils-2.21.1/gas/configure.tgt  2011-10-22 18:46:17.000000000 -0700
 @@ -63,6 +63,7 @@
    pj*)                        cpu_type=pj endian=big ;;
@@ -20553,8 +20573,8 @@ diff -ruN binutils-2.21.1-orig/gas/configure.tgt binutils-2.21.1/gas/configure.t
    s390-*-linux-*)                     fmt=elf em=linux ;;
    s390-*-tpf*)                                fmt=elf ;;
  
-diff -ruN binutils-2.21.1-orig/gas/Makefile.am binutils-2.21.1/gas/Makefile.am
---- binutils-2.21.1-orig/gas/Makefile.am       2010-07-04 07:35:53.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/gas/Makefile.am binutils-2.21.1/gas/Makefile.am
+--- ../binutils-2.21.1-orig/gas/Makefile.am    2010-07-04 07:35:53.000000000 -0700
 +++ binutils-2.21.1/gas/Makefile.am    2011-10-22 18:46:17.000000000 -0700
 @@ -150,6 +150,7 @@
        config/tc-pdp11.c \
@@ -20572,8 +20592,8 @@ diff -ruN binutils-2.21.1-orig/gas/Makefile.am binutils-2.21.1/gas/Makefile.am
        config/tc-rx.h \
        config/tc-s390.h \
        config/tc-score.h \
-diff -ruN binutils-2.21.1-orig/gas/Makefile.in binutils-2.21.1/gas/Makefile.in
---- binutils-2.21.1-orig/gas/Makefile.in       2010-11-05 03:33:35.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/gas/Makefile.in binutils-2.21.1/gas/Makefile.in
+--- ../binutils-2.21.1-orig/gas/Makefile.in    2010-11-05 03:33:35.000000000 -0700
 +++ binutils-2.21.1/gas/Makefile.in    2011-10-22 18:46:17.000000000 -0700
 @@ -417,6 +417,7 @@
        config/tc-pdp11.c \
@@ -20620,8 +20640,8 @@ diff -ruN binutils-2.21.1-orig/gas/Makefile.in binutils-2.21.1/gas/Makefile.in
  tc-rx.o: config/tc-rx.c
  @am__fastdepCC_TRUE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-rx.o -MD -MP -MF $(DEPDIR)/tc-rx.Tpo -c -o tc-rx.o `test -f 'config/tc-rx.c' || echo '$(srcdir)/'`config/tc-rx.c
  @am__fastdepCC_TRUE@  $(am__mv) $(DEPDIR)/tc-rx.Tpo $(DEPDIR)/tc-rx.Po
-diff -ruN binutils-2.21.1-orig/include/dis-asm.h binutils-2.21.1/include/dis-asm.h
---- binutils-2.21.1-orig/include/dis-asm.h     2010-06-28 21:17:27.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/include/dis-asm.h binutils-2.21.1/include/dis-asm.h
+--- ../binutils-2.21.1-orig/include/dis-asm.h  2010-06-28 21:17:27.000000000 -0700
 +++ binutils-2.21.1/include/dis-asm.h  2011-10-22 18:46:17.000000000 -0700
 @@ -227,6 +227,7 @@
  extern int print_insn_big_mips                (bfd_vma, disassemble_info *);
@@ -20639,8 +20659,8 @@ diff -ruN binutils-2.21.1-orig/include/dis-asm.h binutils-2.21.1/include/dis-asm
  extern int print_insn_little_score      (bfd_vma, disassemble_info *); 
  extern int print_insn_lm32            (bfd_vma, disassemble_info *);
  extern int print_insn_m32c            (bfd_vma, disassemble_info *);
-diff -ruN binutils-2.21.1-orig/include/elf/common.h binutils-2.21.1/include/elf/common.h
---- binutils-2.21.1-orig/include/elf/common.h  2010-05-17 20:31:06.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/include/elf/common.h binutils-2.21.1/include/elf/common.h
+--- ../binutils-2.21.1-orig/include/elf/common.h       2010-05-17 20:31:06.000000000 -0700
 +++ binutils-2.21.1/include/elf/common.h       2011-10-22 18:46:17.000000000 -0700
 @@ -295,6 +295,7 @@
  #define EM_TILEPRO    188     /* Tilera TILEPro multicore architecture family */
@@ -20650,8 +20670,8 @@ diff -ruN binutils-2.21.1-orig/include/elf/common.h binutils-2.21.1/include/elf/
  
  /* If it is necessary to assign new unofficial EM_* values, please pick large
     random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
-diff -ruN binutils-2.21.1-orig/include/elf/riscv.h binutils-2.21.1/include/elf/riscv.h
---- binutils-2.21.1-orig/include/elf/riscv.h   1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/include/elf/riscv.h binutils-2.21.1/include/elf/riscv.h
+--- ../binutils-2.21.1-orig/include/elf/riscv.h        1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/include/elf/riscv.h        2011-10-22 18:50:03.000000000 -0700
 @@ -0,0 +1,485 @@
 +/* RISC-V ELF support for BFD.
@@ -21139,8 +21159,8 @@ diff -ruN binutils-2.21.1-orig/include/elf/riscv.h binutils-2.21.1/include/elf/r
 +  (bfd *, const Elf64_Internal_RegInfo *, Elf64_External_RegInfo *);
 +
 +#endif /* _ELF_RISCV_H */
-diff -ruN binutils-2.21.1-orig/include/opcode/riscv.h binutils-2.21.1/include/opcode/riscv.h
---- binutils-2.21.1-orig/include/opcode/riscv.h        1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/include/opcode/riscv.h binutils-2.21.1/include/opcode/riscv.h
+--- ../binutils-2.21.1-orig/include/opcode/riscv.h     1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/include/opcode/riscv.h     2011-10-22 19:17:57.000000000 -0700
 @@ -0,0 +1,253 @@
 +/* riscv.h.  RISC-V opcode list for GDB, the GNU debugger.
@@ -21396,8 +21416,8 @@ diff -ruN binutils-2.21.1-orig/include/opcode/riscv.h binutils-2.21.1/include/op
 +#define NUMOPCODES bfd_riscv_num_opcodes
 +
 +#endif /* _MIPS_H_ */
-diff -ruN binutils-2.21.1-orig/include/opcode/riscv-opc.h binutils-2.21.1/include/opcode/riscv-opc.h
---- binutils-2.21.1-orig/include/opcode/riscv-opc.h    1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/include/opcode/riscv-opc.h binutils-2.21.1/include/opcode/riscv-opc.h
+--- ../binutils-2.21.1-orig/include/opcode/riscv-opc.h 1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/include/opcode/riscv-opc.h 2011-10-22 18:50:03.000000000 -0700
 @@ -0,0 +1,545 @@
 +/* Automatically generated by parse-opcodes */
@@ -21945,8 +21965,8 @@ diff -ruN binutils-2.21.1-orig/include/opcode/riscv-opc.h binutils-2.21.1/includ
 +#define  MASK_VFSSEGD 0x1ffff
 +#define MATCH_SD 0x1a3
 +#define  MASK_SD 0x3ff
-diff -ruN binutils-2.21.1-orig/ld/configure.tgt binutils-2.21.1/ld/configure.tgt
---- binutils-2.21.1-orig/ld/configure.tgt      2011-04-01 05:03:54.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/ld/configure.tgt binutils-2.21.1/ld/configure.tgt
+--- ../binutils-2.21.1-orig/ld/configure.tgt   2011-04-01 05:03:54.000000000 -0700
 +++ binutils-2.21.1/ld/configure.tgt   2011-10-22 18:46:17.000000000 -0700
 @@ -504,6 +504,9 @@
  powerpc-*-beos*)      targ_emul=aixppc ;;
@@ -21958,10 +21978,9 @@ diff -ruN binutils-2.21.1-orig/ld/configure.tgt binutils-2.21.1/ld/configure.tgt
  rs6000-*-aix[5-9]*)   targ_emul=aix5rs6 ;;
  rs6000-*-aix*)                targ_emul=aixrs6
                        ;;
-Binary files binutils-2.21.1-orig/ld/.configure.tgt.swp and binutils-2.21.1/ld/.configure.tgt.swp differ
-diff -ruN binutils-2.21.1-orig/ld/emulparams/elf32lriscv-defs.sh binutils-2.21.1/ld/emulparams/elf32lriscv-defs.sh
---- binutils-2.21.1-orig/ld/emulparams/elf32lriscv-defs.sh     1969-12-31 16:00:00.000000000 -0800
-+++ binutils-2.21.1/ld/emulparams/elf32lriscv-defs.sh  2011-10-22 18:50:03.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/ld/emulparams/elf32lriscv-defs.sh binutils-2.21.1/ld/emulparams/elf32lriscv-defs.sh
+--- ../binutils-2.21.1-orig/ld/emulparams/elf32lriscv-defs.sh  1969-12-31 16:00:00.000000000 -0800
++++ binutils-2.21.1/ld/emulparams/elf32lriscv-defs.sh  2011-11-03 04:00:16.000000000 -0700
 @@ -0,0 +1,93 @@
 +# This is an ELF platform.
 +SCRIPT_NAME=elf
@@ -21997,7 +22016,7 @@ diff -ruN binutils-2.21.1-orig/ld/emulparams/elf32lriscv-defs.sh binutils-2.21.1
 +
 +TEXT_START_ADDR=0x10000000
 +MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
-+ENTRY=__start
++ENTRY=_start
 +
 +# Unlike most targets, the MIPS backend puts all dynamic relocations
 +# in a single dynobj section, which it also calls ".rel.dyn".  It does
@@ -22056,8 +22075,8 @@ diff -ruN binutils-2.21.1-orig/ld/emulparams/elf32lriscv-defs.sh binutils-2.21.1
 +OTHER_SECTIONS="/DISCARD/ : { *(.MIPS.content*) *(.MIPS.events*) }"
 +
 +TEXT_DYNAMIC=
-diff -ruN binutils-2.21.1-orig/ld/emulparams/elf32lriscv.sh binutils-2.21.1/ld/emulparams/elf32lriscv.sh
---- binutils-2.21.1-orig/ld/emulparams/elf32lriscv.sh  1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/ld/emulparams/elf32lriscv.sh binutils-2.21.1/ld/emulparams/elf32lriscv.sh
+--- ../binutils-2.21.1-orig/ld/emulparams/elf32lriscv.sh       1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/ld/emulparams/elf32lriscv.sh       2011-10-22 18:50:03.000000000 -0700
 @@ -0,0 +1,15 @@
 +# If you change this file, please also look at files which source this one:
@@ -22075,15 +22094,15 @@ diff -ruN binutils-2.21.1-orig/ld/emulparams/elf32lriscv.sh binutils-2.21.1/ld/e
 +  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
 +  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
 +'
-diff -ruN binutils-2.21.1-orig/ld/emulparams/elf64lriscv-defs.sh binutils-2.21.1/ld/emulparams/elf64lriscv-defs.sh
---- binutils-2.21.1-orig/ld/emulparams/elf64lriscv-defs.sh     1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/ld/emulparams/elf64lriscv-defs.sh binutils-2.21.1/ld/emulparams/elf64lriscv-defs.sh
+--- ../binutils-2.21.1-orig/ld/emulparams/elf64lriscv-defs.sh  1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/ld/emulparams/elf64lriscv-defs.sh  2011-10-22 18:50:03.000000000 -0700
 @@ -0,0 +1,3 @@
 +. ${srcdir}/emulparams/elf32lriscv-defs.sh
 +COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
 +INITIAL_READONLY_SECTIONS=".MIPS.options : { *(.MIPS.options) }"
-diff -ruN binutils-2.21.1-orig/ld/emulparams/elf64lriscv.sh binutils-2.21.1/ld/emulparams/elf64lriscv.sh
---- binutils-2.21.1-orig/ld/emulparams/elf64lriscv.sh  1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/ld/emulparams/elf64lriscv.sh binutils-2.21.1/ld/emulparams/elf64lriscv.sh
+--- ../binutils-2.21.1-orig/ld/emulparams/elf64lriscv.sh       1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/ld/emulparams/elf64lriscv.sh       2011-10-22 18:50:03.000000000 -0700
 @@ -0,0 +1,13 @@
 +# If you change this file, please also look at files which source this one:
@@ -22099,8 +22118,8 @@ diff -ruN binutils-2.21.1-orig/ld/emulparams/elf64lriscv.sh binutils-2.21.1/ld/e
 +  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
 +  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
 +'
-diff -ruN binutils-2.21.1-orig/ld/emultempl/riscvelf.em binutils-2.21.1/ld/emultempl/riscvelf.em
---- binutils-2.21.1-orig/ld/emultempl/riscvelf.em      1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/ld/emultempl/riscvelf.em binutils-2.21.1/ld/emultempl/riscvelf.em
+--- ../binutils-2.21.1-orig/ld/emultempl/riscvelf.em   1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/ld/emultempl/riscvelf.em   2011-10-24 17:20:34.000000000 -0700
 @@ -0,0 +1,241 @@
 +# This shell script emits a C file. -*- C -*-
@@ -22344,8 +22363,8 @@ diff -ruN binutils-2.21.1-orig/ld/emultempl/riscvelf.em binutils-2.21.1/ld/emult
 +LDEMUL_AFTER_PARSE=riscv_after_parse
 +LDEMUL_BEFORE_ALLOCATION=riscv_before_allocation
 +LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=riscv_create_output_section_statements
-diff -ruN binutils-2.21.1-orig/ld/Makefile.am binutils-2.21.1/ld/Makefile.am
---- binutils-2.21.1-orig/ld/Makefile.am        2011-03-16 01:37:30.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/ld/Makefile.am binutils-2.21.1/ld/Makefile.am
+--- ../binutils-2.21.1-orig/ld/Makefile.am     2011-03-16 01:37:30.000000000 -0700
 +++ binutils-2.21.1/ld/Makefile.am     2011-10-22 18:46:17.000000000 -0700
 @@ -211,6 +211,7 @@
        eelf32lppc.c \
@@ -22386,8 +22405,8 @@ diff -ruN binutils-2.21.1-orig/ld/Makefile.am binutils-2.21.1/ld/Makefile.am
  eelf64ltsmip.c: $(srcdir)/emulparams/elf64ltsmip.sh \
    $(srcdir)/emulparams/elf64btsmip.sh $(srcdir)/emulparams/elf64bmip-defs.sh \
    $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \
-diff -ruN binutils-2.21.1-orig/ld/Makefile.in binutils-2.21.1/ld/Makefile.in
---- binutils-2.21.1-orig/ld/Makefile.in        2011-03-16 01:37:30.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/ld/Makefile.in binutils-2.21.1/ld/Makefile.in
+--- ../binutils-2.21.1-orig/ld/Makefile.in     2011-03-16 01:37:30.000000000 -0700
 +++ binutils-2.21.1/ld/Makefile.in     2011-10-22 18:46:17.000000000 -0700
 @@ -516,6 +516,7 @@
        eelf32lppc.c \
@@ -22444,8 +22463,8 @@ diff -ruN binutils-2.21.1-orig/ld/Makefile.in binutils-2.21.1/ld/Makefile.in
  eelf64ltsmip.c: $(srcdir)/emulparams/elf64ltsmip.sh \
    $(srcdir)/emulparams/elf64btsmip.sh $(srcdir)/emulparams/elf64bmip-defs.sh \
    $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \
-diff -ruN binutils-2.21.1-orig/opcodes/configure binutils-2.21.1/opcodes/configure
---- binutils-2.21.1-orig/opcodes/configure     2010-11-05 03:32:32.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/opcodes/configure binutils-2.21.1/opcodes/configure
+--- ../binutils-2.21.1-orig/opcodes/configure  2010-11-05 03:32:32.000000000 -0700
 +++ binutils-2.21.1/opcodes/configure  2011-10-22 18:48:48.000000000 -0700
 @@ -12462,6 +12462,7 @@
        bfd_powerpc_arch)       ta="$ta ppc-dis.lo ppc-opc.lo" ;;
@@ -22455,8 +22474,8 @@ diff -ruN binutils-2.21.1-orig/opcodes/configure binutils-2.21.1/opcodes/configu
        bfd_romp_arch)          ;;
        bfd_rs6000_arch)        ta="$ta ppc-dis.lo ppc-opc.lo" ;;
        bfd_rx_arch)            ta="$ta rx-dis.lo rx-decode.lo";;
-diff -ruN binutils-2.21.1-orig/opcodes/configure.in binutils-2.21.1/opcodes/configure.in
---- binutils-2.21.1-orig/opcodes/configure.in  2010-06-28 21:17:33.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/opcodes/configure.in binutils-2.21.1/opcodes/configure.in
+--- ../binutils-2.21.1-orig/opcodes/configure.in       2010-06-28 21:17:33.000000000 -0700
 +++ binutils-2.21.1/opcodes/configure.in       2011-10-22 18:46:17.000000000 -0700
 @@ -268,6 +268,7 @@
        bfd_powerpc_arch)       ta="$ta ppc-dis.lo ppc-opc.lo" ;;
@@ -22466,8 +22485,8 @@ diff -ruN binutils-2.21.1-orig/opcodes/configure.in binutils-2.21.1/opcodes/conf
        bfd_romp_arch)          ;;
        bfd_rs6000_arch)        ta="$ta ppc-dis.lo ppc-opc.lo" ;;
        bfd_rx_arch)            ta="$ta rx-dis.lo rx-decode.lo";;
-diff -ruN binutils-2.21.1-orig/opcodes/disassemble.c binutils-2.21.1/opcodes/disassemble.c
---- binutils-2.21.1-orig/opcodes/disassemble.c 2010-08-05 20:59:49.000000000 -0700
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/opcodes/disassemble.c binutils-2.21.1/opcodes/disassemble.c
+--- ../binutils-2.21.1-orig/opcodes/disassemble.c      2010-08-05 20:59:49.000000000 -0700
 +++ binutils-2.21.1/opcodes/disassemble.c      2011-10-22 18:46:17.000000000 -0700
 @@ -338,6 +338,14 @@
        disassemble = print_insn_little_powerpc;
@@ -22484,8 +22503,8 @@ diff -ruN binutils-2.21.1-orig/opcodes/disassemble.c binutils-2.21.1/opcodes/dis
  #ifdef ARCH_rs6000
      case bfd_arch_rs6000:
        if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
-diff -ruN binutils-2.21.1-orig/opcodes/riscv-dis.c binutils-2.21.1/opcodes/riscv-dis.c
---- binutils-2.21.1-orig/opcodes/riscv-dis.c   1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/opcodes/riscv-dis.c binutils-2.21.1/opcodes/riscv-dis.c
+--- ../binutils-2.21.1-orig/opcodes/riscv-dis.c        1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/opcodes/riscv-dis.c        2011-10-22 19:19:34.000000000 -0700
 @@ -0,0 +1,905 @@
 +/* vim: set ts=8: */
@@ -23393,8 +23412,8 @@ diff -ruN binutils-2.21.1-orig/opcodes/riscv-dis.c binutils-2.21.1/opcodes/riscv
 +
 +  fprintf (stream, _("\n"));
 +}
-diff -ruN binutils-2.21.1-orig/opcodes/riscv-opc.c binutils-2.21.1/opcodes/riscv-opc.c
---- binutils-2.21.1-orig/opcodes/riscv-opc.c   1969-12-31 16:00:00.000000000 -0800
+diff -x autom4te.cache -ruN ../binutils-2.21.1-orig/opcodes/riscv-opc.c binutils-2.21.1/opcodes/riscv-opc.c
+--- ../binutils-2.21.1-orig/opcodes/riscv-opc.c        1969-12-31 16:00:00.000000000 -0800
 +++ binutils-2.21.1/opcodes/riscv-opc.c        2011-10-22 19:14:45.000000000 -0700
 @@ -0,0 +1,449 @@
 +/* mips-opc.c -- MIPS opcode list.