This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: input section ordering


On Thu, Jun 21, 2001 at 09:36:43AM -0700, Ian Lance Taylor wrote:
> Alan Modra <amodra@bigpond.net.au> writes:
> 
> > ld.info,  Node: Input Section Basics says this:
> > 
> > "There are two ways to include more than one section:
> >      *(.text .rdata)
> >      *(.text) *(.rdata)
> > 
> > The difference between these is the order in which the `.text' and
> > `.rdata' input sections will appear in the output section.  In the
> > first example, they will be intermingled.  In the second example, all
> > `.text' input sections will appear first, followed by all `.rdata'
> > input sections."
> > 
> > This paragraph was the basis for my suggestion to Geoff Keating re
> > .eh_frame data.
> 
> This would just be a change to lang_wild_statement, I think.  Instead
> of creating a new lang_wild_statement for each filename, keep a list
> of filenames within one *(A B C) construct.  Then check the whole list
> in walk_wild_section and perhaps a few other places.

Here we go.

ld/ChangeLog
 	Order input sections as found in the linker input for
 	"file_match(sec1_match sec2_match)" type input section spec.
 
 	* ld.texinfo (Input Section Basics): Clarify ordering of output
 	sections.
 	* ldlang.c (callback_t): Add wildcard_list param.
 	(walk_wild_section): Remove "section" param.  Rewrite for
 	lang_wild_statement_type change.  Remove unique_section_p test.
 	(walk_wild_file): Remove "section" param.
 	(walk_wild): Remove "section" and "file" params.
 	(lang_gc_wild): Likewise.
 	(wild): Likewise.  Modify for lang_wild_statement_type change.
 	(wild_sort): Likewise.  Add "sec" param.
 	(gc_section_callback): Likewise.
 	(output_section_callback): Likewise.  Do unique_section_p test.
 	(map_input_to_output_sections): Modify call to wild.
 	(lang_gc_sections_1): Likewise.
 	(print_wild_statement): Modify for lang_wild_statement_type
 	change.
 	(lang_add_wild): Replace filename, filenames_sorted param with
 	filespec.  Replace section_name, sections_sorted,
 	exclude_filename_list with section_list.
 	* ldlang.h (lang_add_wild): Here too.
 	(lang_wild_statement_type): Replace section_name, sections_sorted,
 	and exclude_filename_list with section_list.
 	* ldgram.y (current_file): Delete.
 	(%union): Add wildcard_list.
 	(file_NAME_list): Set type to wildcard_list.  Build a linked list
 	rather than calling lang_add_wild for each entry.
 	(input_section_spec_no_keep): Call lang_add_wild here instead.
 	* ld.h (struct wildcard_list): Declare.
 	* mri.c (mri_draw_tree): Modify to suit new lang_add_wild.

-- 
Alan Modra

Index: ld/ld.h
===================================================================
RCS file: /cvs/src/src/ld/ld.h,v
retrieving revision 1.12
diff -c -p -r1.12 ld.h
*** ld.h	2001/06/18 22:20:57	1.12
--- ld.h	2001/08/03 00:52:00
*************** struct wildcard_spec {
*** 73,78 ****
--- 73,83 ----
    boolean sorted;
  };
  
+ struct wildcard_list {
+   struct wildcard_list *next;
+   struct wildcard_spec spec;
+ };
+ 
  /* Extra information we hold on sections */
  typedef struct user_section_struct {
    /* Pointer to the section where this data will go */
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.42
diff -c -p -r1.42 ld.texinfo
*** ld.texinfo	2001/07/30 18:12:07	1.42
--- ld.texinfo	2001/08/03 00:52:07
*************** There are two ways to include more than 
*** 2476,2482 ****
  @noindent
  The difference between these is the order in which the @samp{.text} and
  @samp{.rdata} input sections will appear in the output section.  In the
! first example, they will be intermingled.  In the second example, all
  @samp{.text} input sections will appear first, followed by all
  @samp{.rdata} input sections.
  
--- 2476,2483 ----
  @noindent
  The difference between these is the order in which the @samp{.text} and
  @samp{.rdata} input sections will appear in the output section.  In the
! first example, they will be intermingled, appearing in the same order as
! they are found in the linker input.  In the second example, all
  @samp{.text} input sections will appear first, followed by all
  @samp{.rdata} input sections.
  
Index: ld/ldgram.y
===================================================================
RCS file: /cvs/src/src/ld/ldgram.y,v
retrieving revision 1.10
diff -c -p -r1.10 ldgram.y
*** ldgram.y	2001/05/07 09:20:25	1.10
--- ldgram.y	2001/08/03 00:52:07
*************** static enum section_type sectype;
*** 49,55 ****
  
  lang_memory_region_type *region;
  
- struct wildcard_spec current_file;
  boolean ldgram_want_filename = true;
  boolean had_script = false;
  boolean force_make_executable = false;
--- 49,54 ----
*************** static int error_index;
*** 70,75 ****
--- 69,75 ----
    char *name;
    const char *cname;
    struct wildcard_spec wildcard;
+   struct wildcard_list *wildcard_list;
    struct name_list *name_list;
    int token;
    union etree_union *etree;
*************** static int error_index;
*** 91,96 ****
--- 91,97 ----
  %type <etree> opt_exp_without_type
  %type <integer> fill_opt
  %type <name_list> exclude_name_list
+ %type <wildcard_list> file_NAME_list
  %type <name> memspec_opt casesymlist
  %type <name> memspec_at_opt
  %type <cname> wildcard_name
*************** wildcard_spec:
*** 417,424 ****
  			}
  	;
  
