Fix linking with multiple same-name sections. (PR 27100)

This commit is contained in:
Nick Clifton 2021-01-04 16:31:41 +00:00
parent 4b3b7c0eda
commit 5aee897b5c
2 changed files with 42 additions and 1 deletions

View File

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

View File

@ -39,7 +39,7 @@
Summary: A GNU collection of binary utilities
Name: binutils%{?name_cross}%{?_with_debug:-debug}
Version: 2.35.1
Release: 17%{?dist}
Release: 18%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -291,6 +291,10 @@ Patch27: binutils-recursive-debuglink-following.patch
# Lifetime: Fixed in 2.36
Patch28: binutils-SHF_LINK_ORDER.patch
# Purpose: Correctly handle multiple same-named sections in linker scripts
# Lifetime: Fixed in 2.36
Patch29: binutils-duplicate-sections.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -870,6 +874,9 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Mon Jan 04 2021 Nick Clifton <nickc@redhat.com> - 2.35.1-18
- Fix linking with multiple same-name sections. (PR 27100)
* Mon Jan 04 2021 Nick Clifton <nickc@redhat.com> - 2.35.1-17
- Fix linking mixed SHF_LINK_ORDER and non-SHF_LINK_ORDER sections. (#1907945)