PATCH: Add --sort-section to ld

H. J. Lu hjl@lucon.org
Wed Sep 1 22:11:00 GMT 2004


On Mon, Aug 30, 2004 at 11:33:10AM -0700, H. J. Lu wrote:
> On Thu, Aug 26, 2004 at 02:11:55PM -0400, DJ Delorie wrote:
> > 
> > > 3.1. SORT_BY_NAME (SORT_BY_ALIGNMENT (wildcard section pattern)). It
> > > will sort the input sections by alignment first, then by name if 2
> > > sections have the same alignment.
> > 
> > I think the semantics here need to be reversed.  If this were a real
> > programming language, the SORT_BY_NAME would happen last, and override
> > any previous (inner) sorting.
> > 
> > Thus, these would be equivalent:
> > 
> > SORT_BY_NAME (SORT_BY_ALIGNMENT (*.text))
> > 
> > SORT_BY_NAME (*.text) with -sort-sections=alignment
> 
> Here is the updated proposal. Any other comments?
> 
> 
> H.J.
> ----
> New input section sorting options in linker
> 
> 1. New linker script section sorting commands.
> 
> 1.1. Rename SORT to SORT_BY_NAME and make SORT an alias of
> SORT_BY_NAME.
> 1.2. Add SORT_BY_ALIGNMENT, which appears before a wildcard pattern in
> parentheses (.e.g. `SORT_BY_ALIGNMENT (.text*).). It will sort sections
> into ascending order by alignment before placing them into the output
> file.
> 
> 2. New linker command line option. 
> 
> 2.1. .sort-section name. It will apply SORT_BY_NAME to all wildcard
> section patterns in the linker script. 
> 2.2. .sort-section alignment. It will apply SORT_BY_ALIGMENT to all
> wildcard section patterns in the linker script.
> 
> 3. Nesting of section sorting commands in linker script. There can be
> at most 1 level of nesting for section sorting commands. 
> 
> 3.1. SORT_BY_NAME (SORT_BY_ALIGNMENT (wildcard section pattern)). It
> will sort the input sections by name first, then by alignment if 2
> sections have the same name.
> 3.2. SORT_BY_ALIGNMENT (SORT_BY_NAME (wildcard section pattern)). It
> will sort the input sections by alignment first, then by name if 2
> sections have the same alignment.
> 3.3.  SORT_BY_NAME (SORT_BY_NAME (wildcard section pattern)) is treated
> the same as SORT_BY_NAME (wildcard section pattern).
> 3.4. SORT_BY_ALIGNMENT (SORT_BY_ALIGMENT (wildcard section pattern)) is
> treated the same as SORT_BY_ALIGMENT (wildcard section pattern).
> 3.5. All other nested section sorting commands are invalid.
> 
> 4. .sort-section command line option vs. section sorting command in
> linker script.
> 
> 4.1. Section sorting commands always take precedent over the command
> line option.
> 4.2. If the section sorting command in linker script isn.t nested, the
> command line option will make the section sorting command to be treated
> as nested sorting command.
> 4.2.1. SORT_BY_NAME (wildcard section pattern ) with --sort-sections
> alignment is equivalent to SORT_BY_NAME (SORT_BY_ALIGNMENT (wildcard
> section pattern)).
> 4.2.2. SORT_BY_ALIGNMENT (wildcard section pattern) with .sort-section
> name is equivalent to SORT_BY_ALIGNMENT (SORT_BY_NAME (wildcard section
> pattern)).
> 4.3. If the section sorting command in linker script is nested, the
> command line option will be ignored.
> 

This patch implements --sort-section. I will update the ld doc if this
patch is OK.


H.J.
-------------- next part --------------
ld/

2004-09-01  H.J. Lu  <hongjiu.lu@intel.com>

	* ld.h (sort_type): New enum.
	(wildcard_spec): Change the type of `sorted' to sort_type.

	* ldgram.y (SORT): Removed.
	(SORT_BY_NAME): Added.
	(SORT_BY_ALIGNMENT): Added.
	(wildcard_spec): Updated `sorted'. Handle SORT_BY_NAME and
	SORT_BY_ALIGNMENT.
	(input_section_spec_no_keep): Updated `sorted'.
	(statement): Replace SORT with SORT_BY_NAME.

	* ldlang.c (compare_section): New function to compare 2
	sections with different sorting schemes.
	(wild_sort): Updated. Use compare_section.
	(update_wild_statements): New function.
	(lang_process): Call update_wild_statements before
	map_input_to_output_sections.

	* ldlex.l (SORT_BY_NAME): New.
	(SORT_BY_ALIGNMENT): New.
	(SORT): Return SORT_BY_NAME.

	* ldmain.c (sort_section): New. Defined.
	(main): Initialize it to none.

	* lexsup.c (option_values): Add OPTION_SORT_SECTION.
	(ld_options): Add an entry for OPTION_SORT_SECTION.
	(parse_args): Handle OPTION_SORT_SECTION.

	* mri.c (mri_draw_tree): Updated `sorted'.

ld/testsuite/

2004-09-01  H.J. Lu  <hongjiu.lu@intel.com>

	* ld-scripts/sort.exp: New file for section sorting tests.
	* ld-scripts/sort_b_a.d: Likewise
	* ld-scripts/sort_b_a.s: Likewise
	* ld-scripts/sort_b_a.t: Likewise
	* ld-scripts/sort_b_a_a-1.d: Likewise
	* ld-scripts/sort_b_a_a-2.d: Likewise
	* ld-scripts/sort_b_a_a-3.d: Likewise
	* ld-scripts/sort_b_a_a.t: Likewise
	* ld-scripts/sort_b_a_n-1.d: Likewise
	* ld-scripts/sort_b_a_n-2.d: Likewise
	* ld-scripts/sort_b_a_n-3.d: Likewise
	* ld-scripts/sort_b_a_n.t: Likewise
	* ld-scripts/sort_b_n.d: Likewise
	* ld-scripts/sort_b_n.s: Likewise
	* ld-scripts/sort_b_n.t: Likewise
	* ld-scripts/sort_b_n_a-1.d: Likewise
	* ld-scripts/sort_b_n_a-2.d: Likewise
	* ld-scripts/sort_b_n_a-3.d: Likewise
	* ld-scripts/sort_b_n_a.t: Likewise
	* ld-scripts/sort_b_n_n-1.d: Likewise
	* ld-scripts/sort_b_n_n-2.d: Likewise
	* ld-scripts/sort_b_n_n-3.d: Likewise
	* ld-scripts/sort_b_n_n.t: Likewise
	* ld-scripts/sort_n_a-a.s: Likewise
	* ld-scripts/sort_n_a-b.s: Likewise
	* ld-scripts/sort_no-1.d: Likewise
	* ld-scripts/sort_no-2.d: Likewise
	* ld-scripts/sort_no.t: Likewise

--- ld/ld.h.sort	2004-05-25 22:35:28.000000000 -0700
+++ ld/ld.h	2004-09-01 14:00:44.521750946 -0700
@@ -64,13 +64,18 @@ typedef struct name_list {
 }
 name_list;
 
-/* A wildcard specification.  This is only used in ldgram.y, but it
-   winds up in ldgram.h, so we need to define it outside.  */
+/* A wildcard specification.  */
+
+typedef enum {
+  none, by_name, by_alignment, by_name_alignment, by_alignment_name
+} sort_type;
+
+extern sort_type sort_section;
 
 struct wildcard_spec {
   const char *name;
   struct name_list *exclude_name_list;
-  bfd_boolean sorted;
+  sort_type sorted;
 };
 
 struct wildcard_list {
--- ld/ldgram.y.sort	2004-05-19 08:24:30.000000000 -0700
+++ ld/ldgram.y	2004-09-01 10:15:57.507916043 -0700
@@ -128,7 +128,8 @@ static int error_index;
 %token END
 %left <token> '('
 %token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
-%token SECTIONS PHDRS SORT DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
+%token SECTIONS PHDRS DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
+%token SORT_BY_NAME SORT_BY_ALIGNMENT
 %token '{' '}'
 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
 %token INHIBIT_COMMON_ALLOCATION
@@ -412,25 +413,55 @@ wildcard_spec:
 		wildcard_name
 			{
 			  $$.name = $1;
-			  $$.sorted = FALSE;
+			  $$.sorted = none;
 			  $$.exclude_name_list = NULL;
 			}
 	| 	EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
 			{
 			  $$.name = $5;
-			  $$.sorted = FALSE;
+			  $$.sorted = none;
 			  $$.exclude_name_list = $3;
 			}
-	|	SORT '(' wildcard_name ')'
+	|	SORT_BY_NAME '(' wildcard_name ')'
 			{
 			  $$.name = $3;
-			  $$.sorted = TRUE;
+			  $$.sorted = by_name;
 			  $$.exclude_name_list = NULL;
 			}
-	|	SORT '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
+	|	SORT_BY_ALIGNMENT '(' wildcard_name ')'
+			{
+			  $$.name = $3;
+			  $$.sorted = by_alignment;
+			  $$.exclude_name_list = NULL;
+			}
+	|	SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
+			{
+			  $$.name = $5;
+			  $$.sorted = by_name_alignment;
+			  $$.exclude_name_list = NULL;
+			}
+	|	SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_name ')' ')'
+			{
+			  $$.name = $5;
+			  $$.sorted = by_name;
+			  $$.exclude_name_list = NULL;
+			}
+	|	SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_name ')' ')'
+			{
+			  $$.name = $5;
+			  $$.sorted = by_alignment_name;
+			  $$.exclude_name_list = NULL;
+			}
+	|	SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
+			{
+			  $$.name = $5;
+			  $$.sorted = by_alignment;
+			  $$.exclude_name_list = NULL;
+			}
+	|	SORT_BY_NAME '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
 			{
 			  $$.name = $7;
-			  $$.sorted = TRUE;
+			  $$.sorted = by_name;
 			  $$.exclude_name_list = $5;
 			}
 	;
@@ -481,7 +512,7 @@ input_section_spec_no_keep:
 			  struct wildcard_spec tmp;
 			  tmp.name = $1;
 			  tmp.exclude_name_list = NULL;
-			  tmp.sorted = FALSE;
+			  tmp.sorted = none;
 			  lang_add_wild (&tmp, NULL, ldgram_had_keep);
 			}
         |	'[' file_NAME_list ']'
@@ -514,7 +545,7 @@ statement:
 
 		  lang_add_attribute(lang_constructors_statement_enum);
 		}
-	| SORT '(' CONSTRUCTORS ')'
+	| SORT_BY_NAME '(' CONSTRUCTORS ')'
 		{
 		  constructors_sorted = TRUE;
 		  lang_add_attribute (lang_constructors_statement_enum);
--- ld/ldlang.c.sort	2004-08-26 09:19:09.000000000 -0700
+++ ld/ldlang.c	2004-09-01 14:39:12.068427239 -0700
@@ -1054,6 +1054,46 @@ lang_add_section (lang_statement_list_ty
     }
 }
 
+/* Compare sections ASEC and BSEC according to SORT.  */
+
+static int
+compare_section (sort_type sort, asection *asec, asection *bsec)
+{
+  int ret;
+
+  switch (sort)
+    {
+    default:
+      abort ();
+
+    case by_alignment_name:
+      ret = (bfd_section_alignment (bsec->owner, bsec)
+	     - bfd_section_alignment (asec->owner, asec));
+      if (ret)
+	break;
+      /* Fall through.  */
+
+    case by_name:
+      ret = strcmp (bfd_get_section_name (asec->owner, asec),
+		    bfd_get_section_name (bsec->owner, bsec));
+      break;
+
+    case by_name_alignment:
+      ret = strcmp (bfd_get_section_name (asec->owner, asec),
+		    bfd_get_section_name (bsec->owner, bsec));
+      if (ret)
+	break;
+      /* Fall through.  */
+
+    case by_alignment:
+      ret = (bfd_section_alignment (bsec->owner, bsec)
+	     - bfd_section_alignment (asec->owner, asec));
+      break;
+    }
+
+  return ret;
+}
+
 /* Handle wildcard sorting.  This returns the lang_input_section which
    should follow the one we are going to create for SECTION and FILE,
    based on the sorting requirements of WILD.  It returns NULL if the
@@ -1068,7 +1108,8 @@ wild_sort (lang_wild_statement_type *wil
   const char *section_name;
   lang_statement_union_type *l;
 
-  if (!wild->filenames_sorted && (sec == NULL || !sec->spec.sorted))
+  if (!wild->filenames_sorted
+      && (sec == NULL || sec->spec.sorted == none))
     return NULL;
 
   section_name = bfd_get_section_name (file->the_bfd, section);
@@ -1142,12 +1183,10 @@ wild_sort (lang_wild_statement_type *wil
       /* 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 (sec != NULL && sec->spec.sorted != none)
 	{
-	  if (strcmp (section_name,
-		      bfd_get_section_name (ls->ifile->the_bfd,
-					    ls->section))
-	      < 0)
+	  if (compare_section (sec->spec.sorted, section,
+			       ls->section) < 0)
 	    break;
 	}
     }
@@ -2016,6 +2055,71 @@ check_input_sections
     }
 }
 
+/* Update wildcard statements if needed.  */
+
+static void
+update_wild_statements (lang_statement_union_type *s)
+{
+  struct wildcard_list *sec;
+
+  switch (sort_section)
+    {
+    default:
+      FAIL ();
+
+    case none:
+      break;
+
+    case by_name:
+    case by_alignment:
+      for (; s != NULL; s = s->header.next)
+	{
+	  switch (s->header.type)
+	    {
+	    default:
+	      break;
+
+	    case lang_wild_statement_enum:
+	      sec = s->wild_statement.section_list;
+	      if (sec != NULL)
+		{
+		  switch (sec->spec.sorted)
+		    {
+		    case none:
+		      sec->spec.sorted = sort_section;
+		      break;
+		    case by_name:
+		      if (sort_section == by_alignment)
+			sec->spec.sorted = by_name_alignment;
+		      break;
+		    case by_alignment:
+		      if (sort_section == by_name)
+			sec->spec.sorted = by_alignment_name;
+		      break;
+		    default:
+		      break;
+		    }
+		}
+	      break;
+
+	    case lang_constructors_statement_enum:
+	      update_wild_statements (constructor_list.head);
+	      break;
+
+	    case lang_output_section_statement_enum:
+	      update_wild_statements
+		(s->output_section_statement.children.head);
+	      break;
+
+	    case lang_group_statement_enum:
+	      update_wild_statements (s->group_statement.children.head);
+	      break;
+	    }
+	}
+      break;
+    }
+}
+
 /* Open input files and attach to output sections.  */
 
 static void
@@ -4216,6 +4320,9 @@ lang_process (void)
   /* Size up the common data.  */
   lang_common ();
 
+  /* Update wild statements.  */
+  update_wild_statements (statement_list.head);
+
   /* Run through the contours of the script and attach input sections
      to the correct output sections.  */
   map_input_to_output_sections (statement_list.head, NULL, NULL);
@@ -4365,7 +4472,7 @@ lang_add_wild (struct wildcard_spec *fil
   if (filespec != NULL)
     {
       new->filename = filespec->name;
-      new->filenames_sorted = filespec->sorted;
+      new->filenames_sorted = filespec->sorted == by_name;
     }
   new->section_list = section_list;
   new->keep_sections = keep_sections;
--- ld/ldlex.l.sort	2004-05-19 08:24:37.000000000 -0700
+++ ld/ldlex.l	2004-09-01 09:46:44.498367447 -0700
@@ -289,7 +289,9 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([
 <BOTH,SCRIPT>"NOFLOAT"		{ RTOKEN(NOFLOAT);}
 <EXPRESSION,BOTH,SCRIPT>"NOCROSSREFS"	{ RTOKEN(NOCROSSREFS);}
 <BOTH,SCRIPT>"OVERLAY"			{ RTOKEN(OVERLAY); }
-<BOTH,SCRIPT>"SORT"			{ RTOKEN(SORT); }
+<BOTH,SCRIPT>"SORT_BY_NAME"		{ RTOKEN(SORT_BY_NAME); }
+<BOTH,SCRIPT>"SORT_BY_ALIGNMENT"	{ RTOKEN(SORT_BY_ALIGNMENT); }
+<BOTH,SCRIPT>"SORT"			{ RTOKEN(SORT_BY_NAME); }
 <EXPRESSION,BOTH,SCRIPT>"NOLOAD"	{ RTOKEN(NOLOAD);}
 <EXPRESSION,BOTH,SCRIPT>"DSECT"		{ RTOKEN(DSECT);}
 <EXPRESSION,BOTH,SCRIPT>"COPY"		{ RTOKEN(COPY);}
--- ld/ldmain.c.sort	2004-08-13 08:00:14.000000000 -0700
+++ ld/ldmain.c	2004-09-01 14:03:38.458262455 -0700
@@ -108,6 +108,8 @@ args_type command_line;
 
 ld_config_type config;
 
+sort_type sort_section;
+
 static char *get_emulation
   (int, char **);
 static void set_scripts_dir
@@ -280,6 +282,8 @@ main (int argc, char **argv)
   command_line.accept_unknown_input_arch = FALSE;
   command_line.reduce_memory_overheads = FALSE;
 
+  sort_section = none;
+
   /* We initialize DEMANGLING based on the environment variable
      COLLECT_NO_DEMANGLE.  The gcc collect2 program will demangle the
      output of the linker, unless COLLECT_NO_DEMANGLE is set in the
--- ld/lexsup.c.sort	2004-09-01 13:54:30.839064893 -0700
+++ ld/lexsup.c	2004-09-01 14:08:48.938120089 -0700
@@ -92,6 +92,7 @@ enum option_values
   OPTION_SHARED,
   OPTION_SONAME,
   OPTION_SORT_COMMON,
+  OPTION_SORT_SECTION,
   OPTION_STATS,
   OPTION_SYMBOLIC,
   OPTION_TASK_LINK,
@@ -423,6 +424,9 @@ static const struct ld_option ld_options
     '\0', NULL, N_("Sort common symbols by size"), TWO_DASHES },
   { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
     '\0', NULL, NULL, NO_HELP },
+  { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION},
+    '\0', N_("name|alignment"), 
+    N_("Sort sections by name or maximum alignment"), TWO_DASHES },
   { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS},
     '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
     TWO_DASHES },
@@ -1066,6 +1070,15 @@ parse_args (unsigned argc, char **argv)
 	case OPTION_SORT_COMMON:
 	  config.sort_common = TRUE;
 	  break;
+	case OPTION_SORT_SECTION:
+	  if (strcmp (optarg, N_("name")) == 0)
+	    sort_section = by_name;
+	  else if (strcmp (optarg, N_("alignment")) == 0)
+	    sort_section = by_alignment;
+	  else
+	    einfo (_("%P%F: invalid section sorting option: %s\n"),
+		   optarg);
+	  break;
 	case OPTION_STATS:
 	  config.stats = TRUE;
 	  break;
--- ld/mri.c.sort	2004-05-19 08:24:40.000000000 -0700
+++ ld/mri.c	2004-09-01 10:16:53.569659913 -0700
@@ -226,7 +226,7 @@ mri_draw_tree (void)
 	  tmp->next = NULL;
 	  tmp->spec.name = p->name;
 	  tmp->spec.exclude_name_list = NULL;
-	  tmp->spec.sorted = FALSE;
+	  tmp->spec.sorted = none;
 	  lang_add_wild (NULL, tmp, FALSE);
 
 	  /* If there is an alias for this section, add it too.  */
@@ -237,7 +237,7 @@ mri_draw_tree (void)
 		tmp->next = NULL;
 		tmp->spec.name = aptr->name;
 		tmp->spec.exclude_name_list = NULL;
-		tmp->spec.sorted = FALSE;
+		tmp->spec.sorted = none;
 		lang_add_wild (NULL, tmp, FALSE);
 	      }
 
--- ld/testsuite/ld-scripts/sort.exp.sort	2004-09-01 14:56:05.854415103 -0700
+++ ld/testsuite/ld-scripts/sort.exp	2004-09-01 11:13:23.535105907 -0700
@@ -0,0 +1,26 @@
+# Test SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT in a linker script.
+# By H.J. Lu  <hongjiu.lu@intel.com>
+#   Copyright 2004
+#   Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+load_lib ld-lib.exp
+
+set sort_test_list [lsort [glob -nocomplain $srcdir/$subdir/sort*.d]]
+for { set i 0 } { $i < [llength $sort_test_list] } { incr i } {
+    verbose [file rootname [lindex $sort_test_list $i]]
+    run_dump_test [file rootname [lindex $sort_test_list $i]]
+}
--- ld/testsuite/ld-scripts/sort_b_a.d.sort	2004-09-01 14:56:05.855414973 -0700
+++ ld/testsuite/ld-scripts/sort_b_a.d	2004-09-01 11:41:03.329396550 -0700
@@ -0,0 +1,9 @@
+#source: sort_b_a.s
+#ld: -T sort_b_a.t
+#name: SORT_BY_ALIGNMENT
+#nm: -n
+
+0[0-9a-f]* t text3
+0[0-9a-f]* t text1
+0[0-9a-f]* t text
+0[0-9a-f]* t text2
--- ld/testsuite/ld-scripts/sort_b_a.s.sort	2004-09-01 14:56:05.856414844 -0700
+++ ld/testsuite/ld-scripts/sort_b_a.s	2004-09-01 11:37:00.029869537 -0700
@@ -0,0 +1,16 @@
+	.section .text2
+	.p2align 3
+text2:
+	.long 0
+	.section .text3
+	.p2align 6
+text3:
+	.long 0
+	.section .text1
+	.p2align 5
+text1:
+	.long 0
+	.text
+text:
+	.p2align 4
+	.long 0
--- ld/testsuite/ld-scripts/sort_b_a.t.sort	2004-09-01 14:56:05.857414715 -0700
+++ ld/testsuite/ld-scripts/sort_b_a.t	2004-09-01 11:39:06.377525329 -0700
@@ -0,0 +1,5 @@
+SECTIONS
+{
+  .text : {*(SORT_BY_ALIGNMENT(.text*))}
+  /DISCARD/ : { *(.*) }
+}
--- ld/testsuite/ld-scripts/sort_b_a_a-1.d.sort	2004-09-01 14:56:05.858414586 -0700
+++ ld/testsuite/ld-scripts/sort_b_a_a-1.d	2004-09-01 12:52:57.757548470 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_a_a.t
+#name: SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT())
+#nm: -n
+
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text3a
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
--- ld/testsuite/ld-scripts/sort_b_a_a-2.d.sort	2004-09-01 14:56:05.859414456 -0700
+++ ld/testsuite/ld-scripts/sort_b_a_a-2.d	2004-09-01 14:50:27.060197671 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_a_a.t --sort-section alignment
+#name: SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT()) --sort-section alignment
+#nm: -n
+
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text3a
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
--- ld/testsuite/ld-scripts/sort_b_a_a-3.d.sort	2004-09-01 14:56:05.860414327 -0700
+++ ld/testsuite/ld-scripts/sort_b_a_a-3.d	2004-09-01 14:51:17.109729742 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_a_a.t --sort-section name
+#name: SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT()) --sort-section name
+#nm: -n
+
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text3a
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
--- ld/testsuite/ld-scripts/sort_b_a_a.t.sort	2004-09-01 14:56:05.862414069 -0700
+++ ld/testsuite/ld-scripts/sort_b_a_a.t	2004-09-01 12:50:08.854386192 -0700
@@ -0,0 +1,5 @@
+SECTIONS
+{
+  .text : {*(SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT(.text*)))}
+  /DISCARD/ : { *(.*) }
+}
--- ld/testsuite/ld-scripts/sort_b_a_n-1.d.sort	2004-09-01 14:56:05.863413940 -0700
+++ ld/testsuite/ld-scripts/sort_b_a_n-1.d	2004-09-01 12:49:03.129883803 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_a_n.t
+#name: SORT_BY_ALIGNMENT(SORT_BY_NAME())
+#nm: -n
+
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text3a
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
--- ld/testsuite/ld-scripts/sort_b_a_n-2.d.sort	2004-09-01 14:56:05.864413810 -0700
+++ ld/testsuite/ld-scripts/sort_b_a_n-2.d	2004-09-01 14:52:13.995378377 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_a_n.t --sort-section name
+#name: SORT_BY_ALIGNMENT(SORT_BY_NAME()) --sort-section name
+#nm: -n
+
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text3a
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
--- ld/testsuite/ld-scripts/sort_b_a_n-3.d.sort	2004-09-01 14:56:05.865413681 -0700
+++ ld/testsuite/ld-scripts/sort_b_a_n-3.d	2004-09-01 14:52:42.902642675 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_a_n.t --sort-section alignment
+#name: SORT_BY_ALIGNMENT(SORT_BY_NAME()) --sort-section alignment
+#nm: -n
+
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text3a
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
--- ld/testsuite/ld-scripts/sort_b_a_n.t.sort	2004-09-01 14:56:05.866413552 -0700
+++ ld/testsuite/ld-scripts/sort_b_a_n.t	2004-09-01 12:38:19.294126212 -0700
@@ -0,0 +1,5 @@
+SECTIONS
+{
+  .text : {*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.text*)))}
+  /DISCARD/ : { *(.*) }
+}
--- ld/testsuite/ld-scripts/sort_b_n.d.sort	2004-09-01 14:56:05.867413423 -0700
+++ ld/testsuite/ld-scripts/sort_b_n.d	2004-09-01 11:24:36.571042640 -0700
@@ -0,0 +1,9 @@
+#source: sort_b_n.s
+#ld: -T sort_b_n.t
+#name: SORT_BY_NAME
+#nm: -n
+
+0[0-9a-f]* t text
+0[0-9a-f]* t text1
+0[0-9a-f]* t text2
+0[0-9a-f]* t text3
--- ld/testsuite/ld-scripts/sort_b_n.s.sort	2004-09-01 14:56:05.868413294 -0700
+++ ld/testsuite/ld-scripts/sort_b_n.s	2004-09-01 11:17:13.214394820 -0700
@@ -0,0 +1,12 @@
+	.section .text2
+text2:
+	.long 0
+	.section .text3
+text3:
+	.long 0
+	.section .text1
+text1:
+	.long 0
+	.text
+text:
+	.long 0
--- ld/testsuite/ld-scripts/sort_b_n.t.sort	2004-09-01 14:56:05.869413164 -0700
+++ ld/testsuite/ld-scripts/sort_b_n.t	2004-09-01 11:02:51.994634053 -0700
@@ -0,0 +1,5 @@
+SECTIONS
+{
+  .text : {*(SORT_BY_NAME(.text*))}
+  /DISCARD/ : { *(.*) }
+}
--- ld/testsuite/ld-scripts/sort_b_n_a-1.d.sort	2004-09-01 14:56:05.870413035 -0700
+++ ld/testsuite/ld-scripts/sort_b_n_a-1.d	2004-09-01 12:49:40.444059402 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_n_a.t
+#name: SORT_BY_NAME(SORT_BY_ALIGNMENT())
+#nm: -n
+
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text3a
--- ld/testsuite/ld-scripts/sort_b_n_a-2.d.sort	2004-09-01 14:56:05.871412906 -0700
+++ ld/testsuite/ld-scripts/sort_b_n_a-2.d	2004-09-01 14:53:28.514748197 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_n_a.t --sort-section name
+#name: SORT_BY_NAME(SORT_BY_ALIGNMENT()) --sort-section alignment
+#nm: -n
+
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text3a
--- ld/testsuite/ld-scripts/sort_b_n_a-3.d.sort	2004-09-01 14:56:05.872412777 -0700
+++ ld/testsuite/ld-scripts/sort_b_n_a-3.d	2004-09-01 14:54:00.894563735 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_n_a.t --sort-section alignment
+#name: SORT_BY_NAME(SORT_BY_ALIGNMENT()) --sort-section alignment
+#nm: -n
+
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text3a
--- ld/testsuite/ld-scripts/sort_b_n_a.t.sort	2004-09-01 14:56:05.873412647 -0700
+++ ld/testsuite/ld-scripts/sort_b_n_a.t	2004-09-01 12:46:05.725820618 -0700
@@ -0,0 +1,5 @@
+SECTIONS
+{
+  .text : {*(SORT_BY_NAME(SORT_BY_ALIGNMENT(.text*)))}
+  /DISCARD/ : { *(.*) }
+}
--- ld/testsuite/ld-scripts/sort_b_n_n-1.d.sort	2004-09-01 14:56:05.874412518 -0700
+++ ld/testsuite/ld-scripts/sort_b_n_n-1.d	2004-09-01 12:54:38.708496384 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_n_n.t
+#name: SORT_BY_NAME(SORT_BY_NAME())
+#nm: -n
+
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
+0[0-9a-f]* t text3a
+0[0-9a-f]* t text3b
--- ld/testsuite/ld-scripts/sort_b_n_n-2.d.sort	2004-09-01 14:56:05.875412389 -0700
+++ ld/testsuite/ld-scripts/sort_b_n_n-2.d	2004-09-01 14:54:53.000830013 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_n_n.t --sort-section name
+#name: SORT_BY_NAME(SORT_BY_NAME()) --sort-section name
+#nm: -n
+
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
+0[0-9a-f]* t text3a
+0[0-9a-f]* t text3b
--- ld/testsuite/ld-scripts/sort_b_n_n-3.d.sort	2004-09-01 14:56:05.876412260 -0700
+++ ld/testsuite/ld-scripts/sort_b_n_n-3.d	2004-09-01 14:55:51.126318423 -0700
@@ -0,0 +1,14 @@
+#source: sort_n_a-a.s
+#source: sort_n_a-b.s
+#ld: -T sort_b_n_n.t --sort-section alignment
+#name: SORT_BY_NAME(SORT_BY_NAME()) --sort-section alignment
+#nm: -n
+
+0[0-9a-f]* t texta
+0[0-9a-f]* t textb
+0[0-9a-f]* t text1a
+0[0-9a-f]* t text1b
+0[0-9a-f]* t text2a
+0[0-9a-f]* t text2b
+0[0-9a-f]* t text3b
+0[0-9a-f]* t text3a
--- ld/testsuite/ld-scripts/sort_b_n_n.t.sort	2004-09-01 14:56:05.877412131 -0700
+++ ld/testsuite/ld-scripts/sort_b_n_n.t	2004-09-01 12:55:29.804890061 -0700
@@ -0,0 +1,5 @@
+SECTIONS
+{
+  .text : {*(SORT_BY_NAME(SORT_BY_NAME(.text*)))}
+  /DISCARD/ : { *(.*) }
+}
--- ld/testsuite/ld-scripts/sort_n_a-a.s.sort	2004-09-01 14:56:05.878412001 -0700
+++ ld/testsuite/ld-scripts/sort_n_a-a.s	2004-09-01 12:48:10.288715710 -0700
@@ -0,0 +1,16 @@
+	.section .text2
+	.p2align 3
+text2a:
+	.long 0
+	.section .text3
+	.p2align 5
+text3a:
+	.long 0
+	.section .text1
+	.p2align 5
+text1a:
+	.long 0
+	.text
+texta:
+	.p2align 4
+	.long 0
--- ld/testsuite/ld-scripts/sort_n_a-b.s.sort	2004-09-01 14:56:05.880411743 -0700
+++ ld/testsuite/ld-scripts/sort_n_a-b.s	2004-09-01 12:48:23.278036303 -0700
@@ -0,0 +1,16 @@
+	.section .text2
+	.p2align 3
+text2b:
+	.long 0
+	.section .text3
+	.p2align 6
+text3b:
+	.long 0
+	.section .text1
+	.p2align 5
+text1b:
+	.long 0
+	.text
+textb:
+	.p2align 4
+	.long 0
--- ld/testsuite/ld-scripts/sort_no-1.d.sort	2004-09-01 14:56:05.881411614 -0700
+++ ld/testsuite/ld-scripts/sort_no-1.d	2004-09-01 11:25:33.868630681 -0700
@@ -0,0 +1,9 @@
+#source: sort_b_n.s
+#ld: -T sort_no.t
+#name: no SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT
+#nm: -n
+
+0[0-9a-f]* t text
+0[0-9a-f]* t text2
+0[0-9a-f]* t text3
+0[0-9a-f]* t text1
--- ld/testsuite/ld-scripts/sort_no-2.d.sort	2004-09-01 14:56:05.882411485 -0700
+++ ld/testsuite/ld-scripts/sort_no-2.d	2004-09-01 11:41:38.224882504 -0700
@@ -0,0 +1,9 @@
+#source: sort_b_a.s
+#ld: -T sort_no.t
+#name: no SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT
+#nm: -n
+
+0[0-9a-f]* t text
+0[0-9a-f]* t text2
+0[0-9a-f]* t text3
+0[0-9a-f]* t text1
--- ld/testsuite/ld-scripts/sort_no.t.sort	2004-09-01 14:56:05.883411355 -0700
+++ ld/testsuite/ld-scripts/sort_no.t	2004-09-01 11:13:36.455434546 -0700
@@ -0,0 +1,5 @@
+SECTIONS
+{
+  .text : {*(.text*)}
+  /DISCARD/ : { *(.*) }
+}


More information about the Binutils mailing list