⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ieee.c

📁 基于4个mips核的noc设计
💻 C
📖 第 1 页 / 共 5 页
字号:
  while (loop)    {      switch (this_byte (&(ieee->h)))	{	case ieee_variable_P_enum:	  /* P variable, current program counter for section n */	  {	    int section_n;	    next_byte (&(ieee->h));	    *pcrel = true;	    section_n = must_parse_int (&(ieee->h));	    PUSH (NOSYMBOL, bfd_abs_section_ptr, 0);	    break;	  }	case ieee_variable_L_enum:	  /* L variable  address of section N */	  next_byte (&(ieee->h));	  PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);	  break;	case ieee_variable_R_enum:	  /* R variable, logical address of section module */	  /* FIXME, this should be different to L */	  next_byte (&(ieee->h));	  PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);	  break;	case ieee_variable_S_enum:	  /* S variable, size in MAUS of section module */	  next_byte (&(ieee->h));	  PUSH (NOSYMBOL,		0,		ieee->section_table[must_parse_int (&(ieee->h))]->_raw_size);	  break;	case ieee_variable_I_enum:	  /* Push the address of variable n */	  {	    ieee_symbol_index_type sy;	    next_byte (&(ieee->h));	    sy.index = (int) must_parse_int (&(ieee->h));	    sy.letter = 'I';	    PUSH (sy, bfd_abs_section_ptr, 0);	  }	  break;	case ieee_variable_X_enum:	  /* Push the address of external variable n */	  {	    ieee_symbol_index_type sy;	    next_byte (&(ieee->h));	    sy.index = (int) (must_parse_int (&(ieee->h)));	    sy.letter = 'X';	    PUSH (sy, bfd_und_section_ptr, 0);	  }	  break;	case ieee_function_minus_enum:	  {	    bfd_vma value1, value2;	    asection *section1, *section_dummy;	    ieee_symbol_index_type sy;	    next_byte (&(ieee->h));	    POP (sy, section1, value1);	    POP (sy, section_dummy, value2);	    PUSH (sy, section1 ? section1 : section_dummy, value2 - value1);	  }	  break;	case ieee_function_plus_enum:	  {	    bfd_vma value1, value2;	    asection *section1;	    asection *section2;	    ieee_symbol_index_type sy1;	    ieee_symbol_index_type sy2;	    next_byte (&(ieee->h));	    POP (sy1, section1, value1);	    POP (sy2, section2, value2);	    PUSH (sy1.letter ? sy1 : sy2,		  bfd_is_abs_section (section1) ? section2 : section1,		  value1 + value2);	  }	  break;	default:	  {	    bfd_vma va;	    BFD_ASSERT (this_byte (&(ieee->h)) < (int) ieee_variable_A_enum		    || this_byte (&(ieee->h)) > (int) ieee_variable_Z_enum);	    if (parse_int (&(ieee->h), &va))	      {		PUSH (NOSYMBOL, bfd_abs_section_ptr, va);	      }	    else	      {		/*		  Thats all that we can understand. As far as I can see		  there is a bug in the Microtec IEEE output which I'm		  using to scan, whereby the comma operator is omitted		  sometimes in an expression, giving expressions with too		  many terms. We can tell if that's the case by ensuring		  that sp == stack here. If not, then we've pushed		  something too far, so we keep adding.  */		while (sp != stack + 1)		  {		    asection *section1;		    ieee_symbol_index_type sy1;		    POP (sy1, section1, *extra);		  }		{		  asection *dummy;		  POP (*symbol, dummy, *value);		  if (section)		    *section = dummy;		}		loop = false;	      }	  }	}    }}#define ieee_seek(abfd, offset) \  IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset#define ieee_pos(abfd) \  (IEEE_DATA(abfd)->h.input_p - IEEE_DATA(abfd)->h.first_byte)static unsigned int last_index;static char last_type;		/* is the index for an X or a D */static ieee_symbol_type *get_symbol (abfd,	    ieee,	    last_symbol,	    symbol_count,	    pptr,	    max_index,	    this_type)     bfd *abfd ATTRIBUTE_UNUSED;     ieee_data_type *ieee;     ieee_symbol_type *last_symbol;     unsigned int *symbol_count;     ieee_symbol_type ***pptr;     unsigned int *max_index;     char this_type      ;{  /* Need a new symbol */  unsigned int new_index = must_parse_int (&(ieee->h));  if (new_index != last_index || this_type != last_type)    {      ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd,						 sizeof (ieee_symbol_type));      if (!new_symbol)	return NULL;      new_symbol->index = new_index;      last_index = new_index;      (*symbol_count)++;      **pptr = new_symbol;      *pptr = &new_symbol->next;      if (new_index > *max_index)	{	  *max_index = new_index;	}      last_type = this_type;      new_symbol->symbol.section = bfd_abs_section_ptr;      return new_symbol;    }  return last_symbol;}static booleanieee_slurp_external_symbols (abfd)     bfd *abfd;{  ieee_data_type *ieee = IEEE_DATA (abfd);  file_ptr offset = ieee->w.r.external_part;  ieee_symbol_type **prev_symbols_ptr = &ieee->external_symbols;  ieee_symbol_type **prev_reference_ptr = &ieee->external_reference;  ieee_symbol_type *symbol = (ieee_symbol_type *) NULL;  unsigned int symbol_count = 0;  boolean loop = true;  last_index = 0xffffff;  ieee->symbol_table_full = true;  ieee_seek (abfd, offset);  while (loop)    {      switch (this_byte (&(ieee->h)))	{	case ieee_nn_record:	  next_byte (&(ieee->h));	  symbol = get_symbol (abfd, ieee, symbol, &symbol_count,			       &prev_symbols_ptr,			       &ieee->external_symbol_max_index, 'I');	  if (symbol == NULL)	    return false;	  symbol->symbol.the_bfd = abfd;	  symbol->symbol.name = read_id (&(ieee->h));	  symbol->symbol.udata.p = (PTR) NULL;	  symbol->symbol.flags = BSF_NO_FLAGS;	  break;	case ieee_external_symbol_enum:	  next_byte (&(ieee->h));	  symbol = get_symbol (abfd, ieee, symbol, &symbol_count,			       &prev_symbols_ptr,			       &ieee->external_symbol_max_index, 'D');	  if (symbol == NULL)	    return false;	  BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index);	  symbol->symbol.the_bfd = abfd;	  symbol->symbol.name = read_id (&(ieee->h));	  symbol->symbol.udata.p = (PTR) NULL;	  symbol->symbol.flags = BSF_NO_FLAGS;	  break;	case ieee_attribute_record_enum >> 8:	  {	    unsigned int symbol_name_index;	    unsigned int symbol_type_index;	    unsigned int symbol_attribute_def;	    bfd_vma value;	    switch (read_2bytes (ieee))	      {	      case ieee_attribute_record_enum:		symbol_name_index = must_parse_int (&(ieee->h));		symbol_type_index = must_parse_int (&(ieee->h));		symbol_attribute_def = must_parse_int (&(ieee->h));		switch (symbol_attribute_def)		  {		  case 8:		  case 19:		    parse_int (&ieee->h, &value);		    break;		  default:		    (*_bfd_error_handler)		      (_("%s: unimplemented ATI record  %u for symbol %u"),		       bfd_get_filename (abfd), symbol_attribute_def,		       symbol_name_index);		    bfd_set_error (bfd_error_bad_value);		    return false;		    break;		  }		break;	      case ieee_external_reference_info_record_enum:		/* Skip over ATX record. */		parse_int (&(ieee->h), &value);		parse_int (&(ieee->h), &value);		parse_int (&(ieee->h), &value);		parse_int (&(ieee->h), &value);		break;	      case ieee_atn_record_enum:		/* We may get call optimization information here,		   which we just ignore.  The format is		   {$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs} */		parse_int (&ieee->h, &value);		parse_int (&ieee->h, &value);		parse_int (&ieee->h, &value);		if (value != 0x3f)		  {		    (*_bfd_error_handler)		      (_("%s: unexpected ATN type %d in external part"),			 bfd_get_filename (abfd), (int) value);		    bfd_set_error (bfd_error_bad_value);		    return false;		  }		parse_int (&ieee->h, &value);		parse_int (&ieee->h, &value);		while (value > 0)		  {		    bfd_vma val1;		    --value;		    switch (read_2bytes (ieee))		      {		      case ieee_asn_record_enum:			parse_int (&ieee->h, &val1);			parse_int (&ieee->h, &val1);			break;		      default:			(*_bfd_error_handler)			  (_("%s: unexpected type after ATN"),			     bfd_get_filename (abfd));			bfd_set_error (bfd_error_bad_value);			return false;		      }		  }	      }	  }	  break;	case ieee_value_record_enum >> 8:	  {	    unsigned int symbol_name_index;	    ieee_symbol_index_type symbol_ignore;	    boolean pcrel_ignore;	    unsigned int extra;	    next_byte (&(ieee->h));	    next_byte (&(ieee->h));	    symbol_name_index = must_parse_int (&(ieee->h));	    parse_expression (ieee,			      &symbol->symbol.value,			      &symbol_ignore,			      &pcrel_ignore,			      &extra,			      &symbol->symbol.section);	    /* Fully linked IEEE-695 files tend to give every symbol               an absolute value.  Try to convert that back into a               section relative value.  FIXME: This won't always to               the right thing.  */	    if (bfd_is_abs_section (symbol->symbol.section)		&& (abfd->flags & HAS_RELOC) == 0)	      {		bfd_vma val;		asection *s;		val = symbol->symbol.value;		for (s = abfd->sections; s != NULL; s = s->next)		  {		    if (val >= s->vma && val < s->vma + s->_raw_size)		      {			symbol->symbol.section = s;			symbol->symbol.value -= s->vma;			break;		      }		  }	      }	    symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;	  }	  break;	case ieee_weak_external_reference_enum:	  {	    bfd_vma size;	    bfd_vma value;	    next_byte (&(ieee->h));	    /* Throw away the external reference index */	    (void) must_parse_int (&(ieee->h));	    /* Fetch the default size if not resolved */	    size = must_parse_int (&(ieee->h));	    /* Fetch the defautlt value if available */	    if (parse_int (&(ieee->h), &value) == false)	      {		value = 0;	      }	    /* This turns into a common */	    symbol->symbol.section = bfd_com_section_ptr;	    symbol->symbol.value = size;	  }	  break;	case ieee_external_reference_enum:	  next_byte (&(ieee->h));	  symbol = get_symbol (abfd, ieee, symbol, &symbol_count,			       &prev_reference_ptr,			       &ieee->external_reference_max_index, 'X');	  if (symbol == NULL)	    return false;	  symbol->symbol.the_bfd = abfd;	  symbol->symbol.name = read_id (&(ieee->h));	  symbol->symbol.udata.p = (PTR) NULL;	  symbol->symbol.section = bfd_und_section_ptr;	  symbol->symbol.value = (bfd_vma) 0;	  symbol->symbol.flags = 0;	  BFD_ASSERT (symbol->index >= ieee->external_reference_min_index);	  break;	default:	  loop = false;	}    }  if (ieee->external_symbol_max_index != 0)    {      ieee->external_symbol_count =	ieee->external_symbol_max_index -	ieee->external_symbol_min_index + 1;    }  else    {      ieee->external_symbol_count = 0;    }  if (ieee->external_reference_max_index != 0)    {      ieee->external_reference_count =	ieee->external_reference_max_index -	ieee->external_reference_min_index + 1;    }  else    {      ieee->external_reference_count = 0;    }  abfd->symcount =    ieee->external_reference_count + ieee->external_symbol_count;  if (symbol_count != abfd->symcount)    {      /* There are gaps in the table -- */      ieee->symbol_table_full = false;    }  *prev_symbols_ptr = (ieee_symbol_type *) NULL;  *prev_reference_ptr = (ieee_symbol_type *) NULL;  return true;}static booleanieee_slurp_symbol_table (abfd)     bfd *abfd;{  if (IEEE_DATA (abfd)->read_symbols == false)    {      if (! ieee_slurp_external_symbols (abfd))	return false;      IEEE_DATA (abfd)->read_symbols = true;    }  return true;}longieee_get_symtab_upper_bound (abfd)     bfd *abfd;{  if (! ieee_slurp_symbol_table (abfd))    return -1;  return (abfd->symcount != 0) ?    (abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0;}/*Move from our internal lists to the canon table, and insert insymbol index order*/extern const bfd_target ieee_vec;longieee_get_symtab (abfd, location)     bfd *abfd;     asymbol **location;{  ieee_symbol_type *symp;  static bfd dummy_bfd;  static asymbol empty_symbol =  {    &dummy_bfd,    " ieee empty",    (symvalue) 0,    BSF_DEBUGGING,    bfd_abs_section_ptr#ifdef __STDC__    /* K&R compilers can't initialise unions.  */    , { 0 }#endif  };  if (abfd->symcount)    {      ieee_data_type *ieee = IEEE_DATA (abfd);      dummy_bfd.xvec = &ieee_vec;      if (! ieee_slurp_symbol_table (abfd))	return -1;      if (ieee->symbol_table_full == false)	{	  /* Arrgh - there are gaps in the table, run through and fill them */	  /* up with pointers to a null place */	  unsigned int i;	  for (i = 0; i < abfd->symcount; i++)	    {	      location[i] = &empty_symbol;	    }	}      ieee->external_symbol_base_offset = -ieee->external_symbol_min_index;      for (symp = IEEE_DATA (abfd)->external_symbols;	   symp != (ieee_symbol_type *) NULL;	   symp = symp->next)	{	  /* Place into table at correct index locations */	  location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;	}      /* The external refs are indexed in a bit */      ieee->external_reference_base_offset =	-ieee->external_reference_min_index + ieee->external_symbol_count;      for (symp = IEEE_DATA (abfd)->external_reference;	   symp != (ieee_symbol_type *) NULL;	   symp = symp->next)	{	  location[symp->index + ieee->external_reference_base_offset] =	    &symp->symbol;	}    }  if (abfd->symcount)    {      location[abfd->symcount] = (asymbol *) NULL;    }  return abfd->symcount;}static asection *get_section_entry (abfd, ieee, index)     bfd *abfd;     ieee_data_type *ieee;     unsigned int index;{  if (index >= ieee->section_table_size)    {      unsigned int c, i;      asection **n;      c = ieee->section_table_size;      if (c == 0)	c = 20;      while (c <= index)	c *= 2;      n = ((asection **)	   bfd_realloc (ieee->section_table, c * sizeof (asection *)));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -