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

📄 gcc.c

📁 gcc关键代码
💻 C
📖 第 1 页 / 共 5 页
字号:
  INIT_STATIC_SPEC ("asm_debug",		&asm_debug),  INIT_STATIC_SPEC ("asm_final",		&asm_final_spec),  INIT_STATIC_SPEC ("asm_options",		&asm_options),  INIT_STATIC_SPEC ("invoke_as",		&invoke_as),  INIT_STATIC_SPEC ("cpp",			&cpp_spec),  INIT_STATIC_SPEC ("cpp_options",		&cpp_options),  INIT_STATIC_SPEC ("cpp_debug_options",	&cpp_debug_options),  INIT_STATIC_SPEC ("cpp_unique_options",	&cpp_unique_options),  INIT_STATIC_SPEC ("trad_capable_cpp",		&trad_capable_cpp),  INIT_STATIC_SPEC ("cc1",			&cc1_spec),  INIT_STATIC_SPEC ("cc1_options",		&cc1_options),  INIT_STATIC_SPEC ("cc1plus",			&cc1plus_spec),  INIT_STATIC_SPEC ("link_gcc_c_sequence",	&link_gcc_c_sequence_spec),  INIT_STATIC_SPEC ("link_ssp",			&link_ssp_spec),  INIT_STATIC_SPEC ("endfile",			&endfile_spec),  INIT_STATIC_SPEC ("link",			&link_spec),  INIT_STATIC_SPEC ("lib",			&lib_spec),  INIT_STATIC_SPEC ("mfwrap",			&mfwrap_spec),  INIT_STATIC_SPEC ("mflib",			&mflib_spec),  INIT_STATIC_SPEC ("libgcc",			&libgcc_spec),  INIT_STATIC_SPEC ("startfile",		&startfile_spec),  INIT_STATIC_SPEC ("switches_need_spaces",	&switches_need_spaces),  INIT_STATIC_SPEC ("cross_compile",		&cross_compile),  INIT_STATIC_SPEC ("version",			&compiler_version),  INIT_STATIC_SPEC ("multilib",			&multilib_select),  INIT_STATIC_SPEC ("multilib_defaults",	&multilib_defaults),  INIT_STATIC_SPEC ("multilib_extra",		&multilib_extra),  INIT_STATIC_SPEC ("multilib_matches",		&multilib_matches),  INIT_STATIC_SPEC ("multilib_exclusions",	&multilib_exclusions),  INIT_STATIC_SPEC ("multilib_options",		&multilib_options),  INIT_STATIC_SPEC ("linker",			&linker_name_spec),  INIT_STATIC_SPEC ("link_libgcc",		&link_libgcc_spec),  INIT_STATIC_SPEC ("md_exec_prefix",		&md_exec_prefix),  INIT_STATIC_SPEC ("md_startfile_prefix",	&md_startfile_prefix),  INIT_STATIC_SPEC ("md_startfile_prefix_1",	&md_startfile_prefix_1),  INIT_STATIC_SPEC ("startfile_prefix_spec",	&startfile_prefix_spec),  INIT_STATIC_SPEC ("sysroot_spec",             &sysroot_spec),  INIT_STATIC_SPEC ("sysroot_suffix_spec",	&sysroot_suffix_spec),  INIT_STATIC_SPEC ("sysroot_hdrs_suffix_spec",	&sysroot_hdrs_suffix_spec),};#ifdef EXTRA_SPECS		/* additional specs needed *//* Structure to keep track of just the first two args of a spec_list.   That is all that the EXTRA_SPECS macro gives us.  */struct spec_list_1{  const char *const name;  const char *const ptr;};static const struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS };static struct spec_list *extra_specs = (struct spec_list *) 0;#endif/* List of dynamically allocates specs that have been defined so far.  */static struct spec_list *specs = (struct spec_list *) 0;/* List of static spec functions.  */static const struct spec_function static_spec_functions[] ={  { "if-exists",		if_exists_spec_function },  { "if-exists-else",		if_exists_else_spec_function },  { "replace-outfile",		replace_outfile_spec_function },  { "version-compare",		version_compare_spec_function },  { 0, 0 }};static int processing_spec_function;/* Add appropriate libgcc specs to OBSTACK, taking into account   various permutations of -shared-libgcc, -shared, and such.  */#if defined(ENABLE_SHARED_LIBGCC) && !defined(REAL_LIBGCC_SPEC)#ifndef USE_LD_AS_NEEDED#define USE_LD_AS_NEEDED 0#endifstatic voidinit_gcc_specs (struct obstack *obstack, const char *shared_name,		const char *static_name, const char *eh_name){  char *buf;  buf = concat ("%{static|static-libgcc:", static_name, " ", eh_name,		"}%{!static:%{!static-libgcc:",#if USE_LD_AS_NEEDED		"%{!shared-libgcc:", static_name,		" --as-needed ", shared_name, " --no-as-needed}"		"%{shared-libgcc:", shared_name, "%{!shared: ", static_name,		"}",#else		"%{!shared:%{!shared-libgcc:", static_name, " ",		eh_name, "}%{shared-libgcc:", shared_name, " ",		static_name, "}}%{shared:",#ifdef LINK_EH_SPEC		"%{shared-libgcc:", shared_name,		"}%{!shared-libgcc:", static_name, "}",#else		shared_name,#endif#endif		"}}}", NULL);  obstack_grow (obstack, buf, strlen (buf));  free (buf);}#endif /* ENABLE_SHARED_LIBGCC *//* Initialize the specs lookup routines.  */static voidinit_spec (void){  struct spec_list *next = (struct spec_list *) 0;  struct spec_list *sl   = (struct spec_list *) 0;  int i;  if (specs)    return;			/* Already initialized.  */  if (verbose_flag)    notice ("Using built-in specs.\n");#ifdef EXTRA_SPECS  extra_specs = xcalloc (sizeof (struct spec_list),			 ARRAY_SIZE (extra_specs_1));  for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--)    {      sl = &extra_specs[i];      sl->name = extra_specs_1[i].name;      sl->ptr = extra_specs_1[i].ptr;      sl->next = next;      sl->name_len = strlen (sl->name);      sl->ptr_spec = &sl->ptr;      next = sl;    }#endif  /* Initialize here, not in definition.  The IRIX 6 O32 cc sometimes chokes     on ?: in file-scope variable initializations.  */  asm_debug = ASM_DEBUG_SPEC;  for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)    {      sl = &static_specs[i];      sl->next = next;      next = sl;    }#if defined(ENABLE_SHARED_LIBGCC) && !defined(REAL_LIBGCC_SPEC)  /* ??? If neither -shared-libgcc nor --static-libgcc was     seen, then we should be making an educated guess.  Some proposed     heuristics for ELF include:	(1) If "-Wl,--export-dynamic", then it's a fair bet that the	    program will be doing dynamic loading, which will likely	    need the shared libgcc.	(2) If "-ldl", then it's also a fair bet that we're doing	    dynamic loading.	(3) For each ET_DYN we're linking against (either through -lfoo	    or /some/path/foo.so), check to see whether it or one of	    its dependencies depends on a shared libgcc.	(4) If "-shared"	    If the runtime is fixed to look for program headers instead	    of calling __register_frame_info at all, for each object,	    use the shared libgcc if any EH symbol referenced.	    If crtstuff is fixed to not invoke __register_frame_info	    automatically, for each object, use the shared libgcc if	    any non-empty unwind section found.     Doing any of this probably requires invoking an external program to     do the actual object file scanning.  */  {    const char *p = libgcc_spec;    int in_sep = 1;    /* Transform the extant libgcc_spec into one that uses the shared libgcc       when given the proper command line arguments.  */    while (*p)      {	if (in_sep && *p == '-' && strncmp (p, "-lgcc", 5) == 0)	  {	    init_gcc_specs (&obstack,			    "-lgcc_s"#ifdef USE_LIBUNWIND_EXCEPTIONS			    " -lunwind"#endif			    ,			    "-lgcc",			    "-lgcc_eh"#ifdef USE_LIBUNWIND_EXCEPTIONS# ifdef HAVE_LD_STATIC_DYNAMIC			    " %{!static:-Bstatic} -lunwind %{!static:-Bdynamic}"# else			    " -lunwind"# endif#endif			    );	    p += 5;	    in_sep = 0;	  }	else if (in_sep && *p == 'l' && strncmp (p, "libgcc.a%s", 10) == 0)	  {	    /* Ug.  We don't know shared library extensions.  Hope that	       systems that use this form don't do shared libraries.  */	    init_gcc_specs (&obstack,			    "-lgcc_s",			    "libgcc.a%s",			    "libgcc_eh.a%s"#ifdef USE_LIBUNWIND_EXCEPTIONS			    " -lunwind"#endif			    );	    p += 10;	    in_sep = 0;	  }	else	  {	    obstack_1grow (&obstack, *p);	    in_sep = (*p == ' ');	    p += 1;	  }      }    obstack_1grow (&obstack, '\0');    libgcc_spec = XOBFINISH (&obstack, const char *);  }#endif#ifdef USE_AS_TRADITIONAL_FORMAT  /* Prepend "--traditional-format" to whatever asm_spec we had before.  */  {    static const char tf[] = "--traditional-format ";    obstack_grow (&obstack, tf, sizeof(tf) - 1);    obstack_grow0 (&obstack, asm_spec, strlen (asm_spec));    asm_spec = XOBFINISH (&obstack, const char *);  }#endif#ifdef LINK_EH_SPEC  /* Prepend LINK_EH_SPEC to whatever link_spec we had before.  */  obstack_grow (&obstack, LINK_EH_SPEC, sizeof(LINK_EH_SPEC) - 1);  obstack_grow0 (&obstack, link_spec, strlen (link_spec));  link_spec = XOBFINISH (&obstack, const char *);#endif  specs = sl;}/* Change the value of spec NAME to SPEC.  If SPEC is empty, then the spec is   removed; If the spec starts with a + then SPEC is added to the end of the   current spec.  */static voidset_spec (const char *name, const char *spec){  struct spec_list *sl;  const char *old_spec;  int name_len = strlen (name);  int i;  /* If this is the first call, initialize the statically allocated specs.  */  if (!specs)    {      struct spec_list *next = (struct spec_list *) 0;      for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)	{	  sl = &static_specs[i];	  sl->next = next;	  next = sl;	}      specs = sl;    }  /* See if the spec already exists.  */  for (sl = specs; sl; sl = sl->next)    if (name_len == sl->name_len && !strcmp (sl->name, name))      break;  if (!sl)    {      /* Not found - make it.  */      sl = xmalloc (sizeof (struct spec_list));      sl->name = xstrdup (name);      sl->name_len = name_len;      sl->ptr_spec = &sl->ptr;      sl->alloc_p = 0;      *(sl->ptr_spec) = "";      sl->next = specs;      specs = sl;    }  old_spec = *(sl->ptr_spec);  *(sl->ptr_spec) = ((spec[0] == '+' && ISSPACE ((unsigned char)spec[1]))		     ? concat (old_spec, spec + 1, NULL)		     : xstrdup (spec));#ifdef DEBUG_SPECS  if (verbose_flag)    notice ("Setting spec %s to '%s'\n\n", name, *(sl->ptr_spec));#endif  /* Free the old spec.  */  if (old_spec && sl->alloc_p)    free ((void *) old_spec);  sl->alloc_p = 1;}/* Accumulate a command (program name and args), and run it.  *//* Vector of pointers to arguments in the current line of specifications.  */static const char **argbuf;/* Number of elements allocated in argbuf.  */static int argbuf_length;/* Number of elements in argbuf currently in use (containing args).  */static int argbuf_index;/* Position in the argbuf array containing the name of the output file   (the value associated with the "-o" flag).  */static int have_o_argbuf_index = 0;/* Were the options -c or -S passed.  */static int have_c = 0;/* Was the option -o passed.  */static int have_o = 0;/* This is the list of suffixes and codes (%g/%u/%U/%j) and the associated   temp file.  If the HOST_BIT_BUCKET is used for %j, no entry is made for   it here.  */static struct temp_name {  const char *suffix;	/* suffix associated with the code.  */  int length;		/* strlen (suffix).  */  int unique;		/* Indicates whether %g or %u/%U was used.  */  const char *filename;	/* associated filename.  */  int filename_length;	/* strlen (filename).  */  struct temp_name *next;} *temp_names;/* Number of commands executed so far.  */static int execution_count;/* Number of commands that exited with a signal.  */static int signal_count;/* Name with which this program was invoked.  */static const char *programname;/* Allocate the argument vector.  */static voidalloc_args (void){  argbuf_length = 10;  argbuf = xmalloc (argbuf_length * sizeof (const char *));}/* Clear out the vector of arguments (after a command is executed).  */stati

⌨️ 快捷键说明

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