vms-tir.c

来自「基于4个mips核的noc设计」· C语言 代码 · 共 2,461 行 · 第 1/4 页

C
2,461
字号
    case ETIR_S_C_OPR_IOR:      op1 = (long)_bfd_vms_pop (abfd, NULL);      op2 = (long)_bfd_vms_pop (abfd, NULL);      _bfd_vms_push (abfd, (uquad) (op1 | op2), -1);      break;      /* logical exclusive or  */    case ETIR_S_C_OPR_EOR:      op1 = (long)_bfd_vms_pop (abfd, NULL);      op2 = (long)_bfd_vms_pop (abfd, NULL);      _bfd_vms_push (abfd, (uquad) (op1 ^ op2), -1);      break;      /* negate  */    case ETIR_S_C_OPR_NEG:      op1 = (long)_bfd_vms_pop (abfd, NULL);      _bfd_vms_push (abfd, (uquad) (-op1), -1);      break;      /* complement  */    case ETIR_S_C_OPR_COM:      op1 = (long)_bfd_vms_pop (abfd, NULL);      _bfd_vms_push (abfd, (uquad) (op1 ^ -1L), -1);      break;      /* insert field  */    case ETIR_S_C_OPR_INSV:      (void)_bfd_vms_pop (abfd, NULL);      (*_bfd_error_handler) (_("ETIR_S_C_OPR_INSV: Not supported"));      break;    /* arithmetic shift  */    case ETIR_S_C_OPR_ASH:      op1 = (long)_bfd_vms_pop (abfd, NULL);      op2 = (long)_bfd_vms_pop (abfd, NULL);      if (op2 < 0)		/* shift right */	op1 >>= -op2;      else			/* shift left */	op1 <<= op2;      _bfd_vms_push (abfd, (uquad)op1, -1);      break;      /* unsigned shift  */    case ETIR_S_C_OPR_USH:      (*_bfd_error_handler) (_("ETIR_S_C_OPR_USH: Not supported"));      break;      /* rotate  */    case ETIR_S_C_OPR_ROT:      (*_bfd_error_handler) (_("ETIR_S_C_OPR_ROT: Not supported"));      break;      /* select  */    case ETIR_S_C_OPR_SEL:      if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L)	(void)_bfd_vms_pop (abfd, NULL);      else	{	  op1 = (long)_bfd_vms_pop (abfd, NULL);	  (void)_bfd_vms_pop (abfd, NULL);	  _bfd_vms_push (abfd, (uquad)op1, -1);	}      break;      /* redefine symbol to current location  */    case ETIR_S_C_OPR_REDEF:      (*_bfd_error_handler) (_("ETIR_S_C_OPR_REDEF: Not supported"));      break;      /* define a literal  */    case ETIR_S_C_OPR_DFLIT:      (*_bfd_error_handler) (_("ETIR_S_C_OPR_DFLIT: Not supported"));      break;    default:      (*_bfd_error_handler) (_("Reserved OPR cmd %d"), cmd);      break;    }  return true;}/* control commands   see table B-11 of the openVMS linker manual  */static booleanetir_ctl (abfd, cmd, ptr)     bfd *abfd;     int cmd;     unsigned char *ptr;{  uquad	 dummy;  int psect;#if VMS_DEBUG  _bfd_vms_debug (5, "etir_ctl %d/%x\n", cmd, cmd);  _bfd_hexdump (8, ptr, 16, (int)ptr);#endif  switch (cmd)    {      /* set relocation base: pop stack, set image location counter	 arg: -  */    case ETIR_S_C_CTL_SETRB:      dummy = _bfd_vms_pop (abfd, &psect);      image_set_ptr (abfd, psect, dummy);      break;      /* augment relocation base: increment image location counter by offset	 arg: lw	offset value  */    case ETIR_S_C_CTL_AUGRB:      dummy = bfd_getl32 (ptr);      image_inc_ptr (abfd, dummy);      break;      /* define location: pop index, save location counter under index	 arg: -  */    case ETIR_S_C_CTL_DFLOC:      dummy = _bfd_vms_pop (abfd, NULL);      /* FIXME */      break;      /* set location: pop index, restore location counter from index	 arg: -  */    case ETIR_S_C_CTL_STLOC:      dummy = _bfd_vms_pop (abfd, &psect);      /* FIXME */      break;      /* stack defined location: pop index, push location counter from index	 arg: -  */    case ETIR_S_C_CTL_STKDL:      dummy = _bfd_vms_pop (abfd, &psect);      /* FIXME */      break;    default:      (*_bfd_error_handler) (_("Reserved CTL cmd %d"), cmd);      break;    }  return true;}/* store conditional commands   see table B-12 and B-13 of the openVMS linker manual  */static booleanetir_stc (abfd, cmd, ptr)     bfd *abfd;     int cmd;     unsigned char *ptr ATTRIBUTE_UNUSED;{#if VMS_DEBUG  _bfd_vms_debug (5, "etir_stc %d/%x\n", cmd, cmd);  _bfd_hexdump (8, ptr, 16, (int)ptr);#endif  switch (cmd)    {      /* 200 Store-conditional Linkage Pair	 arg:  */    case ETIR_S_C_STC_LP:      (*_bfd_error_handler) (_("ETIR_S_C_STC_LP: not supported"));      break;      /* 201 Store-conditional Linkage Pair with Procedure Signature	 arg:	lw	linkage index	 cs	procedure name	 by	signature length	 da	signature  */    case ETIR_S_C_STC_LP_PSB:      image_inc_ptr (abfd, 16);	/* skip entry,procval */      break;      /* 202 Store-conditional Address at global address	 arg:	lw	linkage index	 cs	global name  */    case ETIR_S_C_STC_GBL:      (*_bfd_error_handler) (_("ETIR_S_C_STC_GBL: not supported"));      break;      /* 203 Store-conditional Code Address at global address	 arg:	lw	linkage index	 cs	procedure name  */    case ETIR_S_C_STC_GCA:      (*_bfd_error_handler) (_("ETIR_S_C_STC_GCA: not supported"));      break;      /* 204 Store-conditional Address at psect + offset	 arg:	lw	linkage index	 lw	psect index	 qw	offset  */    case ETIR_S_C_STC_PS:      (*_bfd_error_handler) (_("ETIR_S_C_STC_PS: not supported"));      break;      /* 205 Store-conditional NOP at address of global	 arg:  */    case ETIR_S_C_STC_NOP_GBL:      /* 206 Store-conditional NOP at pect + offset	 arg:  */    case ETIR_S_C_STC_NOP_PS:      /* 207 Store-conditional BSR at global address	 arg:  */    case ETIR_S_C_STC_BSR_GBL:      /* 208 Store-conditional BSR at pect + offset	 arg:  */    case ETIR_S_C_STC_BSR_PS:      /* 209 Store-conditional LDA at global address	 arg:  */    case ETIR_S_C_STC_LDA_GBL:      /* 210 Store-conditional LDA at psect + offset	 arg:  */    case ETIR_S_C_STC_LDA_PS:      /* 211 Store-conditional BSR or Hint at global address	 arg:  */    case ETIR_S_C_STC_BOH_GBL:      /* 212 Store-conditional BSR or Hint at pect + offset	 arg:  */    case ETIR_S_C_STC_BOH_PS:      /* 213 Store-conditional NOP,BSR or HINT at global address	 arg:  */    case ETIR_S_C_STC_NBH_GBL:      /* 214 Store-conditional NOP,BSR or HINT at psect + offset	 arg:  */    case ETIR_S_C_STC_NBH_PS:/* FIXME     (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd); */      break;    default:#if VMS_DEBUG      _bfd_vms_debug (3,  "Reserved STC cmd %d", cmd);#endif      break;    }  return true;}static asection *new_section (abfd, idx)     bfd *abfd ATTRIBUTE_UNUSED;     int idx;{  asection *section;  char sname[16];  char *name;#if VMS_DEBUG  _bfd_vms_debug (5,  "new_section %d\n", idx);#endif  sprintf (sname, SECTION_NAME_TEMPLATE, idx);  name = bfd_malloc (strlen (sname) + 1);  if (name == 0)    return 0;  strcpy (name, sname);  section = bfd_malloc (sizeof (asection));  if (section == 0)    {#if VMS_DEBUG      _bfd_vms_debug (6,  "bfd_make_section (%s) failed", name);#endif      return 0;    }  section->_raw_size = 0;  section->vma = 0;  section->contents = 0;  section->_cooked_size = 0;  section->name = name;  section->index = idx;  return section;}static intalloc_section (abfd, idx)     bfd *abfd;     unsigned int idx;{#if VMS_DEBUG  _bfd_vms_debug (4,  "alloc_section %d\n", idx);#endif  PRIV(sections) = ((asection **)		    bfd_realloc (PRIV(sections), (idx+1) * sizeof (asection *)));  if (PRIV(sections) == 0)    return -1;  while (PRIV(section_count) <= idx)    {      PRIV(sections)[PRIV(section_count)] = new_section (abfd, PRIV(section_count));      if (PRIV(sections)[PRIV(section_count)] == 0)	return -1;      PRIV(section_count)++;    }  return 0;}/* * tir_sta * * vax stack commands * * handle sta_xxx commands in tir section * ptr points to data area in record * * see table 7-3 of the VAX/VMS linker manual */static unsigned char *tir_sta (bfd *abfd, unsigned char *ptr){  int cmd = *ptr++;#if VMS_DEBUG  _bfd_vms_debug (5, "tir_sta %d\n", cmd);#endif  switch (cmd)    {  /* stack */      case TIR_S_C_STA_GBL:	/*	 * stack global	 * arg: cs	symbol name	 *	 * stack 32 bit value of symbol (high bits set to 0)	 */	{	  char *name;	  vms_symbol_entry *entry;	  name = _bfd_vms_save_counted_string (ptr);          entry = _bfd_vms_enter_symbol (abfd, name);	  if (entry == (vms_symbol_entry *)NULL)	    return 0;	  _bfd_vms_push (abfd, (unsigned long) (entry->symbol->value), -1);	  ptr += *ptr + 1;	}      break;      case TIR_S_C_STA_SB:	/*	 * stack signed byte	 * arg: by	value	 *	 * stack byte value, sign extend to 32 bit	 */	_bfd_vms_push (abfd, (long)*ptr++, -1);      break;      case TIR_S_C_STA_SW:	/*	 * stack signed short word	 * arg: sh	value	 *	 * stack 16 bit value, sign extend to 32 bit	 */	_bfd_vms_push (abfd, (long)bfd_getl16(ptr), -1);	ptr += 2;      break;      case TIR_S_C_STA_LW:	/*	 * stack signed longword	 * arg: lw	value	 *	 * stack 32 bit value	 */	_bfd_vms_push (abfd, (long)bfd_getl32 (ptr), -1);	ptr += 4;      break;      case TIR_S_C_STA_PB:      case TIR_S_C_STA_WPB:	/*	 * stack psect base plus byte offset (word index)	 * arg: by	section index	 *	(sh	section index)	 *	by	signed byte offset	 *	 */  	{	  unsigned long dummy;	  unsigned int psect;	  if (cmd == TIR_S_C_STA_PB)	    psect = *ptr++;	  else	    {	      psect = bfd_getl16(ptr);	      ptr += 2;	    }	  if (psect >= PRIV(section_count))	    {	      alloc_section (abfd, psect);	    }	  dummy = (long)*ptr++;	  dummy += (PRIV(sections)[psect])->vma;	  _bfd_vms_push (abfd, dummy, psect);        }      break;      case TIR_S_C_STA_PW:      case TIR_S_C_STA_WPW:	/*	 * stack psect base plus word offset (word index)	 * arg: by	section index	 *	(sh	section index)	 *	sh	signed short offset	 *	 */  	{	  unsigned long dummy;	  unsigned int psect;	  if (cmd == TIR_S_C_STA_PW)	    psect = *ptr++;	  else	    {	      psect = bfd_getl16(ptr);	      ptr += 2;	    }	  if (psect >= PRIV(section_count))	    {	      alloc_section (abfd, psect);	    }	  dummy = bfd_getl16(ptr); ptr+=2;	  dummy += (PRIV(sections)[psect])->vma;	  _bfd_vms_push (abfd, dummy, psect);        }      break;      case TIR_S_C_STA_PL:      case TIR_S_C_STA_WPL:	/*	 * stack psect base plus long offset (word index)	 * arg: by	section index	 *	(sh	section index)	 *	lw	signed longword offset	 *	 */  	{	  unsigned long dummy;	  unsigned int psect;	  if (cmd == TIR_S_C_STA_PL)	    psect = *ptr++;	  else	    {	      psect = bfd_getl16(ptr);	      ptr += 2;	    }	  if (psect >= PRIV(section_count))	    {	      alloc_section (abfd, psect);	    }	  dummy = bfd_getl32 (ptr); ptr += 4;	  dummy += (PRIV(sections)[psect])->vma;	  _bfd_vms_push (abfd, dummy, psect);        }      break;      case TIR_S_C_STA_UB:	/*	 * stack unsigned byte	 * arg: by	value	 *	 * stack byte value	 */	_bfd_vms_push (abfd, (unsigned long)*ptr++, -1);      break;      case TIR_S_C_STA_UW:	/*	 * stack unsigned short word	 * arg: sh	value	 *	 * stack 16 bit value	 */	_bfd_vms_push (abfd, (unsigned long)bfd_getl16(ptr), -1);	ptr += 2;      break;      case TIR_S_C_STA_BFI:	/*	 * stack byte from image	 * arg: -	 *	 */	/*FALLTHRU*/      case TIR_S_C_STA_WFI:	/*	 * stack byte from image	 * arg: -	 *	 */	/*FALLTHRU*/      case TIR_S_C_STA_LFI:	/*	 * stack byte from image	 * arg: -	 *	 */        (*_bfd_error_handler) (_("Stack-from-image not implemented"));	return NULL;      case TIR_S_C_STA_EPM:	/*	 * stack entry point mask	 * arg: cs	symbol name	 *	 * stack (unsigned) entry point mask of symbol	 * err if symbol is no entry point	 */	{	  char *name;	  vms_symbol_entry *entry;	  name = _bfd_vms_save_counted_string (ptr);	  entry = _bfd_vms_enter_symbol (abfd, name);	  if (entry == (vms_symbol_entry *)NULL)	    return 0;          (*_bfd_error_handler) (_("Stack-entry-mask not fully implemented"));	  _bfd_vms_push (abfd, 0L, -1);	  ptr += *ptr + 1;	}      break;      case TIR_S_C_STA_CKARG:	/*	 * compare procedure argument	 * arg: cs	symbol name	 *	by	argument index	 *	da	argument descriptor	 *	 * compare argument descriptor with symbol argument (ARG$V_PASSMECH)	 * and stack TRUE (args match) or FALSE (args dont match) value	 */        (*_bfd_error_handler) (_("PASSMECH not fully implemented"));	_bfd_vms_push (abfd, 1L, -1);	break;      case TIR_S_C_STA_LSY:	/*	 * stack local symbol value	 * arg:	sh	environment index	 *	cs	symbol name	 */	{	  int envidx;	  char *name;	  vms_symbol_entry *entry;	  envidx = bfd_getl16(ptr); ptr += 2;	  name = _bfd_vms_save_counted_string (ptr);	  entry = _bfd_vms_enter_symbol (abfd, name);	  if (entry == (vms_symbol_entry *)NULL)	    return 0;          (*_bfd_error_handler) (_("Stack-local-symbol not fully implemented"));	  _bfd_vms_push (abfd, 0L, -1);	  ptr += *ptr + 1;

⌨️ 快捷键说明

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