- 
- 
  exclude_name_list:
  		exclude_name_list wildcard_name
  			{
--- 418,423 ----
*************** exclude_name_list:
*** 440,481 ****
  	;
  
  file_NAME_list:
  		wildcard_spec
  			{
! 			  lang_add_wild ($1.name, $1.sorted,
! 					 current_file.name,
! 					 current_file.sorted,
! 					 ldgram_had_keep, $1.exclude_name_list);
! 			}
! 	|	file_NAME_list opt_comma wildcard_spec
! 			{
! 			  lang_add_wild ($3.name, $3.sorted,
! 					 current_file.name,
! 					 current_file.sorted,
! 					 ldgram_had_keep, $3.exclude_name_list);
  			}
  	;
  
  input_section_spec_no_keep:
  		NAME
  			{
! 			  lang_add_wild (NULL, false, $1, false,
! 					 ldgram_had_keep, NULL);
  			}
!         |	'['
  			{
! 			  current_file.name = NULL;
! 			  current_file.sorted = false;
  			}
! 		file_NAME_list ']'
! 	|	wildcard_spec
  			{
! 			  current_file = $1;
! 			  /* '*' matches any file name.  */
! 			  if (strcmp (current_file.name, "*") == 0)
! 			    current_file.name = NULL;
  			}
- 		'(' file_NAME_list ')'
  	;
  
  input_section_spec:
--- 439,480 ----
  	;
  
  file_NAME_list:
+ 		file_NAME_list opt_comma wildcard_spec
+ 			{
+ 			  struct wildcard_list *tmp;
+ 			  tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
+ 			  tmp->next = $1;
+ 			  tmp->spec = $3;
+ 			  $$ = tmp;
+ 			}
+ 	|
  		wildcard_spec
  			{
! 			  struct wildcard_list *tmp;
! 			  tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
! 			  tmp->next = NULL;
! 			  tmp->spec = $1;
! 			  $$ = tmp;
  			}
  	;
  
  input_section_spec_no_keep:
  		NAME
  			{
! 			  struct wildcard_spec tmp;
! 			  tmp.name = $1;
! 			  tmp.exclude_name_list = NULL;
! 			  tmp.sorted = false;
! 			  lang_add_wild (&tmp, NULL, ldgram_had_keep);
  			}
!         |	'[' file_NAME_list ']'
  			{
! 			  lang_add_wild (NULL, $2, ldgram_had_keep);
  			}
! 	|	wildcard_spec '(' file_NAME_list ')'
  			{
! 			  lang_add_wild (&$1, $3, ldgram_had_keep);
  			}
  	;
  
  input_section_spec:
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.55
diff -c -p -r1.55 ldlang.c
*** ldlang.c	2001/07/19 16:21:39	1.55
--- ldlang.c	2001/08/03 00:52:12
*************** static void already_linked_table_init PA
*** 78,93 ****
  static void already_linked_table_free PARAMS ((void));
  static boolean wildcardp PARAMS ((const char *));
  static lang_statement_union_type *wild_sort
!   PARAMS ((lang_wild_statement_type *, lang_input_statement_type *,
! 	   asection *));
  static void output_section_callback
!   PARAMS ((lang_wild_statement_type *, asection *,
  	   lang_input_statement_type *, PTR));
  static lang_input_statement_type *lookup_name PARAMS ((const char *));
  static boolean load_symbols
    PARAMS ((lang_input_statement_type *, lang_statement_list_type *));
  static void wild
!   PARAMS ((lang_wild_statement_type *, const char *, const char *,
  	   const char *, lang_output_section_statement_type *));
  static bfd *open_output PARAMS ((const char *));
  static void ldlang_open_output PARAMS ((lang_statement_union_type *));
--- 78,93 ----
  static void already_linked_table_free PARAMS ((void));
  static boolean wildcardp PARAMS ((const char *));
  static lang_statement_union_type *wild_sort
!   PARAMS ((lang_wild_statement_type *, struct wildcard_list *,
! 	   lang_input_statement_type *, asection *));
  static void output_section_callback
!   PARAMS ((lang_wild_statement_type *, struct wildcard_list *, asection *,
  	   lang_input_statement_type *, PTR));
  static lang_input_statement_type *lookup_name PARAMS ((const char *));
  static boolean load_symbols
    PARAMS ((lang_input_statement_type *, lang_statement_list_type *));
  static void wild
!   PARAMS ((lang_wild_statement_type *,
  	   const char *, lang_output_section_statement_type *));
  static bfd *open_output PARAMS ((const char *));
  static void ldlang_open_output PARAMS ((lang_statement_union_type *));
*************** static int topower PARAMS ((int));
*** 135,145 ****
  static void lang_set_startof PARAMS ((void));
  static void reset_memory_regions PARAMS ((void));
  static void gc_section_callback
!   PARAMS ((lang_wild_statement_type *, asection *,
  	   lang_input_statement_type *, PTR));
  static void lang_record_phdrs PARAMS ((void));
! static void lang_gc_wild
!   PARAMS ((lang_wild_statement_type *, const char *, const char *));
  static void lang_gc_sections_1 PARAMS ((lang_statement_union_type *));
  static void lang_gc_sections PARAMS ((void));
  static int lang_vers_match_lang_c
--- 135,144 ----
  static void lang_set_startof PARAMS ((void));
  static void reset_memory_regions PARAMS ((void));
  static void gc_section_callback
!   PARAMS ((lang_wild_statement_type *, struct wildcard_list *, asection *,
  	   lang_input_statement_type *, PTR));
  static void lang_record_phdrs PARAMS ((void));
! static void lang_gc_wild PARAMS ((lang_wild_statement_type *));
  static void lang_gc_sections_1 PARAMS ((lang_statement_union_type *));
  static void lang_gc_sections PARAMS ((void));
  static int lang_vers_match_lang_c
*************** static void os_region_check
*** 155,171 ****
  	   struct memory_region_struct *, etree_type *, bfd_vma));
  
  typedef void (*callback_t) PARAMS ((lang_wild_statement_type *,
! 				    asection *, lang_input_statement_type *,
  				    PTR));
  static void walk_wild
