ld: separate output sections for incompatible orphans

Alan Modra amodra@bigpond.net.au
Fri May 15 14:34:00 GMT 2009


My fix for PR6391 resulted in orphan input sections with incompatible
flags and/or types being combined into one output section.  Prior to
that ld created separate output sections for such input, with unique
names formed by appending a suffix to the input section name.  This
patch restores separate output sections for these orphan sections, but
uses the same name.  The machinery to support duplicate output section
names in ld turned out pleasingly simple.

Committed.

ld/
	* ldlang.c (lang_output_section_statement_lookup): Add function
	comment.  Make "name" non-const.  Ensure duplicate entries use
	the same string, allowing simple comparison in hash bucket loop.
	Tweak constraint check.
	(next_matching_output_section_statement): New function.
	* ldlang.h (lang_output_section_statement_lookup): Update.
	(next_matching_output_section_statement): Declare.
	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Don't
	combine orphan sections when input sections flags differ in
	alloc or load.
	* emultempl/pe.em: Formatting throughout.
	(gld${EMULATION_NAME}_place_orphan): As for elf32.em.
	* emultempl/pep.em: Formatting throughout.
	(gld${EMULATION_NAME}_place_orphan): As for elf32.em.
ld/testsuite/
	* ld-elf/orphan3.d, * ld-elf/orphan3a.s, * ld-elf/orphan3b.s,
	* ld-elf/orphan3c.s, * ld-elf/orphan3d.s, * ld-elf/orphan3e.s,
	* ld-elf/orphan3f.s: New test.
	* ld-pe/orphan.d, * ld-pe/orphana.s, * ld-pe/orphanb.s,
	* ld-pe/orphand.s, * ld-pe/orphane.s: New test.
	* ld-pe/direct.exp: Use is_pecoff_format.
	* ld-pe/longsecn.exp: Delete.
	* ld-pe/pe.exp: Run new test and longsecn tests.

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.307
diff -u -p -r1.307 ldlang.c
--- ld/ldlang.c	14 May 2009 02:21:45 -0000	1.307
+++ ld/ldlang.c	15 May 2009 05:32:30 -0000
@@ -1322,8 +1322,13 @@ lang_memory_default (asection * section)
   return lang_memory_region_lookup (DEFAULT_MEMORY_REGION, FALSE);
 }
 
+/* Find or create an output_section_statement with the given NAME.
+   If CONSTRAINT is non-zero match one with that constraint, otherwise
+   match any non-negative constraint.  If CREATE, always make a
+   new output_section_statement for SPECIAL CONSTRAINT.  */
+
 lang_output_section_statement_type *
