/* The argument of the -mabi= flag. */
 static char* mips_abi_string = 0;
 
+/* Wether we should mark the file EABI64 or EABI32. */
+static int mips_eabi64 = 0;
+
 /* Whether the 4650 instructions (mad/madu) are permitted.  */
 static int mips_4650 = -1;
 
       else if (mips_cpu == 4000
                || mips_cpu == 4100
               /* start-sanitize-vr4xxx */
+               || mips_cpu == 4111
                || mips_cpu == 4121
               /* end-sanitize-vr4xxx */
                || mips_cpu == 4400
     mips_4010 = (mips_cpu == 4010);
 
   if (mips_4100 < 0)
-    mips_4100 = (mips_cpu == 4100);
+    mips_4100 = (mips_cpu == 4100
+                /* start-sanitize-vr4xxx */
+                || mips_cpu == 4111
+                /* end-sanitize-vr4xxx */
+                );
 
   /* start-sanitize-vr4xxx */
   if (mips_4121 < 0)
   if (mips_opts.isa < 2 && mips_trap)
     as_bad (_("trap exception not supported at ISA 1"));
 
+  /* Set the EABI kind based on the ISA before the user gets
+     to change the ISA with directives.  This isn't really
+     the best, but then neither is basing the abi on the isa. */     
+  if (mips_opts.isa > 2 && strcmp (mips_abi_string,"eabi"))
+    mips_eabi64 = 1;
+
   if (mips_cpu != 0 && mips_cpu != -1)
     {
       ok = bfd_set_arch_mach (stdoutput, bfd_arch_mips, mips_cpu);
                     mips_cpu = 4100;
                /* start-sanitize-vr4xxx */
                else if (strcmp (p, "4111") == 0)
-                    mips_cpu = 4100;
+                    mips_cpu = 4111;
                else if (strcmp (p, "4121") == 0)
                     mips_cpu = 4121;
                /* end-sanitize-vr4xxx */
 -no-m4100              do not permit VR4100 instructions\n"));
   /* start-sanitize-vr4xxx */
   fprintf(stream, _("\
+-mcpu=vr4111           generate code for vr4111\n"));
+  fprintf(stream, _("\
 -mcpu=vr4121           generate code for vr4121\n\
 -m4121                  permit VR4121 instructions\n\
 -no-m4121              do not permit VR4121 instructions\n"));
     elf_elfheader (stdoutput)->e_flags |= E_MIPS_ABI_O64;
   else if (strcmp (mips_abi_string,"eabi") == 0)
     {
-      if (mips_opts.isa > 2)
-       elf_elfheader (stdoutput)->e_flags |= E_MIPS_ABI_EABI32;
-      else
+      if (mips_eabi64)
        elf_elfheader (stdoutput)->e_flags |= E_MIPS_ABI_EABI64;
+      else
+       elf_elfheader (stdoutput)->e_flags |= E_MIPS_ABI_EABI32;
     }
 }