!   PARAMS ((lang_wild_statement_type *, const char *, const char *,
! 	 callback_t, PTR));
  static void walk_wild_section
!   PARAMS ((lang_wild_statement_type *, const char *,
! 	   lang_input_statement_type *, callback_t, PTR));
  static void walk_wild_file
!   PARAMS ((lang_wild_statement_type *, const char *,
! 	   lang_input_statement_type *, callback_t, PTR));
  
  static int    get_target PARAMS ((const bfd_target *, PTR));
  static void   stricpy PARAMS ((char *, char *));
--- 154,171 ----
  	   struct memory_region_struct *, etree_type *, bfd_vma));
  
  typedef void (*callback_t) PARAMS ((lang_wild_statement_type *,
! 				    struct wildcard_list *,
! 				    asection *,
! 				    lang_input_statement_type *,
  				    PTR));
  static void walk_wild
!   PARAMS ((lang_wild_statement_type *, callback_t, PTR));
  static void walk_wild_section
!   PARAMS ((lang_wild_statement_type *, lang_input_statement_type *,
! 	   callback_t, PTR));
  static void walk_wild_file
!   PARAMS ((lang_wild_statement_type *, lang_input_statement_type *,
! 	   callback_t, PTR));
  
  static int    get_target PARAMS ((const bfd_target *, PTR));
  static void   stricpy PARAMS ((char *, char *));
*************** unique_section_p (secnam)
*** 236,309 ****
  /* Generic traversal routines for finding matching sections.  */
  
  static void
! walk_wild_section (ptr, section, file, callback, data)
       lang_wild_statement_type *ptr;
-      const char *section;
       lang_input_statement_type *file;
       callback_t callback;
       PTR data;
  {
!   /* Don't process sections from files which were excluded.  */
!   if (ptr->exclude_filename_list != NULL)
      {
!       struct name_list *list_tmp;
!       for (list_tmp = ptr->exclude_filename_list;
! 	   list_tmp;
! 	   list_tmp = list_tmp->next)
  	{
! 	  boolean match;
  
! 	  if (wildcardp (list_tmp->name))
! 	    match = fnmatch (list_tmp->name, file->filename, 0) == 0;
! 	  else
! 	    match = strcmp (list_tmp->name, file->filename) == 0;
  
! 	  if (match)
! 	    return;
! 	}
!     }
  
!   if (file->just_syms_flag == false)
!     {
!       register asection *s;
!       boolean wildcard = false;
  
!       if (section != NULL)
! 	wildcard = wildcardp (section);
  
!       for (s = file->the_bfd->sections; s != NULL; s = s->next)
! 	{
! 	  boolean match;
! 	  const char *sname = bfd_get_section_name (file->the_bfd, s);
  
! 	  if (section == NULL)
! 	    match = true;
! 	  else if (wildcard)
! 	    match = fnmatch (section, sname, 0) == 0;
! 	  else
! 	    match = strcmp (section, sname) == 0;
  
! 	  /* If this is a wild-card output section statement, exclude
! 	     sections that match UNIQUE_SECTION_LIST.  */
! 	  if (match && (data == NULL || !unique_section_p (sname)))
! 	    (*callback) (ptr, s, file, data);
  	}
      }
  }
  
  /* Handle a wild statement for a single file F.  */
  
  static void
