Nicholas Clifton 577fbb
--- ../binutils-2.19.51.0.2.orig/ld/ldlang.c	2009-07-17 12:43:11.000000000 +0100
Nicholas Clifton 577fbb
+++ ld/ldlang.c	2009-07-17 12:50:39.000000000 +0100
Nicholas Clifton 577fbb
@@ -1533,10 +1533,13 @@ output_prev_sec_find (lang_output_sectio
Nicholas Clifton 577fbb
    idea is to skip over anything that might be inside a SECTIONS {}
Nicholas Clifton 577fbb
    statement in a script, before we find another output section
Nicholas Clifton 577fbb
    statement.  Assignments to "dot" before an output section statement
Nicholas Clifton 577fbb
-   are assumed to belong to it.  An exception to this rule is made for
Nicholas Clifton 577fbb
-   the first assignment to dot, otherwise we might put an orphan
Nicholas Clifton 577fbb
-   before . = . + SIZEOF_HEADERS or similar assignments that set the
Nicholas Clifton 577fbb
-   initial address.  */
Nicholas Clifton 577fbb
+   are assumed to belong to it, except in two cases;  The first
Nicholas Clifton 577fbb
+   assignment to dot, and assignments before non-alloc sections.
Nicholas Clifton 577fbb
+   Otherwise we might put an orphan before . = . + SIZEOF_HEADERS or
Nicholas Clifton 577fbb
+   similar assignments that set the initial address, or we might
Nicholas Clifton 577fbb
+   insert non-alloc note sections among assignments setting end of
Nicholas Clifton 577fbb
+   image symbols.  */
Nicholas Clifton 577fbb
+
Nicholas Clifton 577fbb
 
Nicholas Clifton 577fbb
 static lang_statement_union_type **
Nicholas Clifton 577fbb
 insert_os_after (lang_output_section_statement_type *after)
Nicholas Clifton 577fbb
@@ -1580,7 +1583,12 @@ insert_os_after (lang_output_section_sta
Nicholas Clifton 577fbb
 	  continue;
Nicholas Clifton 577fbb
 	case lang_output_section_statement_enum:
Nicholas Clifton 577fbb
 	  if (assign != NULL)
Nicholas Clifton 577fbb
-	    where = assign;
Nicholas Clifton 577fbb
+	    {
Nicholas Clifton 577fbb
+	      asection *s = (*where)->output_section_statement.bfd_section;
Nicholas Clifton 577fbb
+
Nicholas Clifton 577fbb
+	      if (s == NULL || (s->flags & SEC_ALLOC) != 0)
Nicholas Clifton 577fbb
+		where = assign;
Nicholas Clifton 577fbb
+	    }
Nicholas Clifton 577fbb
 	  break;
Nicholas Clifton 577fbb
 	case lang_input_statement_enum:
Nicholas Clifton 577fbb
 	case lang_address_statement_enum: