]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: mips: fix segfault with invalid default cpu strings
authorMike Frysinger <vapier@gentoo.org>
Tue, 22 May 2012 01:55:16 +0000 (01:55 +0000)
committerMike Frysinger <vapier@gentoo.org>
Tue, 22 May 2012 01:55:16 +0000 (01:55 +0000)
If you configure gas for a mips32el-* target, the default cpu calculation
gets mangled, and we end up passing and invalid value as the default cpu.

If you try executing gas after that, it segfaults.  This is because it
assumes that the default cpu value is always valid.
$ ./gas/as-new
Assembler messages:
Error: Bad value (2) for default CPU
Segmentation fault (core dumped)

I'm not debating that the target tuple is valid, just that gas shouldn't
crash.  So add a friendly assert to avoid that.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
gas/ChangeLog
gas/config/tc-mips.c

index 116ba375fb77a51078d91233c5f2e742c7b918f6..caef2baa553aba3449cd43843a3a34ee205eb7b0 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-21  Mike Frysinger  <vapier@gentoo.org>
+
+       * config/tc-mips.c (mips_after_parse_args): Assert that arch_info
+       is non-NULL.
+
 2012-05-19  Alan Modra  <amodra@gmail.com>
 
        * config/obj-elf.c (obj_elf_section): Cater for TC_KEEP_OPERAND_SPACES
index d6b8ecb49032d592a9fb0080131efec6b4dd838c..4760c05d4b72e19d1e8fee3b7c507c6bf1857d0d 100644 (file)
@@ -15005,7 +15005,10 @@ mips_after_parse_args (void)
     }
 
   if (arch_info == 0)
-    arch_info = mips_parse_cpu ("default CPU", MIPS_CPU_STRING_DEFAULT);
+    {
+      arch_info = mips_parse_cpu ("default CPU", MIPS_CPU_STRING_DEFAULT);
+      gas_assert (arch_info);
+    }
 
   if (ABI_NEEDS_64BIT_REGS (mips_abi) && !ISA_HAS_64BIT_REGS (arch_info->isa))
     as_bad (_("-march=%s is not compatible with the selected ABI"),