! walk_wild_file (s, section, f, callback, data)
       lang_wild_statement_type *s;
-      const char *section;
       lang_input_statement_type *f;
       callback_t callback;
       PTR data;
  {
    if (f->the_bfd == NULL
        || ! bfd_check_format (f->the_bfd, bfd_archive))
!     walk_wild_section (s, section, f, callback, data);
    else
      {
        bfd *member;
--- 236,313 ----
  /* Generic traversal routines for finding matching sections.  */
  
  static void
! walk_wild_section (ptr, file, callback, data)
       lang_wild_statement_type *ptr;
       lang_input_statement_type *file;
       callback_t callback;
       PTR data;
  {
!   asection *s;
! 
!   if (file->just_syms_flag)
!     return;
! 
!   for (s = file->the_bfd->sections; s != NULL; s = s->next)
      {
!       struct wildcard_list *sec;
! 
!       sec = ptr->section_list;
!       do
  	{
! 	  boolean skip = false;
  
! 	  if (sec != NULL)
! 	    {
! 	      struct name_list *list_tmp;
  
! 	      /* Don't process sections from files which were
! 		 excluded.  */
! 	      for (list_tmp = sec->spec.exclude_name_list;
! 		   list_tmp;
! 		   list_tmp = list_tmp->next)
! 		{
! 		  if (wildcardp (list_tmp->name))
! 		    skip = fnmatch (list_tmp->name, file->filename, 0) == 0;
! 		  else
! 		    skip = strcmp (list_tmp->name, file->filename) == 0;
  
! 		  if (skip)
! 		    break;
! 		}
  
! 	      if (!skip && sec->spec.name != NULL)
! 		{
! 		  const char *sname = bfd_get_section_name (file->the_bfd, s);
  
! 		  if (wildcardp (sec->spec.name))
! 		    skip = fnmatch (sec->spec.name, sname, 0) != 0;
! 		  else
! 		    skip = strcmp (sec->spec.name, sname) != 0;
! 		}
! 	    }
  
! 	  if (!skip)
! 	    (*callback) (ptr, sec, s, file, data);
  
! 	  if (sec != NULL)
! 	    sec = sec->next;
  	}
+       while (sec != NULL);
      }
  }
  
  /* Handle a wild statement for a single file F.  */
  
  static void
! walk_wild_file (s, f, callback, data)
       lang_wild_statement_type *s;
       lang_input_statement_type *f;
       callback_t callback;
       PTR data;
  {
    if (f->the_bfd == NULL
        || ! bfd_check_format (f->the_bfd, bfd_archive))
!     walk_wild_section (s, f, callback, data);
    else
      {
        bfd *member;
*************** walk_wild_file (s, section, f, callback,
*** 320,326 ****
  	     lang_input_statement.  */
  	  if (member->usrdata != NULL)
  	    {
! 	      walk_wild_section (s, section,
  				 (lang_input_statement_type *) member->usrdata,
  				 callback, data);
  	    }
--- 324,330 ----
  	     lang_input_statement.  */
  	  if (member->usrdata != NULL)
  	    {
! 	      walk_wild_section (s,
  				 (lang_input_statement_type *) member->usrdata,
  				 callback, data);
  	    }
*************** walk_wild_file (s, section, f, callback,
*** 331,357 ****
  }
  
  static void
! walk_wild (s, section, file, callback, data)
       lang_wild_statement_type *s;
-      const char *section;
-      const char *file;
       callback_t callback;
       PTR data;
  {
!   if (file == (char *) NULL)
      {
        /* Perform the iteration over all files in the list.  */
        LANG_FOR_EACH_INPUT_STATEMENT (f)
  	{
! 	  walk_wild_file (s, section, f, callback, data);
  	}
      }
!   else if (wildcardp (file))
      {
        LANG_FOR_EACH_INPUT_STATEMENT (f)
  	{
! 	  if (fnmatch (file, f->filename, FNM_FILE_NAME) == 0)
! 	    walk_wild_file (s, section, f, callback, data);
  	}
      }
    else
--- 335,361 ----
  }
  
  static void
! walk_wild (s, callback, data)
       lang_wild_statement_type *s;
       callback_t callback;
       PTR data;
  {
!   const char *file_spec = s->filename;
! 
!   if (file_spec == NULL)
      {
        /* Perform the iteration over all files in the list.  */
        LANG_FOR_EACH_INPUT_STATEMENT (f)
  	{
! 	  walk_wild_file (s, f, callback, data);
  	}
      }
!   else if (wildcardp (file_spec))
      {
        LANG_FOR_EACH_INPUT_STATEMENT (f)
  	{
! 	  if (fnmatch (file_spec, f->filename, FNM_FILE_NAME) == 0)
! 	    walk_wild_file (s, f, callback, data);
  	}
      }
    else
*************** walk_wild (s, section, file, callback, d
*** 359,367 ****
        lang_input_statement_type *f;
  
        /* Perform the iteration over a single file.  */
!       f = lookup_name (file);
        if (f)
! 	walk_wild_file (s, section, f, callback, data);
      }
  }
  
--- 363,371 ----
        lang_input_statement_type *f;
  
        /* Perform the iteration over a single file.  */
!       f = lookup_name (file_spec);
        if (f)
! 	walk_wild_file (s, f, callback, data);
      }
  }
  
*************** wild_doit (ptr, section, output, file)
*** 1242,1256 ****
     new section should just go at the end of the current list.  */
  
  static lang_statement_union_type *
! wild_sort (wild, file, section)
       lang_wild_statement_type *wild;
       lang_input_statement_type *file;
       asection *section;
  {
    const char *section_name;
    lang_statement_union_type *l;
  
!   if (! wild->filenames_sorted && ! wild->sections_sorted)
      return NULL;
  
    section_name = bfd_get_section_name (file->the_bfd, section);
--- 1246,1261 ----
     new section should just go at the end of the current list.  */
  
  static lang_statement_union_type *
! wild_sort (wild, sec, file, section)
       lang_wild_statement_type *wild;
+      struct wildcard_list *sec;
       lang_input_statement_type *file;
       asection *section;
  {
    const char *section_name;
    lang_statement_union_type *l;
  
!   if (!wild->filenames_sorted && (sec == NULL || !sec->spec.sorted))
      return NULL;
  
    section_name = bfd_get_section_name (file->the_bfd, section);
*************** wild_sort (wild, file, section)
*** 1324,1330 ****
        /* Here either the files are not sorted by name, or we are
           looking at the sections for this file.  */
  
!       if (wild->sections_sorted)
  	{
  	  if (strcmp (section_name,
  		      bfd_get_section_name (ls->ifile->the_bfd,
--- 1329,1335 ----
        /* Here either the files are not sorted by name, or we are
           looking at the sections for this file.  */
  
!       if (sec != NULL && sec->spec.sorted)
  	{
  	  if (strcmp (section_name,
  		      bfd_get_section_name (ls->ifile->the_bfd,
*************** wild_sort (wild, file, section)
*** 1341,1360 ****
     NULL, in which case it is a wild card.  */
  
  static void
! output_section_callback (ptr, section, file, output)
       lang_wild_statement_type *ptr;
       asection *section;
       lang_input_statement_type *file;
       PTR output;
  {
    lang_statement_union_type *before;
  
    /* If the wild pattern was marked KEEP, the member sections
       should be as well.  */
    if (ptr->keep_sections)
      section->flags |= SEC_KEEP;
  
!   before = wild_sort (ptr, file, section);
  
    /* Here BEFORE points to the lang_input_section which
       should follow the one we are about to add.  If BEFORE
--- 1346,1370 ----
     NULL, in which case it is a wild card.  */
  
  static void
! output_section_callback (ptr, sec, section, file, output)
       lang_wild_statement_type *ptr;
+      struct wildcard_list *sec;
       asection *section;
       lang_input_statement_type *file;
       PTR output;
  {
    lang_statement_union_type *before;
  
+   /* Exclude sections that match UNIQUE_SECTION_LIST.  */
+   if (unique_section_p (bfd_get_section_name (file->the_bfd, section)))
+     return;
+ 
    /* If the wild pattern was marked KEEP, the member sections
       should be as well.  */
    if (ptr->keep_sections)
      section->flags |= SEC_KEEP;
  
!   before = wild_sort (ptr, sec, file, section);
  
    /* Here BEFORE points to the lang_input_section which
       should follow the one we are about to add.  If BEFORE
*************** load_symbols (entry, place)
*** 1557,1584 ****
    return entry->loaded;
  }
  
! /* Handle a wild statement.  SECTION or FILE or both may be NULL,
!    indicating that it is a wildcard.  Separate lang_input_section
!    statements are created for each part of the expansion; they are
!    added after the wild statement S.  OUTPUT is the output section.  */
  
  static void
! wild (s, section, file, target, output)
       lang_wild_statement_type *s;
-      const char *section;
-      const char *file;
       const char *target ATTRIBUTE_UNUSED;
       lang_output_section_statement_type *output;
  {
!   walk_wild (s, section, file, output_section_callback, (PTR) output);
  
!   if (section != (char *) NULL
!       && strcmp (section, "COMMON") == 0
!       && default_common_section == NULL)
!     {
!       /* Remember the section that common is going to in case we later
!          get something which doesn't know where to put it.  */
!       default_common_section = output;
      }
  }
  
--- 1567,1598 ----
    return entry->loaded;
  }
  
! /* Handle a wild statement.  S->FILENAME or S->SECTION_LIST or both
!    may be NULL, indicating that it is a wildcard.  Separate
!    lang_input_section statements are created for each part of the
!    expansion; they are added after the wild statement S.  OUTPUT is
!    the output section.  */
  
  static void
! wild (s, target, output)
       lang_wild_statement_type *s;
       const char *target ATTRIBUTE_UNUSED;
       lang_output_section_statement_type *output;
  {
!   struct wildcard_list *sec;
  
!   walk_wild (s, output_section_callback, (PTR) output);
! 
!   for (sec = s->section_list; sec != NULL; sec = sec->next)
!     {
!       if (default_common_section != NULL)
! 	break;
!       if (sec->spec.name != NULL && strcmp (sec->spec.name, "COMMON") == 0)
! 	{
! 	  /* Remember the section that common is going to in case we
! 	     later get something which doesn't know where to put it.  */ 
! 	  default_common_section = output;
! 	}
      }
  }
  
*************** map_input_to_output_sections (s, target,
*** 2052,2064 ****
      {
        switch (s->header.type)
  	{
- 
  	case lang_wild_statement_enum:
! 	  wild (&s->wild_statement, s->wild_statement.section_name,
! 		s->wild_statement.filename, target,
! 		output_section_statement);
! 
! 	  break;
  	case lang_constructors_statement_enum:
  	  map_input_to_output_sections (constructor_list.head,
  					target,
--- 2066,2073 ----
      {
        switch (s->header.type)
  	{
  	case lang_wild_statement_enum:
! 	  wild (&s->wild_statement, target, output_section_statement);
  	case lang_constructors_statement_enum:
  	  map_input_to_output_sections (constructor_list.head,
  					target,
*************** print_wild_statement (w, os)
*** 2441,2458 ****
       lang_wild_statement_type *w;
       lang_output_section_statement_type *os;
  {
    print_space ();
  
    if (w->filenames_sorted)
      minfo ("SORT(");
-   if (w->exclude_filename_list != NULL)
-     {
-       name_list *tmp;
-       minfo ("EXCLUDE_FILE ( %s", w->exclude_filename_list->name);
-       for (tmp = w->exclude_filename_list->next; tmp; tmp = tmp->next)
- 	minfo (", %s", tmp->name);
-       minfo (")");
-     }
    if (w->filename != NULL)
      minfo ("%s", w->filename);
    else
--- 2450,2461 ----
       lang_wild_statement_type *w;
       lang_output_section_statement_type *os;
  {
+   struct wildcard_list *sec;
+ 
    print_space ();
  
    if (w->filenames_sorted)
      minfo ("SORT(");
    if (w->filename != NULL)
      minfo ("%s", w->filename);
    else
*************** print_wild_statement (w, os)
*** 2461,2474 ****
      minfo (")");
  
    minfo ("(");
!   if (w->sections_sorted)
!     minfo ("SORT(");
!   if (w->section_name != NULL)
!     minfo ("%s", w->section_name);
!   else
!     minfo ("*");
!   if (w->sections_sorted)
!     minfo (")");
    minfo (")");
  
    print_nl ();
--- 2464,2488 ----
      minfo (")");
  
    minfo ("(");
!   for (sec = w->section_list; sec; sec = sec->next)
!     {
!       if (sec->spec.sorted)
! 	minfo ("SORT(");
!       if (sec->spec.exclude_name_list != NULL)
! 	{
! 	  name_list *tmp;
! 	  minfo ("EXCLUDE_FILE ( %s", sec->spec.exclude_name_list->name);
! 	  for (tmp = sec->spec.exclude_name_list->next; tmp; tmp = tmp->next)
! 	    minfo (", %s", tmp->name);
! 	  minfo (")");
! 	}
!       if (sec->spec.name != NULL)
! 	minfo ("%s", sec->spec.name);
!       else
! 	minfo ("*");
!       if (sec->spec.sorted)
! 	minfo (")");
!     }
    minfo (")");
  
    print_nl ();
*************** reset_memory_regions ()
*** 3978,4009 ****
      }
  }
  
! /* Expand a wild statement for a particular FILE, marking its sections KEEP
!    as needed.  SECTION may be NULL, in which case it is a wild card.  */
  
  static void
! gc_section_callback (ptr, section, file, data)
       lang_wild_statement_type *ptr;
       asection *section;
       lang_input_statement_type *file ATTRIBUTE_UNUSED;
       PTR data ATTRIBUTE_UNUSED;
  {
-   /* If the wild pattern was marked KEEP, the member sections
-      should be as well.  */
    if (ptr->keep_sections)
      section->flags |= SEC_KEEP;
  }
  
! /* Handle a wild statement, marking it against GC.  SECTION or FILE or both
!    may be NULL, indicating that it is a wildcard.  */
  
  static void
! lang_gc_wild (s, section, file)
       lang_wild_statement_type *s;
-      const char *section;
-      const char *file;
  {
!   walk_wild (s, section, file, gc_section_callback, NULL);
  }
  
  /* Iterate over sections marking them against GC.  */
--- 3992,4019 ----
      }
  }
  
! /* If the wild pattern was marked KEEP, the member sections
!    should be as well.  */
  
  static void
! gc_section_callback (ptr, sec, section, file, data)
       lang_wild_statement_type *ptr;
+      struct wildcard_list *sec ATTRIBUTE_UNUSED;
       asection *section;
       lang_input_statement_type *file ATTRIBUTE_UNUSED;
       PTR data ATTRIBUTE_UNUSED;
  {
    if (ptr->keep_sections)
      section->flags |= SEC_KEEP;
  }
  
! /* Handle a wild statement, marking it against GC.  */
  
  static void
! lang_gc_wild (s)
       lang_wild_statement_type *s;
  {
!   walk_wild (s, gc_section_callback, NULL);
  }
  
  /* Iterate over sections marking them against GC.  */
*************** lang_gc_sections_1 (s)
*** 4017,4026 ****
        switch (s->header.type)
  	{
  	case lang_wild_statement_enum:
! 	  lang_gc_wild (&s->wild_statement,
! 			s->wild_statement.section_name,
! 			s->wild_statement.filename);
! 	  break;
  	case lang_constructors_statement_enum:
  	  lang_gc_sections_1 (constructor_list.head);
  	  break;
--- 4027,4033 ----
        switch (s->header.type)
  	{
  	case lang_wild_statement_enum:
! 	  lang_gc_wild (&s->wild_statement);
  	case lang_constructors_statement_enum:
  	  lang_gc_sections_1 (constructor_list.head);
  	  break;
*************** lang_process ()
*** 4211,4242 ****
  /* EXPORTED TO YACC */
  
  void
! lang_add_wild (section_name, sections_sorted, filename, filenames_sorted,
! 	       keep_sections, exclude_filename_list)
!      const char *const section_name;
!      boolean sections_sorted;
!      const char *const filename;
!      boolean filenames_sorted;
       boolean keep_sections;
-      struct name_list *exclude_filename_list;
  {
!   lang_wild_statement_type *new = new_stat (lang_wild_statement,
! 					    stat_ptr);
  
!   if (section_name != (char *) NULL && strcmp (section_name, "COMMON") == 0)
      {
!       placed_commons = true;
      }
!   if (filename != NULL && ! wildcardp (filename))
      {
!       lang_has_input_file = true;
      }
!   new->section_name = section_name;
!   new->sections_sorted = sections_sorted;
!   new->filename = filename;
!   new->filenames_sorted = filenames_sorted;
    new->keep_sections = keep_sections;
-   new->exclude_filename_list = exclude_filename_list;
    lang_list_init (&new->children);
  }
  
--- 4218,4261 ----
  /* EXPORTED TO YACC */
  
  void
! lang_add_wild (filespec, section_list, keep_sections)
!      struct wildcard_spec *filespec;
!      struct wildcard_list *section_list;
       boolean keep_sections;
  {
!   struct wildcard_list *curr, *next;
!   lang_wild_statement_type *new;
! 
!   /* Reverse the list as the parser puts it back to front.  */
!   for (curr = section_list, section_list = NULL;
!        curr != NULL;
!        section_list = curr, curr = next)
!     {
!       if (curr->spec.name != NULL && strcmp (curr->spec.name, "COMMON") == 0)
! 	placed_commons = true;
  
!       next = curr->next;
!       curr->next = section_list;
!     }
! 
!   if (filespec != NULL && filespec->name != NULL)
      {
!       if (strcmp (filespec->name, "*") == 0)
! 	filespec->name = NULL;
!       else if (! wildcardp (filespec->name))
! 	lang_has_input_file = true;
      }
! 
!   new = new_stat (lang_wild_statement, stat_ptr);
!   new->filename = NULL;
!   new->filenames_sorted = false;
!   if (filespec != NULL)
      {
!       new->filename = filespec->name;
!       new->filenames_sorted = filespec->sorted;
      }
!   new->section_list = section_list;
    new->keep_sections = keep_sections;
    lang_list_init (&new->children);
  }
  
Index: ld/ldlang.h
===================================================================
RCS file: /cvs/src/src/ld/ldlang.h,v
retrieving revision 1.10
diff -c -p -r1.10 ldlang.h
*** ldlang.h	2001/03/13 06:14:27	1.10
--- ldlang.h	2001/08/03 00:52:12
*************** typedef struct {
*** 257,268 ****
  
  typedef struct lang_wild_statement_struct {
    lang_statement_header_type header;
-   const char *section_name;
-   boolean sections_sorted;
    const char *filename;
    boolean filenames_sorted;
    boolean keep_sections;
-   struct name_list *exclude_filename_list;
    lang_statement_list_type children;
  } lang_wild_statement_type;
  
--- 257,266 ----
  
  typedef struct lang_wild_statement_struct {
    lang_statement_header_type header;
    const char *filename;
    boolean filenames_sorted;
+   struct wildcard_list *section_list;
    boolean keep_sections;
    lang_statement_list_type children;
  } lang_wild_statement_type;
  
*************** extern void lang_section_start PARAMS ((
*** 385,391 ****
  extern void lang_add_entry PARAMS ((const char *, boolean));
  extern void lang_add_target PARAMS ((const char *));
  extern void lang_add_wild
!   PARAMS ((const char *, boolean, const char *, boolean, boolean, name_list *));
  extern void lang_add_map PARAMS ((const char *));
  extern void lang_add_fill PARAMS ((int));
  extern lang_assignment_statement_type * lang_add_assignment PARAMS ((union etree_union *));
--- 383,389 ----
  extern void lang_add_entry PARAMS ((const char *, boolean));
  extern void lang_add_target PARAMS ((const char *));
  extern void lang_add_wild
!   PARAMS ((struct wildcard_spec *, struct wildcard_list *, boolean));
  extern void lang_add_map PARAMS ((const char *));
  extern void lang_add_fill PARAMS ((int));
  extern lang_assignment_statement_type * lang_add_assignment PARAMS ((union etree_union *));
Index: ld/mri.c
===================================================================
RCS file: /cvs/src/src/ld/mri.c,v
retrieving revision 1.6
diff -c -p -r1.6 mri.c
*** mri.c	2001/03/13 06:14:27	1.6
--- mri.c	2001/08/03 00:52:12
*************** mri_draw_tree ()
*** 220,225 ****
--- 220,226 ----
  	  struct section_name_struct *aptr;
  	  etree_type *align = 0;
  	  etree_type *subalign = 0;
+ 	  struct wildcard_list *tmp;
  
  	  /* See if an alignment has been specified.  */
  	  for (aptr = alignment; aptr; aptr = aptr->next)
*************** mri_draw_tree ()
*** 238,249 ****
  					       1, align, subalign,
  					       (etree_type *) NULL);
  	  base = 0;
! 	  lang_add_wild (p->name, false, (char *) NULL, false, false, NULL);
  
  	  /* If there is an alias for this section, add it too.  */
  	  for (aptr = alias; aptr; aptr = aptr->next)
  	    if (strcmp (aptr->alias, p->name) == 0)
! 	      lang_add_wild (aptr->name, false, (char *) NULL, false, false, NULL);
  
  	  lang_leave_output_section_statement
  	    (0, "*default*", (struct lang_output_section_phdr_list *) NULL,
--- 239,262 ----
  					       1, align, subalign,
  					       (etree_type *) NULL);
  	  base = 0;
! 	  tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
! 	  tmp->next = NULL;
! 	  tmp->spec.name = p->name;
! 	  tmp->spec.exclude_name_list = NULL;
! 	  tmp->spec.sorted = false;
! 	  lang_add_wild (NULL, tmp, false);
  
  	  /* If there is an alias for this section, add it too.  */
  	  for (aptr = alias; aptr; aptr = aptr->next)
  	    if (strcmp (aptr->alias, p->name) == 0)
! 	      {
! 		tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
! 		tmp->next = NULL;
! 		tmp->spec.name = aptr->name;
! 		tmp->spec.exclude_name_list = NULL;
! 		tmp->spec.sorted = false;
! 		lang_add_wild (NULL, tmp, false);
! 	      }
  
  	  lang_leave_output_section_statement
  	    (0, "*default*", (struct lang_output_section_phdr_list *) NULL,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]