This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Add support for 64-bit MIPS GNU/Linux targets


On Dec 24,  2:40pm, Daniel Jacobowitz wrote:
[...]
> > I found it necessary to change the osabi registration (in mips-linux-tdep.c)
> > from:
> > 
> >   gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_LINUX,
> >                           mips_linux_init_abi);
> > 
> > to:
> > 
> >   for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0);
> >        arch_info != NULL;
> >        arch_info = arch_info->next)
> >     {
> >       gdbarch_register_osabi (bfd_arch_mips, arch_info->mach, GDB_OSABI_LINUX,
> >                               mips_linux_init_abi);
> >     }
> > 
> > I'm not entirely happy with this change, but I see no way around it
> > due to the recent changes to osabi.c.  (I'm open to suggestions for
> > better ways to do it...)
> 
> OK, that's a problem.  In fact it's disgusting...  A mach value of 0 is
> always supposed to mean "default", if I remember my BFD correctly.  Has
> the change to pass a machine of 0 broken osabi support for anything
> that sets a machine?  It looks that way.

I wonder if Mark made a mistake in his recent change to gdbarch_init_osabi(),
specifically in the following code:

  for (handler = gdb_osabi_handler_list; handler != NULL;
       handler = handler->next)
    {
      if (handler->osabi != osabi)
	continue;

      /* Check whether the machine type and architecture of the
         handler are compatible with the desired machine type and
         architecture.

	 NOTE: kettenis/20021027: There may be more than one machine
	 type that is compatible with the desired machine type.  Right
	 now we simply return the first match, which is fine for now.
	 However, we might want to do something smarter in the future.  */
      compatible = arch_info->compatible (arch_info, handler->arch_info);
      if (compatible == handler->arch_info)
	{
	  (*handler->init_osabi) (info, gdbarch);
	  return;
	}
    }

For MIPS, the compatible() function is defined as follows:

static const bfd_arch_info_type *
mips_compatible (a, b)
     const bfd_arch_info_type *a;
     const bfd_arch_info_type *b;
{
  if (a->arch != b->arch)
    return NULL;

  /* Machine compatibility is checked in
     _bfd_mips_elf_merge_private_bfd_data.  */

  return a;
}

So... the first argument is returned when the ``arch'' fields are the
same, and NULL otherwise.  Thus, for MIPS, the following bit of
code:

      compatible = arch_info->compatible (arch_info, handler->arch_info);
      if (compatible == handler->arch_info)
        ...

means the same as:

      if (arch_info == handler->arch_info)
        ...

which seems overly restrictive and not at all in the spirit of the
comment preceding that bit of code.

Kevin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]