static const char *
get_arch_name (const char *name)
{
  NXArchInfo * a_info;
  const NXArchInfo * all_info;
  cpu_type_t cputype;
  struct arch_config_guess_map *map;
  const char *aname;

  if (name) {
    /* Find config name based on arch name.  */
    aname = NULL;
    map = arch_config_map;
    while (map->arch_name) {
      if (!strcmp (map->arch_name, name))
	return name;
      else map++;
    }
    a_info = (NXArchInfo *) NXGetArchInfoFromName (name);
    /* radr://7148788  emit diagnostic for ARM architectures not explicitly
     * handled by the driver. */
    if (a_info && a_info->cputype == CPU_TYPE_ARM)
      a_info = NULL;
  } else {
    a_info = (NXArchInfo *) NXGetLocalArchInfo();
    if (a_info) {
      if (dash_m32_seen) {
        /* If -m32 is seen then do not change cpu type.  */
      } else if (dash_m64_seen) {
        /* If -m64 is seen then enable CPU_ARCH_ABI64.  */
	a_info->cputype |= CPU_ARCH_ABI64;
      } else if (sizeof (long) == 8)
	/* On x86, by default (name is NULL here) enable 64 bit code.  */
	a_info->cputype |= CPU_ARCH_ABI64;
    }
  }

  if (!a_info)
    fatal ("Invalid arch name : %s", name);

  all_info = NXGetAllArchInfos();

  if (!all_info)
    fatal ("Unable to get architecture information");

  /* Find first arch. that matches cputype.  */
  cputype = a_info->cputype;

  while (all_info->name)
    {
      if (all_info->cputype == cputype)
	break;
      else
	all_info++;
    }

  return all_info->name;
}
Exemple #2
0
static const char *
get_arch_name (const char *name)
{
  const NXArchInfo * a_info;
  const NXArchInfo * all_info;
  cpu_type_t cputype;
  struct arch_config_guess_map *map;
  const char *aname;

  if (name)
    {
      /* Find config name based on arch name.  */
      aname = NULL;
      map = arch_config_map;
      while (map->arch_name)
	{
	  if (!strcmp (map->arch_name, name))
	    return name;
	  else map++;
	}
      a_info = NXGetArchInfoFromName (name);
    }
  else
    a_info = NXGetLocalArchInfo ();

  if (!a_info)
    fatal ("Invalid arch name : %s", name);

  all_info = NXGetAllArchInfos();

  if (!all_info)
    fatal ("Unable to get architecture information");

  /* Find first arch. that matches cputype.  */
  cputype = a_info->cputype;

  while (all_info->name)
    {
      if (all_info->cputype == cputype)
	break;
      else
	all_info++;
    }

  return all_info->name;
}