-lang_output_section_statement_lookup (const char *const name,
+lang_output_section_statement_lookup (const char *name,
 				      int constraint,
 				      bfd_boolean create)
 {
@@ -1344,8 +1349,8 @@ lang_output_section_statement_lookup (co
       /* We have a section of this name, but it might not have the correct
 	 constraint.  */
       struct out_section_hash_entry *last_ent;
-      unsigned long hash = entry->root.hash;
 
+      name = entry->s.output_section_statement.name;
       if (create && constraint == SPECIAL)
 	/* Not traversing to the end reverses the order of the second
 	   and subsequent SPECIAL sections in the hash table chain,
@@ -1354,17 +1359,15 @@ lang_output_section_statement_lookup (co
       else
 	do
 	  {
-	    if (entry->s.output_section_statement.constraint >= 0
-		&& (constraint == 0
-		    || (constraint
-			== entry->s.output_section_statement.constraint)))
+	    if (constraint == entry->s.output_section_statement.constraint
+		|| (constraint == 0
+		    && entry->s.output_section_statement.constraint >= 0))
 	      return &entry->s.output_section_statement;
 	    last_ent = entry;
 	    entry = (struct out_section_hash_entry *) entry->root.next;
 	  }
 	while (entry != NULL
-	       && entry->root.hash == hash
-	       && strcmp (name, entry->s.output_section_statement.name) == 0);
+	       && name == entry->s.output_section_statement.name);
 
       if (!create)
 	return NULL;
@@ -1388,6 +1391,36 @@ lang_output_section_statement_lookup (co
   return &entry->s.output_section_statement;
 }
 
+/* Find the next output_section_statement with the same name as OS.
+   If CONSTRAINT is non-zero, find one with that constraint otherwise
+   match any non-negative constraint.  */
+
+lang_output_section_statement_type *
+next_matching_output_section_statement (lang_output_section_statement_type *os,
+					int constraint)
+{
+  /* All output_section_statements are actually part of a
+     struct out_section_hash_entry.  */
+  struct out_section_hash_entry *entry = (struct out_section_hash_entry *)
+    ((char *) os
+     - offsetof (struct out_section_hash_entry, s.output_section_statement));
+  const char *name = os->name;
+
+  ASSERT (name == entry->root.string);
+  do
+    {
+      entry = (struct out_section_hash_entry *) entry->root.next;
+      if (entry == NULL
+	  || name != entry->s.output_section_statement.name)
+	return NULL;
+    }
+  while (constraint != entry->s.output_section_statement.constraint
+	 && (constraint != 0
+	     || entry->s.output_section_statement.constraint < 0));
+
+  return &entry->s.output_section_statement;
+}
+
 /* A variant of lang_output_section_find used by place_orphan.
    Returns the output statement that should precede a new output
    statement for SEC.  If an exact match is found on certain flags,
Index: ld/ldlang.h
===================================================================
RCS file: /cvs/src/src/ld/ldlang.h,v
retrieving revision 1.82
diff -u -p -r1.82 ldlang.h
--- ld/ldlang.h	2 Mar 2009 17:27:35 -0000	1.82
+++ ld/ldlang.h	15 May 2009 05:32:30 -0000
@@ -550,7 +550,9 @@ extern lang_input_statement_type *lang_a
 extern void lang_add_keepsyms_file
   (const char *);
 extern lang_output_section_statement_type *lang_output_section_statement_lookup
-  (const char *const, int, bfd_boolean);
+  (const char *, int, bfd_boolean);
+extern lang_output_section_statement_type *next_matching_output_section_statement
+  (lang_output_section_statement_type *, int);
 extern void ldlang_add_undef
   (const char *const);
 extern void lang_add_output_format
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.196
diff -u -p -r1.196 elf32.em
--- ld/emultempl/elf32.em	21 Oct 2008 22:55:04 -0000	1.196
+++ ld/emultempl/elf32.em	15 May 2009 05:32:32 -0000
@@ -1712,23 +1712,32 @@ gld${EMULATION_NAME}_place_orphan (asect
     }
 
   /* Look through the script to see where to place this section.  */
-  if (constraint == 0
-      && (os = lang_output_section_find (secname)) != NULL
-      && os->bfd_section != NULL
-      && (os->bfd_section->flags == 0
-	  || (_bfd_elf_match_sections_by_type (link_info.output_bfd,
-					       os->bfd_section, s->owner, s)
-	      && ((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 has compatible flags.
-	 If the section already exists but does not have any flags
-	 set, then it has been created by the linker, probably as a
-	 result of a --section-start command line switch.  */
-      lang_add_section (&os->children, s, os);
-      return os;
-    }
+  if (constraint == 0)
+    for (os = lang_output_section_find (secname);
+	 os != NULL;
+	 os = next_matching_output_section_statement (os, 0))
+      {
+	/* If we don't match an existing output section, tell
+	   lang_insert_orphan to create a new output section.  */
+	constraint = SPECIAL;
+
+	if (os->bfd_section != NULL
+	    && (os->bfd_section->flags == 0
+		|| (_bfd_elf_match_sections_by_type (link_info.output_bfd,
+						     os->bfd_section,
+						     s->owner, s)
+		    && ((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 has compatible flags.
+	       If the section already exists but does not have any flags
+	       set, then it has been created by the linker, probably as a
+	       result of a --section-start command line switch.  */
+	    lang_add_section (&os->children, s, os);
+	    return os;
+	  }
+      }
 
   if (!orphan_init_done)
     {
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.149
diff -u -p -r1.149 pe.em
--- ld/emultempl/pe.em	14 May 2009 02:21:45 -0000	1.149
+++ ld/emultempl/pe.em	15 May 2009 05:32:33 -0000
@@ -242,9 +242,12 @@ fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_add_options
-  (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
-    struct option **longopts, int nrl ATTRIBUTE_UNUSED,
-    struct option **really_longopts ATTRIBUTE_UNUSED)
+  (int ns ATTRIBUTE_UNUSED,
+   char **shortopts ATTRIBUTE_UNUSED,
+   int nl,
+   struct option **longopts,
+   int nrl ATTRIBUTE_UNUSED,
+   struct option **really_longopts ATTRIBUTE_UNUSED)
 {
   static const struct option xtra_long[] = {
     /* PE options */
@@ -267,8 +270,8 @@ gld${EMULATION_NAME}_add_options
     {"use-nul-prefixed-import-tables", no_argument, NULL,
      OPTION_USE_NUL_PREFIXED_IMPORT_TABLES},
 #ifdef DLL_SUPPORT
-    /* getopt allows abbreviations, so we do this to stop it from treating -o
-       as an abbreviation for this option */
+    /* getopt allows abbreviations, so we do this to stop it
+       from treating -o as an abbreviation for this option.  */
     {"output-def", required_argument, NULL, OPTION_OUT_DEF},
     {"output-def", required_argument, NULL, OPTION_OUT_DEF},
     {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL},
@@ -311,8 +314,8 @@ gld${EMULATION_NAME}_add_options
     {NULL, no_argument, NULL, 0}
   };
 
-  *longopts = (struct option *)
-    xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
+  *longopts
+    = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
   memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
 }
 
@@ -819,12 +822,15 @@ gld_${EMULATION_NAME}_set_symbols (void)
       if (link_info.relocatable)
 	init[IMAGEBASEOFF].value = 0;
       else if (init[DLLOFF].value || (link_info.shared && !link_info.pie))
+	{
 #ifdef DLL_SUPPORT
-	init[IMAGEBASEOFF].value = (pe_enable_auto_image_base) ?
-	  compute_dll_image_base (output_filename) : NT_DLL_IMAGE_BASE;
+	  init[IMAGEBASEOFF].value = (pe_enable_auto_image_base
+				      ? compute_dll_image_base (output_filename)
+				      : NT_DLL_IMAGE_BASE);
 #else
-	init[IMAGEBASEOFF].value = NT_DLL_IMAGE_BASE;
+	  init[IMAGEBASEOFF].value = NT_DLL_IMAGE_BASE;
 #endif
+	}
       else
 	init[IMAGEBASEOFF].value = NT_EXE_IMAGE_BASE;
       init[MSIMAGEBASEOFF].value = init[IMAGEBASEOFF].value;
@@ -859,8 +865,7 @@ gld_${EMULATION_NAME}_set_symbols (void)
   /* Restore the pointer.  */
   pop_stat_ptr ();
 
-  if (pe.FileAlignment >
-      pe.SectionAlignment)
+  if (pe.FileAlignment > pe.SectionAlignment)
     {
       einfo (_("%P: warning, file alignment > section alignment.\n"));
     }
@@ -1266,7 +1271,7 @@ gld_${EMULATION_NAME}_after_open (void)
 		      }
 		    symbols = bfd_get_outsymbols (is->the_bfd);
 
-		    relocs = (arelent **) xmalloc ((size_t) relsize);
+		    relocs = xmalloc ((size_t) relsize);
 		    nrelocs = bfd_canonicalize_reloc (is->the_bfd, sec,
 						      relocs, symbols);
 		    if (nrelocs < 0)
@@ -1581,7 +1586,7 @@ gld_${EMULATION_NAME}_unrecognized_file 
 		buflen = len + 2;
 	    }
 
-	  buf = (char *) xmalloc (buflen);
+	  buf = xmalloc (buflen);
 
 	  for (i = 0; i < pe_def_file->num_exports; i++)
 	    {
@@ -1716,7 +1721,7 @@ gld_${EMULATION_NAME}_finish (void)
 #ifdef DLL_SUPPORT
   if (link_info.shared
 #if !defined(TARGET_IS_shpe) && !defined(TARGET_IS_mipspe)
-    || (!link_info.relocatable && pe_def_file->num_exports != 0)
+      || (!link_info.relocatable && pe_def_file->num_exports != 0)
 #endif
     )
     {
@@ -1786,21 +1791,32 @@ gld_${EMULATION_NAME}_place_orphan (asec
 
   lang_list_init (&add_child);
 
-  if (constraint == 0
-      && (os = lang_output_section_find (secname)) != NULL
-      && os->bfd_section != NULL
-      && (os->bfd_section->flags == 0
-	  || ((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 has compatible flags.
-	 If the section already exists but does not have any flags set,
-	 then it has been created by the linker, probably as a result of
-	 a --section-start command line switch.  */
-      lang_add_section (&add_child, s, os);
-    }
-  else
+  os = NULL;
+  if (constraint == 0)
+    for (os = lang_output_section_find (secname);
+	 os != NULL;
+	 os = next_matching_output_section_statement (os, 0))
+      {
+	/* If we don't match an existing output section, tell
+	   lang_insert_orphan to create a new output section.  */
+	constraint = SPECIAL;
+
+	if (os->bfd_section != NULL
+	    && (os->bfd_section->flags == 0
+		|| ((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 has compatible flags.
+	       If the section already exists but does not have any flags set,
+	       then it has been created by the linker, probably as a result of
+	       a --section-start command line switch.  */
+	    lang_add_section (&add_child, s, os);
+	    break;
+	  }
+      }
+
+  if (os == NULL)
     {
       static struct orphan_save hold[] =
 	{
@@ -1906,7 +1922,8 @@ gld_${EMULATION_NAME}_place_orphan (asec
 
 static bfd_boolean
 gld_${EMULATION_NAME}_open_dynamic_archive
-  (const char *arch ATTRIBUTE_UNUSED, search_dirs_type *search,
+  (const char *arch ATTRIBUTE_UNUSED,
+   search_dirs_type *search,
    lang_input_statement_type *entry)
 {
   static const struct
Index: ld/emultempl/pep.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pep.em,v
retrieving revision 1.26
diff -u -p -r1.26 pep.em
--- ld/emultempl/pep.em	14 May 2009 02:21:45 -0000	1.26
+++ ld/emultempl/pep.em	15 May 2009 05:32:34 -0000
@@ -260,10 +260,12 @@ gld${EMULATION_NAME}_add_options
     {"no-seh", no_argument, NULL, OPTION_NO_SEH},
     {"no-bind", no_argument, NULL, OPTION_NO_BIND},
     {"wdmdriver", no_argument, NULL, OPTION_WDM_DRIVER},
-    {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE},    {NULL, no_argument, NULL, 0}
+    {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE},
+    {NULL, no_argument, NULL, 0}
   };
 
-  *longopts = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
+  *longopts
+    = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
   memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
 }
 
@@ -370,7 +372,7 @@ gld_${EMULATION_NAME}_list_options (FILE
   fprintf (file, _("  --no-isolation		 Image understands isolation but do not isolate the image\n"));
   fprintf (file, _("  --no-seh			 Image does not use SEH. No SE handler may\n\
 				       be called in this image\n"));
-  fprintf (file, _("  --no-bind		 	 Do not bind this image\n"));
+  fprintf (file, _("  --no-bind			 Do not bind this image\n"));
   fprintf (file, _("  --wdmdriver		 Driver uses the WDM model\n"));
   fprintf (file, _("  --tsaware       		 Image is Terminal Server aware\n"));
 #endif
@@ -757,15 +759,18 @@ gld_${EMULATION_NAME}_set_symbols (void)
       if (link_info.relocatable)
 	init[IMAGEBASEOFF].value = 0;
       else if (init[DLLOFF].value || (link_info.shared && !link_info.pie))
+	{
 #ifdef DLL_SUPPORT
-	init[IMAGEBASEOFF].value = (pep_enable_auto_image_base) ?
-	  compute_dll_image_base (output_filename) : NT_DLL_IMAGE_BASE;
+	  init[IMAGEBASEOFF].value = (pep_enable_auto_image_base
+				      ? compute_dll_image_base (output_filename)
+				      : NT_DLL_IMAGE_BASE);
 #else
-	init[IMAGEBASEOFF].value = NT_DLL_IMAGE_BASE;
+	  init[IMAGEBASEOFF].value = NT_DLL_IMAGE_BASE;
 #endif
+	}
       else
 	init[IMAGEBASEOFF].value = NT_EXE_IMAGE_BASE;
-	init[MSIMAGEBASEOFF].value = init[IMAGEBASEOFF].value;
+      init[MSIMAGEBASEOFF].value = init[IMAGEBASEOFF].value;
     }
 
   /* Don't do any symbol assignments if this is a relocatable link.  */
@@ -1057,7 +1062,7 @@ This should work unless it involves cons
 		}
 
 	      pep_walk_relocs_of_symbol (&link_info, undef->root.string,
-					make_import_fixup);
+					 make_import_fixup);
 
 	      /* Let's differentiate it somehow from defined.  */
 	      undef->type = bfd_link_hash_defweak;
@@ -1561,21 +1566,32 @@ gld_${EMULATION_NAME}_place_orphan (asec
 
   lang_list_init (&add_child);
 
-  if (constraint == 0
-      && (os = lang_output_section_find (secname)) != NULL
-      && os->bfd_section != NULL
-      && (os->bfd_section->flags == 0
-	  || ((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 has compatible flags.
-	 If the section already exists but does not have any flags set,
-	 then it has been created by the linker, probably as a result of
-	 a --section-start command line switch.  */
-      lang_add_section (&add_child, s, os);
-    }
-  else
+  os = NULL;
+  if (constraint == 0)
+    for (os = lang_output_section_find (secname);
+	 os != NULL;
+	 os = next_matching_output_section_statement (os, 0))
+      {
+	/* If we don't match an existing output section, tell
+	   lang_insert_orphan to create a new output section.  */
+	constraint = SPECIAL;
+
+	if (os->bfd_section != NULL
+	    && (os->bfd_section->flags == 0
+		|| ((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 has compatible flags.
+	       If the section already exists but does not have any flags set,
+	       then it has been created by the linker, probably as a result of
+	       a --section-start command line switch.  */
+	    lang_add_section (&add_child, s, os);
+	    break;
+	  }
+      }
+
+  if (os == NULL)
     {
       static struct orphan_save hold[] =
 	{
Index: ld/testsuite/ld-elf/orphan3.d
===================================================================
RCS file: ld/testsuite/ld-elf/orphan3.d
diff -N ld/testsuite/ld-elf/orphan3.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/orphan3.d	15 May 2009 05:40:07 -0000
@@ -0,0 +1,21 @@
+#source: orphan3a.s
+#source: orphan3b.s
+#source: orphan3c.s
+#source: orphan3d.s
+#source: orphan3e.s
+#source: orphan3f.s
+#ld:
+#readelf: -S --wide
+#xfail: "arc-*-*" "d30v-*-*" "dlx-*-*" "fr30-*-*" "frv-*-*"
+#xfail: "i860-*-*" "i960-*-*" "iq2000-*-*" "mn10200-*-*" "msp430-*-*" "mt-*-*"
+#xfail: "or32-*-*" "pj-*-*"
+#xfail: "cr16-*-*" "crx-*-*" "d10v-*-*" "xstormy16-*-*"
+
+#...
+  \[[ 0-9]+\] \.foo +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +0+ +A +0 +0 +[0-9]+
+#...
+  \[[ 0-9]+\] \.foo +NOBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +0+ +A +0 +0 +[0-9]+
+#...
+  \[[ 0-9]+\] \.foo +PROGBITS +0+ +[0-9a-f]+ +0+8 +0+ +0 +0 +[0-9]+
+  \[[ 0-9]+\] \.[^f].*
+#pass
Index: ld/testsuite/ld-elf/orphan3a.s
===================================================================
RCS file: ld/testsuite/ld-elf/orphan3a.s
diff -N ld/testsuite/ld-elf/orphan3a.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/orphan3a.s	15 May 2009 05:40:07 -0000
@@ -0,0 +1,12 @@
+ .globl main
+ .globl start
+ .globl _start
+ .globl __start
+ .text
+main:
+start:
+_start:
+__start:
+
+ .section .foo,"a",%nobits
+ .space 4
Index: ld/testsuite/ld-elf/orphan3b.s
===================================================================
RCS file: ld/testsuite/ld-elf/orphan3b.s
diff -N ld/testsuite/ld-elf/orphan3b.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/orphan3b.s	15 May 2009 05:40:07 -0000
@@ -0,0 +1,2 @@
+ .section .foo,"a",%progbits
+ .long 1
Index: ld/testsuite/ld-elf/orphan3c.s
===================================================================
RCS file: ld/testsuite/ld-elf/orphan3c.s
diff -N ld/testsuite/ld-elf/orphan3c.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/orphan3c.s	15 May 2009 05:40:07 -0000
@@ -0,0 +1,2 @@
+ .section .foo,"",%progbits
+ .long 2
Index: ld/testsuite/ld-elf/orphan3d.s
===================================================================
RCS file: ld/testsuite/ld-elf/orphan3d.s
diff -N ld/testsuite/ld-elf/orphan3d.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/orphan3d.s	15 May 2009 05:40:07 -0000
@@ -0,0 +1,2 @@
+ .section .foo,"a",%nobits
+ .space 4
Index: ld/testsuite/ld-elf/orphan3e.s
===================================================================
RCS file: ld/testsuite/ld-elf/orphan3e.s
diff -N ld/testsuite/ld-elf/orphan3e.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/orphan3e.s	15 May 2009 05:40:07 -0000
@@ -0,0 +1,2 @@
+ .section .foo,"a",%progbits
+ .long 4
Index: ld/testsuite/ld-elf/orphan3f.s
===================================================================
RCS file: ld/testsuite/ld-elf/orphan3f.s
diff -N ld/testsuite/ld-elf/orphan3f.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/orphan3f.s	15 May 2009 05:40:07 -0000
@@ -0,0 +1,2 @@
+ .section .foo,"",%progbits
+ .long 5
Index: ld/testsuite/ld-pe/direct.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/direct.exp,v
retrieving revision 1.2
diff -u -p -r1.2 direct.exp
--- ld/testsuite/ld-pe/direct.exp	6 Jul 2007 14:09:44 -0000	1.2
+++ ld/testsuite/ld-pe/direct.exp	15 May 2009 13:41:36 -0000
@@ -49,9 +49,7 @@
 # 7. run the produced executables
 
 # This test can only be run on PE/COFF platforms.
-if {    ![istarget *-*-cygwin*]
-     && ![istarget *-*-mingw*]
-     && ![istarget *-*-pe] } {
+if {![is_pecoff_format]} {
     return
 }
 
Index: ld/testsuite/ld-pe/longsecn.exp
===================================================================
RCS file: ld/testsuite/ld-pe/longsecn.exp
diff -N ld/testsuite/ld-pe/longsecn.exp
--- ld/testsuite/ld-pe/longsecn.exp	18 Feb 2009 18:23:08 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,35 +0,0 @@
-# Expect script for COFF long section name tests
-#   Copyright 2009
-#   Free Software Foundation, Inc.
-#
-# This file is part of the GNU Binutils.
-#
-# This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
-# MA 02110-1301, USA.
-#
- 
-# This test can only be run on PE/COFF platforms.
-if {![is_pecoff_format]} {
-    return
-}
-
-run_dump_test "longsecn"
-
-run_dump_test "longsecn-1"
-run_dump_test "longsecn-2"
-run_dump_test "longsecn-3"
-run_dump_test "longsecn-4"
-run_dump_test "longsecn-5"
-
Index: ld/testsuite/ld-pe/orphan.d
===================================================================
RCS file: ld/testsuite/ld-pe/orphan.d
diff -N ld/testsuite/ld-pe/orphan.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/orphan.d	15 May 2009 13:41:36 -0000
@@ -0,0 +1,13 @@
+#source: orphana.s
+#source: orphanb.s
+#source: orphand.s
+#source: orphane.s
+#ld: --file-align 1 --section-align 1
+#objdump: -h --wide
+
+#...
+ +0 +\.text .*
+ +1 +\.foo +0+8 .*
+ +2 +\.foo +0+8 .*
+ +3 +\.idata .*
+#pass
Index: ld/testsuite/ld-pe/orphana.s
===================================================================
RCS file: ld/testsuite/ld-pe/orphana.s
diff -N ld/testsuite/ld-pe/orphana.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/orphana.s	15 May 2009 13:41:36 -0000
@@ -0,0 +1,8 @@
+ .globl _mainCRTStartup
+ .globl _start
+ .text
+_mainCRTStartup:
+_start:
+
+ .section .foo,"b"
+ .space 4
Index: ld/testsuite/ld-pe/orphanb.s
===================================================================
RCS file: ld/testsuite/ld-pe/orphanb.s
diff -N ld/testsuite/ld-pe/orphanb.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/orphanb.s	15 May 2009 13:41:36 -0000
@@ -0,0 +1,2 @@
+ .section .foo
+ .long 1
Index: ld/testsuite/ld-pe/orphand.s
===================================================================
RCS file: ld/testsuite/ld-pe/orphand.s
diff -N ld/testsuite/ld-pe/orphand.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/orphand.s	15 May 2009 13:41:36 -0000
@@ -0,0 +1,2 @@
+ .section .foo,"b"
+ .space 4
Index: ld/testsuite/ld-pe/orphane.s
===================================================================
RCS file: ld/testsuite/ld-pe/orphane.s
diff -N ld/testsuite/ld-pe/orphane.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/orphane.s	15 May 2009 13:41:36 -0000
@@ -0,0 +1,2 @@
+ .section .foo
+ .long 4
Index: ld/testsuite/ld-pe/pe.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/pe.exp,v
retrieving revision 1.10
diff -u -p -r1.10 pe.exp
--- ld/testsuite/ld-pe/pe.exp	2 Apr 2009 14:42:41 -0000	1.10
+++ ld/testsuite/ld-pe/pe.exp	15 May 2009 13:41:36 -0000
@@ -1,52 +1,65 @@
-# Expect script for export table in executables tests
-#   Copyright 2004, 2006, 2007
-#   Free Software Foundation, Inc.
-#
-# This file is part of the GNU Binutils.
-#
-# This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
-# MA 02110-1301, USA.
-#
- 
-# This test can only be run on PE/COFF platforms that support .secrel32.
-if {    ![istarget i*86-*-cygwin*]
-     && ![istarget i*86-*-pe]
-     && ![istarget i*86-*-mingw*]
-     && ![istarget x86_64-*-mingw*]
-     && ![istarget arm-wince-pe] } {
-    return
-}
-
-if {[istarget x86_64-*-mingw*] } {
-  set pe_tests {
-    {".secrel32" "" "" {secrel1.s secrel2.s}
-    {{objdump -s secrel_64.d}} "secrel.x"}
-  }
-} elseif {[istarget i*86-*-cygwin*] } {
-  set pe_tests {
-    {".secrel32" "--disable-auto-import" "" {secrel1.s secrel2.s}
-     {{objdump -s secrel.d}} "secrel.x"}
-  }
-} else {
-  set pe_tests {
-    {".secrel32" "" "" {secrel1.s secrel2.s}
-     {{objdump -s secrel.d}} "secrel.x"}
-  }
-}
-
-run_ld_link_tests $pe_tests
-
-run_dump_test "image_size"
-run_dump_test "export_dynamic_warning"
+# Expect script for export table in executables tests
+#   Copyright 2004, 2006, 2007
+#   Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+# These tests can only be run on PE/COFF platforms.
+if {![is_pecoff_format]} {
+    return
+}
+
+# This test can only be run on PE/COFF platforms that support .secrel32.
+if {[istarget i*86-*-cygwin*]
+    || [istarget i*86-*-pe]
+    || [istarget i*86-*-mingw*]
+    || [istarget x86_64-*-mingw*]
+    || [istarget arm-wince-pe] } {
+
+    if {[istarget x86_64-*-mingw*] } {
+      set pe_tests {
+	{".secrel32" "" "" {secrel1.s secrel2.s}
+	{{objdump -s secrel_64.d}} "secrel.x"}
+      }
+    } elseif {[istarget i*86-*-cygwin*] } {
+      set pe_tests {
+	{".secrel32" "--disable-auto-import" "" {secrel1.s secrel2.s}
+	 {{objdump -s secrel.d}} "secrel.x"}
+      }
+    } else {
+      set pe_tests {
+	{".secrel32" "" "" {secrel1.s secrel2.s}
+	 {{objdump -s secrel.d}} "secrel.x"}
+      }
+    }
+
+    run_ld_link_tests $pe_tests
+}
+
+run_dump_test "image_size"
+run_dump_test "export_dynamic_warning"
+
+run_dump_test "longsecn"
+run_dump_test "longsecn-1"
+run_dump_test "longsecn-2"
+run_dump_test "longsecn-3"
+run_dump_test "longsecn-4"
+run_dump_test "longsecn-5"
+
+run_dump_test "orphan"

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list