obj-aout.c

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

C
759
字号
      *input_line_pointer = c;      SKIP_WHITESPACE ();      S_SET_WEAK (symbolP);      if (c == ',')	{	  input_line_pointer++;	  SKIP_WHITESPACE ();	  if (*input_line_pointer == '\n')	    c = '\n';	}    }  while (c == ',');  demand_empty_rest_of_line ();}/* Handle .type.  On {Net,Open}BSD, this is used to set the n_other field,   which is then apparently used when doing dynamic linking.  Older   versions of gas ignored the .type pseudo-op, so we also ignore it if   we can't parse it.  */static voidobj_aout_type (ignore)     int ignore ATTRIBUTE_UNUSED;{  char *name;  int c;  symbolS *sym;  name = input_line_pointer;  c = get_symbol_end ();  sym = symbol_find_or_make (name);  *input_line_pointer = c;  SKIP_WHITESPACE ();  if (*input_line_pointer == ',')    {      ++input_line_pointer;      SKIP_WHITESPACE ();      if (*input_line_pointer == '@')	{	  ++input_line_pointer;	  if (strncmp (input_line_pointer, "object", 6) == 0)#ifdef BFD_ASSEMBLER	    aout_symbol (symbol_get_bfdsym (sym))->other = 1;#else	  S_SET_OTHER (sym, 1);#endif	  else if (strncmp (input_line_pointer, "function", 8) == 0)#ifdef BFD_ASSEMBLER	    aout_symbol (symbol_get_bfdsym (sym))->other = 2;#else	  S_SET_OTHER (sym, 2);#endif	}    }  /* Ignore everything else on the line.  */  s_ignore (0);}#ifndef BFD_ASSEMBLERvoidobj_crawl_symbol_chain (headers)     object_headers *headers;{  symbolS *symbolP;  symbolS **symbolPP;  int symbol_number = 0;  tc_crawl_symbol_chain (headers);  symbolPP = &symbol_rootP;	/*->last symbol chain link.  */  while ((symbolP = *symbolPP) != NULL)    {      if (symbolP->sy_mri_common)	{	  if (S_IS_EXTERNAL (symbolP))	    as_bad (_("%s: global symbols not supported in common sections"),		    S_GET_NAME (symbolP));	  *symbolPP = symbol_next (symbolP);	  continue;	}      if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_DATA))	{	  S_SET_SEGMENT (symbolP, SEG_TEXT);	}			/* if pusing data into text */      resolve_symbol_value (symbolP, 1);      /* Skip symbols which were equated to undefined or common	 symbols.  */      if (symbolP->sy_value.X_op == O_symbol	  && (! S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP)))	{	  *symbolPP = symbol_next (symbolP);	  continue;	}      /* OK, here is how we decide which symbols go out into the brave	 new symtab.  Symbols that do are:	 * symbols with no name (stabd's?)	 * symbols with debug info in their N_TYPE	 Symbols that don't are:	 * symbols that are registers	 * symbols with \1 as their 3rd character (numeric labels)	 * "local labels" as defined by S_LOCAL_NAME(name) if the -L	 switch was passed to gas.	 All other symbols are output.  We complain if a deleted	 symbol was marked external.  */      if (!S_IS_REGISTER (symbolP)	  && (!S_GET_NAME (symbolP)	      || S_IS_DEBUG (symbolP)	      || !S_IS_DEFINED (symbolP)	      || S_IS_EXTERNAL (symbolP)	      || (S_GET_NAME (symbolP)[0] != '\001'		  && (flag_keep_locals || !S_LOCAL_NAME (symbolP)))))	{	  symbolP->sy_number = symbol_number++;	  /* The + 1 after strlen account for the \0 at the			   end of each string */	  if (!S_IS_STABD (symbolP))	    {	      /* Ordinary case.  */	      symbolP->sy_name_offset = string_byte_count;	      string_byte_count += strlen (S_GET_NAME (symbolP)) + 1;	    }	  else			/* .Stabd case.  */	    symbolP->sy_name_offset = 0;	  symbolPP = &symbolP->sy_next;	}      else	{	  if (S_IS_EXTERNAL (symbolP) || !S_IS_DEFINED (symbolP))	    /* This warning should never get triggered any more.	       Well, maybe if you're doing twisted things with	       register names...  */	    {	      as_bad (_("Local symbol %s never defined."), decode_local_label_name (S_GET_NAME (symbolP)));	    }			/* oops.  */	  /* Unhook it from the chain */	  *symbolPP = symbol_next (symbolP);	}			/* if this symbol should be in the output */    }				/* for each symbol */  H_SET_SYMBOL_TABLE_SIZE (headers, symbol_number);}/* * Find strings by crawling along symbol table chain. */voidobj_emit_strings (where)     char **where;{  symbolS *symbolP;#ifdef CROSS_COMPILE  /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */  md_number_to_chars (*where, string_byte_count, sizeof (string_byte_count));  *where += sizeof (string_byte_count);#else /* CROSS_COMPILE */  append (where, (char *) &string_byte_count, (unsigned long) sizeof (string_byte_count));#endif /* CROSS_COMPILE */  for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))    {      if (S_GET_NAME (symbolP))	append (&next_object_file_charP, S_GET_NAME (symbolP),		(unsigned long) (strlen (S_GET_NAME (symbolP)) + 1));    }				/* walk symbol chain */}#ifndef AOUT_VERSION#define AOUT_VERSION 0#endifvoidobj_pre_write_hook (headers)     object_headers *headers;{  H_SET_DYNAMIC (headers, 0);  H_SET_VERSION (headers, AOUT_VERSION);  H_SET_MACHTYPE (headers, AOUT_MACHTYPE);  tc_aout_pre_write_hook (headers);}voids_sect (){  /* Strip out the section name */  char *section_name;  char *section_name_end;  char c;  unsigned int len;  unsigned int exp;  char *save;  section_name = input_line_pointer;  c = get_symbol_end ();  section_name_end = input_line_pointer;  len = section_name_end - section_name;  input_line_pointer++;  save = input_line_pointer;  SKIP_WHITESPACE ();  if (c == ',')    {      exp = get_absolute_expression ();    }  else if (*input_line_pointer == ',')    {      input_line_pointer++;      exp = get_absolute_expression ();    }  else    {      input_line_pointer = save;      exp = 0;    }  if (exp >= 1000)    {      as_bad (_("subsegment index too high"));    }  if (strcmp (section_name, ".text") == 0)    {      subseg_set (SEG_TEXT, (subsegT) exp);    }  if (strcmp (section_name, ".data") == 0)    {      if (flag_readonly_data_in_text)	subseg_set (SEG_TEXT, (subsegT) exp + 1000);      else	subseg_set (SEG_DATA, (subsegT) exp);    }  *section_name_end = c;}#endif /* ! BFD_ASSEMBLER */#ifdef BFD_ASSEMBLER/* Support for an AOUT emulation.  */static void aout_pop_insert PARAMS ((void));static int obj_aout_s_get_other PARAMS ((symbolS *));static void obj_aout_s_set_other PARAMS ((symbolS *, int));static int obj_aout_s_get_desc PARAMS ((symbolS *));static void obj_aout_s_set_desc PARAMS ((symbolS *, int));static int obj_aout_s_get_type PARAMS ((symbolS *));static void obj_aout_s_set_type PARAMS ((symbolS *, int));static int obj_aout_separate_stab_sections PARAMS ((void));static int obj_aout_sec_sym_ok_for_reloc PARAMS ((asection *));static void obj_aout_process_stab PARAMS ((segT, int, const char *, int, int, int));static voidaout_pop_insert (){  pop_insert (aout_pseudo_table);}static intobj_aout_s_get_other (sym)     symbolS *sym;{  return aout_symbol (symbol_get_bfdsym (sym))->other;}static voidobj_aout_s_set_other (sym, o)     symbolS *sym;     int o;{  aout_symbol (symbol_get_bfdsym (sym))->other = o;}static intobj_aout_sec_sym_ok_for_reloc (sec)     asection *sec ATTRIBUTE_UNUSED;{  return obj_sec_sym_ok_for_reloc (sec);}static voidobj_aout_process_stab (seg, w, s, t, o, d)     segT seg ATTRIBUTE_UNUSED;     int w;     const char *s;     int t;     int o;     int d;{  aout_process_stab (w, s, t, o, d);}static intobj_aout_s_get_desc (sym)     symbolS *sym;{  return aout_symbol (symbol_get_bfdsym (sym))->desc;}static voidobj_aout_s_set_desc (sym, d)     symbolS *sym;     int d;{  aout_symbol (symbol_get_bfdsym (sym))->desc = d;}static intobj_aout_s_get_type (sym)     symbolS *sym;{  return aout_symbol (symbol_get_bfdsym (sym))->type;}static voidobj_aout_s_set_type (sym, t)     symbolS *sym;     int t;{  aout_symbol (symbol_get_bfdsym (sym))->type = t;}static intobj_aout_separate_stab_sections (){  return 0;}/* When changed, make sure these table entries match the single-format   definitions in obj-aout.h.  */const struct format_ops aout_format_ops ={  bfd_target_aout_flavour,  1,	/* dfl_leading_underscore */  0,	/* emit_section_symbols */  0,	/* begin */  0,	/* app_file */  obj_aout_frob_symbol,  obj_aout_frob_file,  0,	/* frob_file_before_adjust */  0,	/* frob_file_after_relocs */  0,	/* s_get_size */  0,	/* s_set_size */  0,	/* s_get_align */  0,	/* s_set_align */  obj_aout_s_get_other,  obj_aout_s_set_other,  obj_aout_s_get_desc,  obj_aout_s_set_desc,  obj_aout_s_get_type,  obj_aout_s_set_type,  0,	/* copy_symbol_attributes */  0,	/* generate_asm_lineno */  obj_aout_process_stab,  obj_aout_separate_stab_sections,  0,	/* init_stab_section */  obj_aout_sec_sym_ok_for_reloc,  aout_pop_insert,  0,	/* ecoff_set_ext */  0,	/* read_begin_hook */  0 	/* symbol_new_hook */};#endif BFD_ASSEMBLER

⌨️ 快捷键说明

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