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

📄 pe.em

📁 俄罗斯高人Mamaich的Pocket gcc编译器(运行在PocketPC上)的全部源代码。
💻 EM
📖 第 1 页 / 共 4 页
字号:
static asection *output_prev_sec_find (os)     lang_output_section_statement_type *os;{  asection *s = (asection *) NULL;  lang_statement_union_type *u;  lang_output_section_statement_type *lookup;  for (u = lang_output_section_statement.head;       u != (lang_statement_union_type *) NULL;       u = lookup->next)    {      lookup = &u->output_section_statement;      if (lookup == os)	return s;      if (lookup->bfd_section != NULL && lookup->bfd_section->owner != NULL)	s = lookup->bfd_section;    }  return NULL;}/* Place an orphan section.   We use this to put sections in a reasonable place in the file, and   to ensure that they are aligned as required.   We handle grouped sections here as well.  A section named .foo$nn   goes into the output section .foo.  All grouped sections are sorted   by name.   Grouped sections for the default sections are handled by the   default linker script using wildcards, and are sorted by   sort_sections.  */struct orphan_save{  lang_output_section_statement_type *os;  asection **section;  lang_statement_union_type **stmt;};/*ARGSUSED*/static booleangld_${EMULATION_NAME}_place_orphan (file, s)     lang_input_statement_type *file;     asection *s;{  const char *secname;  char *hold_section_name;  char *dollar = NULL;  const char *ps = NULL;  lang_output_section_statement_type *os;  lang_statement_list_type add_child;  secname = bfd_get_section_name (s->owner, s);  /* Look through the script to see where to place this section.  */  hold_section_name = xstrdup (secname);  if (!link_info.relocateable)    {      dollar = strchr (hold_section_name, '$');      if (dollar != NULL)	*dollar = '\0';    }  os = lang_output_section_find (hold_section_name);  lang_list_init (&add_child);  if (os != NULL      && (os->bfd_section == NULL	  || ((s->flags ^ os->bfd_section->flags)	      & (SEC_LOAD | SEC_ALLOC)) == 0))    {      /* We already have an output section statement with this	 name, and its bfd section, if any, has compatible flags.  */      lang_add_section (&add_child, s, os, file);    }  else    {      struct orphan_save *place;      static struct orphan_save hold_text;      static struct orphan_save hold_rdata;      static struct orphan_save hold_data;      static struct orphan_save hold_bss;      char *outsecname;      lang_statement_list_type *old;      lang_statement_list_type add;      etree_type *address;      /* Try to put the new output section in a reasonable place based	 on the section name and section flags.  */#define HAVE_SECTION(hold, name) \(hold.os != NULL || (hold.os = lang_output_section_find (name)) != NULL)      place = NULL;      if ((s->flags & SEC_ALLOC) == 0)	;      else if ((s->flags & SEC_HAS_CONTENTS) == 0	       && HAVE_SECTION (hold_bss, ".bss"))	place = &hold_bss;      else if ((s->flags & SEC_READONLY) == 0	       && HAVE_SECTION (hold_data, ".data"))	place = &hold_data;      else if ((s->flags & SEC_CODE) == 0	       && (s->flags & SEC_READONLY) != 0	       && HAVE_SECTION (hold_rdata, ".rdata"))	place = &hold_rdata;      else if ((s->flags & SEC_READONLY) != 0	       && HAVE_SECTION (hold_text, ".text"))	place = &hold_text;#undef HAVE_SECTION      /* Choose a unique name for the section.  This will be needed if	 the same section name appears in the input file with	 different loadable or allocatable characteristics.  */      outsecname = xstrdup (hold_section_name);      if (bfd_get_section_by_name (output_bfd, outsecname) != NULL)	{	  unsigned int len;	  char *newname;	  unsigned int i;	  len = strlen (outsecname);	  newname = xmalloc (len + 5);	  strcpy (newname, outsecname);	  i = 0;	  do	    {	      sprintf (newname + len, "%d", i);	      ++i;	    }	  while (bfd_get_section_by_name (output_bfd, newname) != NULL);	  free (outsecname);	  outsecname = newname;	}      /* Start building a list of statements for this section.  */      old = stat_ptr;      stat_ptr = &add;      lang_list_init (stat_ptr);      if (config.build_constructors)	{	  /* If the name of the section is representable in C, then create	     symbols to mark the start and the end of the section.  */	  for (ps = outsecname; *ps != '\0'; ps++)	    if (! isalnum ((unsigned char) *ps) && *ps != '_')	      break;	  if (*ps == '\0')	    {	      char *symname;	      etree_type *e_align;	      symname = (char *) xmalloc (ps - outsecname + sizeof "___start_");	      sprintf (symname, "___start_%s", outsecname);	      e_align = exp_unop (ALIGN_K,				  exp_intop ((bfd_vma) 1 << s->alignment_power));	      lang_add_assignment (exp_assop ('=', symname, e_align));	    }	}      if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0)	address = exp_intop ((bfd_vma) 0);      else	{	  /* All sections in an executable must be aligned to a page	     boundary.  */	  address = exp_unop (ALIGN_K,			      exp_nameop (NAME, "__section_alignment__"));	}      os = lang_enter_output_section_statement (outsecname, address, 0,						(bfd_vma) 0,						(etree_type *) NULL,						(etree_type *) NULL,						(etree_type *) NULL);      lang_add_section (&add_child, s, os, file);      lang_leave_output_section_statement	((bfd_vma) 0, "*default*",	 (struct lang_output_section_phdr_list *) NULL, NULL);      if (config.build_constructors && *ps == '\0')        {	  char *symname;	  /* lang_leave_ouput_section_statement resets stat_ptr.  Put	     stat_ptr back where we want it.  */	  if (place != NULL)	    stat_ptr = &add;	  symname = (char *) xmalloc (ps - outsecname + sizeof "___stop_");	  sprintf (symname, "___stop_%s", outsecname);	  lang_add_assignment (exp_assop ('=', symname,					  exp_nameop (NAME, ".")));	}      stat_ptr = old;      if (place != NULL && os->bfd_section != NULL)	{	  asection *snew, **pps;	  snew = os->bfd_section;	  /* Shuffle the bfd section list to make the output file look	     neater.  This is really only cosmetic.  */	  if (place->section == NULL)	    {	      asection *bfd_section = place->os->bfd_section;	      /* If the output statement hasn't been used to place		 any input sections (and thus doesn't have an output		 bfd_section), look for the closest prior output statement		 having an output section.  */	      if (bfd_section == NULL)		bfd_section = output_prev_sec_find (place->os);	      if (bfd_section != NULL && bfd_section != snew)		place->section = &bfd_section->next;	    }	  if (place->section != NULL)	    {	      /* Unlink the section.  */	      for (pps = &output_bfd->sections;		   *pps != snew;		   pps = &(*pps)->next)		;	      bfd_section_list_remove (output_bfd, pps);	      /* Now tack it on to the "place->os" section list.  */	      bfd_section_list_insert (output_bfd, place->section, snew);	    }	  /* Save the end of this list.  Further ophans of this type will	     follow the one we've just added.  */	  place->section = &snew->next;	  /* The following is non-cosmetic.  We try to put the output	     statements in some sort of reasonable order here, because	     they determine the final load addresses of the orphan	     sections.  In addition, placing output statements in the	     wrong order may require extra segments.  For instance,	     given a typical situation of all read-only sections placed	     in one segment and following that a segment containing all	     the read-write sections, we wouldn't want to place an orphan	     read/write section before or amongst the read-only ones.  */	  if (add.head != NULL)	    {	      if (place->stmt == NULL)		{		  /* Put the new statement list right at the head.  */		  *add.tail = place->os->header.next;		  place->os->header.next = add.head;		}	      else		{		  /* Put it after the last orphan statement we added.  */		  *add.tail = *place->stmt;		  *place->stmt = add.head;		}	      /* Fix the global list pointer if we happened to tack our		 new list at the tail.  */	      if (*old->tail == add.head)		old->tail = add.tail;	      /* Save the end of this list.  */	      place->stmt = add.tail;	    }	}    }  {    lang_statement_union_type **pl = &os->children.head;    if (dollar != NULL)      {	boolean found_dollar;	/* The section name has a '$'.  Sort it with the other '$'	   sections.  */	found_dollar = false;	for ( ; *pl != NULL; pl = &(*pl)->header.next)	  {	    lang_input_section_type *ls;	    const char *lname;	    if ((*pl)->header.type != lang_input_section_enum)	      continue;	    ls = &(*pl)->input_section;	    lname = bfd_get_section_name (ls->ifile->the_bfd, ls->section);	    if (strchr (lname, '$') == NULL)	      {		if (found_dollar)		  break;	      }	    else	      {		found_dollar = true;		if (strcmp (secname, lname) < 0)		  break;	      }	  }      }    if (add_child.head != NULL)      {	add_child.head->header.next = *pl;	*pl = add_child.head;      }  }  free (hold_section_name);  return true;}static booleangld_${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)     const char * arch ATTRIBUTE_UNUSED;     search_dirs_type * search;     lang_input_statement_type * entry;{  const char * filename;  char * string;  if (! entry->is_archive)    return false;  filename = entry->filename;  string = (char *) xmalloc (strlen (search->name)                             + strlen (filename)                             + sizeof "/lib.a.dll"#ifdef DLL_SUPPORT                             + (pe_dll_search_prefix ? strlen (pe_dll_search_prefix) : 0)#endif                             + 1);  /* Try "libfoo.dll.a" first (preferred explicit import library for dll's */  sprintf (string, "%s/lib%s.dll.a", search->name, filename);  if (! ldfile_try_open_bfd (string, entry))    {      /* Try "foo.dll.a" next (alternate explicit import library for dll's */      sprintf (string, "%s/%s.dll.a", search->name, filename);      if (! ldfile_try_open_bfd (string, entry))        {/*   Try libfoo.a next. Normally, this would be interpreted as a static   library, but it *could* be an import library. For backwards compatibility,   libfoo.a needs to ==precede== libfoo.dll and foo.dll in the search,   or sometimes errors occur when building legacy packages.   Putting libfoo.a here means that in a failure case (i.e. the library   -lfoo is not found) we will search for libfoo.a twice before   giving up -- once here, and once when searching for a "static" lib.   for a "static" lib.*/          /* Try "libfoo.a" (import lib, or static lib, but must             take precedence over dll's) */          sprintf (string, "%s/lib%s.a", search->name, filename);          if (! ldfile_try_open_bfd (string, entry))            {#ifdef DLL_SUPPORT              if (pe_dll_search_prefix)                {                  /* Try "<prefix>foo.dll" (preferred dll name, if specified) */                  sprintf (string, "%s/%s%s.dll", search->name, pe_dll_search_prefix, filename);                  if (! ldfile_try_open_bfd (string, entry))                    {                      /* Try "libfoo.dll" (default preferred dll name) */                      sprintf (string, "%s/lib%s.dll", search->name, filename);                      if (! ldfile_try_open_bfd (string, entry))                        {                          /* Finally, try "foo.dll" (alternate dll name) */                          sprintf (string, "%s/%s.dll", search->name, filename);                          if (! ldfile_try_open_bfd (string, entry))                            {                              free (string);                              return false;                            }                        }                    }                }              else /* pe_dll_search_prefix not specified */#endif                {                  /* Try "libfoo.dll" (preferred dll name) */                  sprintf (string, "%s/lib%s.dll", search->name, filename);                  if (! ldfile_try_open_bfd (string, entry))                    {                      /* Finally, try "foo.dll" (alternate dll name) */                      sprintf (string, "%s/%s.dll", search->name, filename);                      if (! ldfile_try_open_bfd (string, entry))                        {                          free (string);                          return false;                        }                    }                }            }        }    }  entry->filename = string;  return true;}static intgld_${EMULATION_NAME}_find_potential_libraries (name, entry)     char * name;     lang_input_statement_type * entry;{  return ldfile_open_file_search (name, entry, "", ".lib");}static char *gld_${EMULATION_NAME}_get_script(isfile)     int *isfile;EOF# Scripts compiled in.# sed commands to quote an ld script as a C string.sc="-f stringify.sed"cat >>e${EMULATION_NAME}.c <<EOF{  *isfile = 0;  if (link_info.relocateable == true && config.build_constructors == true)    returnEOFsed $sc ldscripts/${EMULATION_NAME}.xu                     >> e${EMULATION_NAME}.cecho '  ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.csed $sc ldscripts/${EMULATION_NAME}.xr                     >> e${EMULATION_NAME}.cecho '  ; else if (!config.text_read_only) return'         >> e${EMULATION_NAME}.csed $sc ldscripts/${EMULATION_NAME}.xbn                    >> e${EMULATION_NAME}.cecho '  ; else if (!config.magic_demand_paged) return'     >> e${EMULATION_NAME}.csed $sc ldscripts/${EMULATION_NAME}.xn                     >> e${EMULATION_NAME}.cecho '  ; else return'                                     >> e${EMULATION_NAME}.csed $sc ldscripts/${EMULATION_NAME}.x                      >> e${EMULATION_NAME}.cecho '; }'                                                 >> e${EMULATION_NAME}.ccat >>e${EMULATION_NAME}.c <<EOFstruct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation ={  gld_${EMULATION_NAME}_before_parse,  syslib_default,  hll_default,  gld_${EMULATION_NAME}_after_parse,  gld_${EMULATION_NAME}_after_open,  after_allocation_default,  set_output_arch_default,  ldemul_default_target,  gld_${EMULATION_NAME}_before_allocation,  gld_${EMULATION_NAME}_get_script,  "${EMULATION_NAME}",  "${OUTPUT_FORMAT}",  gld_${EMULATION_NAME}_finish, /* finish */  NULL, /* create output section statements */  gld_${EMULATION_NAME}_open_dynamic_archive,  gld_${EMULATION_NAME}_place_orphan,  gld_${EMULATION_NAME}_set_symbols,  gld_${EMULATION_NAME}_parse_args,  gld_${EMULATION_NAME}_unrecognized_file,  gld_${EMULATION_NAME}_list_options,  gld_${EMULATION_NAME}_recognized_file,  gld_${EMULATION_NAME}_find_potential_libraries,  NULL	/* new_vers_pattern */};EOF

⌨️ 快捷键说明

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