Blame SOURCES/binutils-duplicate-sections.patch

d1152b
diff -rup binutils.orig/ld/ldlang.c binutils-2.35.1/ld/ldlang.c
d1152b
--- binutils.orig/ld/ldlang.c	2021-01-04 15:20:32.901498036 +0000
d1152b
+++ binutils-2.35.1/ld/ldlang.c	2021-01-04 15:22:03.151916333 +0000
d1152b
@@ -1529,6 +1529,8 @@ lang_output_section_statement_lookup (co
d1152b
 
d1152b
   entry->s.output_section_statement.name = name;
d1152b
   entry->s.output_section_statement.constraint = constraint;
d1152b
+  entry->s.output_section_statement.dup_output = (create == 2
d1152b
+                                                 || constraint == SPECIAL);
d1152b
   return &entry->s.output_section_statement;
d1152b
 }
d1152b
 
d1152b
@@ -2390,7 +2392,7 @@ init_os (lang_output_section_statement_t
d1152b
   if (strcmp (s->name, DISCARD_SECTION_NAME) == 0)
d1152b
     einfo (_("%F%P: illegal use of `%s' section\n"), DISCARD_SECTION_NAME);
d1152b
 
d1152b
-  if (s->constraint != SPECIAL)
d1152b
+  if (!s->dup_output)
d1152b
     s->bfd_section = bfd_get_section_by_name (link_info.output_bfd, s->name);
d1152b
   if (s->bfd_section == NULL)
d1152b
     s->bfd_section = bfd_make_section_anyway_with_flags (link_info.output_bfd,
d1152b
diff -rup binutils.orig/ld/ldlang.h binutils-2.35.1/ld/ldlang.h
d1152b
--- binutils.orig/ld/ldlang.h	2021-01-04 15:20:32.627499830 +0000
d1152b
+++ binutils-2.35.1/ld/ldlang.h	2021-01-04 15:21:06.688277003 +0000
d1152b
@@ -173,6 +173,9 @@ typedef struct lang_output_section_state
d1152b
   unsigned int after_end : 1;
d1152b
   /* If this section uses the alignment of its input sections.  */
d1152b
   unsigned int align_lma_with_input : 1;
d1152b
+  /* If script has duplicate output section statements of the same name
d1152b
+     create duplicate output sections.  */
d1152b
+  unsigned int dup_output : 1;
d1152b
 } lang_output_section_statement_type;
d1152b
 
d1152b
 typedef struct