[nios2] fix _initialize_nios2_linux_tdep for BFD mach changes

Message ID 5594919A.6090701@codesourcery.com
State New, archived
Headers

Commit Message

Sandra Loosemore July 2, 2015, 1:19 a.m. UTC
  As a consequence of this patch

https://sourceware.org/ml/binutils/2015-07/msg00015.html

which introduced new BFD mach identifiers for Nios II R1 and R2 
processor variants, BFD now identifies Nios II R1 objects as 
bfd_mach_nios2r1 instead of bfd_mach_nios2.  This breaks
the call to gdbarch_register_osabi, such that GDB fails to recognize R1 
nios2-linux-gnu executables.  Note that this is *not* due to any 
incompatible change in R1 ELF objects, just in BFD's internal 
representation of the mach values.

I stole this fix verbatim from the MIPS back end so I consider it 
borderline obvious.  I don't like to leave GDB in a broken state so I 
propose to commit this in a few days unless I hear objections meanwhile.

The patches to add GDB support for Nios II R2 objects will be coming 
along later; this patch just un-breaks the existing support for R1.

-Sandra
  

Patch

diff --git a/gdb/nios2-linux-tdep.c b/gdb/nios2-linux-tdep.c
index 0a837b0..68c949a 100644
--- a/gdb/nios2-linux-tdep.c
+++ b/gdb/nios2-linux-tdep.c
@@ -223,8 +223,14 @@  extern initialize_file_ftype _initialize_nios2_linux_tdep;
 void
 _initialize_nios2_linux_tdep (void)
 {
-  gdbarch_register_osabi (bfd_arch_nios2, 0, GDB_OSABI_LINUX,
-                          nios2_linux_init_abi);
+
+  const struct bfd_arch_info *arch_info;
+
+  for (arch_info = bfd_lookup_arch (bfd_arch_nios2, 0);
+       arch_info != NULL;
+       arch_info = arch_info->next)
+    gdbarch_register_osabi (bfd_arch_nios2, arch_info->mach,
+			    GDB_OSABI_LINUX, nios2_linux_init_abi);
 
   initialize_tdesc_nios2_linux ();
 }