From a902ca5ef78cb34e7f3569dd8c7ed33e292cae4a Mon Sep 17 00:00:00 2001 From: eabdullin Date: Tue, 12 Nov 2024 10:35:28 +0000 Subject: [PATCH] import UBI binutils-2.35.2-54.el9 --- SOURCES/binutils-AArch64-EFI.patch | 9 + SOURCES/binutils-gnu.debuglto_.patch | 75 ++++ .../binutils-objcopy-pe-section-align.patch | 365 ++++++++++++++++++ SOURCES/binutils-prune-lto-messages.patch | 16 + SOURCES/binutils-relro-padding.patch | 15 + SOURCES/binutils-relro.patch | 140 +++++++ SPECS/binutils.spec | 55 ++- 7 files changed, 674 insertions(+), 1 deletion(-) create mode 100644 SOURCES/binutils-gnu.debuglto_.patch create mode 100644 SOURCES/binutils-objcopy-pe-section-align.patch create mode 100644 SOURCES/binutils-prune-lto-messages.patch create mode 100644 SOURCES/binutils-relro-padding.patch create mode 100644 SOURCES/binutils-relro.patch diff --git a/SOURCES/binutils-AArch64-EFI.patch b/SOURCES/binutils-AArch64-EFI.patch index 06ba201..eefcb4e 100644 --- a/SOURCES/binutils-AArch64-EFI.patch +++ b/SOURCES/binutils-AArch64-EFI.patch @@ -926,3 +926,12 @@ diff -rup binutils.orig/include/coff/pe.h binutils-2.35.2/include/coff/pe.h +#define PEAOUTHDR PEPAOUTHDR + +#include "coff-aarch64.c" +--- binutils.orig/binutils/testsuite/binutils-all/aarch64/pei-aarch64-little.d 2024-06-04 14:00:51.569526147 +0100 ++++ binutils-2.35.2/binutils/testsuite/binutils-all/aarch64/pei-aarch64-little.d 2024-06-04 14:00:59.049544354 +0100 +@@ -12,5 +12,5 @@ start address 0x0000000000000000 + + Sections: + Idx Name Size VMA LMA File off Algn +- 0 \.text 00000030 0[^ ]+ 0[^ ]+ 0[^ ]+ 2\*\*2 ++ 0 \.text 00000030 0[^ ]+ 0[^ ]+ 0[^ ]+ 2\*\*12 + CONTENTS, ALLOC, LOAD, READONLY, CODE diff --git a/SOURCES/binutils-gnu.debuglto_.patch b/SOURCES/binutils-gnu.debuglto_.patch new file mode 100644 index 0000000..e612c52 --- /dev/null +++ b/SOURCES/binutils-gnu.debuglto_.patch @@ -0,0 +1,75 @@ +diff -rup binutils.orig/bfd/elf.c binutils-2.35.2/bfd/elf.c +--- binutils.orig/bfd/elf.c 2024-06-20 16:18:11.685058701 +0100 ++++ binutils-2.35.2/bfd/elf.c 2024-06-20 16:19:59.040433524 +0100 +@@ -1090,6 +1090,7 @@ _bfd_elf_make_section_from_shdr (bfd *ab + if (name [0] == '.') + { + if (strncmp (name, ".debug", 6) == 0 ++ || strncmp (name, ".gnu.debuglto_.debug_", 21) == 0 + || strncmp (name, ".gnu.linkonce.wi.", 17) == 0 + || strncmp (name, ".zdebug", 7) == 0) + flags |= SEC_DEBUGGING | SEC_ELF_OCTETS; +diff -rup binutils.orig/ld/ldlang.c binutils-2.35.2/ld/ldlang.c +--- binutils.orig/ld/ldlang.c 2024-06-20 16:18:11.518058118 +0100 ++++ binutils-2.35.2/ld/ldlang.c 2024-06-20 16:21:50.407756115 +0100 +@@ -7471,7 +7471,7 @@ lang_gc_sections (void) + lang_gc_sections_1 (statement_list.head); + + /* SEC_EXCLUDE is ignored when doing a relocatable link, except in +- the special case of debug info. (See bfd/stabs.c) ++ the special case of .stabstr debug info. (See bfd/stabs.c) + Twiddle the flag here, to simplify later linker code. */ + if (bfd_link_relocatable (&link_info)) + { +@@ -7483,7 +7483,8 @@ lang_gc_sections (void) + continue; + #endif + for (sec = f->the_bfd->sections; sec != NULL; sec = sec->next) +- if ((sec->flags & SEC_DEBUGGING) == 0) ++ if ((sec->flags & SEC_DEBUGGING) == 0 ++ || strcmp (sec->name, ".stabstr") != 0) + sec->flags &= ~SEC_EXCLUDE; + } + } +diff -rupN binutils.orig/ld/testsuite/ld-elf/pr27590.s binutils-2.35.2/ld/testsuite/ld-elf/pr27590.s +--- binutils.orig/ld/testsuite/ld-elf/pr27590.s 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.35.2/ld/testsuite/ld-elf/pr27590.s 2024-06-20 16:51:39.108295959 +0100 +@@ -0,0 +1,6 @@ ++ .section .gnu.debuglto_.debug_macro,"",%progbits ++.Ldebug_macro0: ++ .dc.a .Ldebug_macro2 ++ .section .gnu.debuglto_.debug_macro,"G",%progbits,wm4,comdat ++.Ldebug_macro2: ++ .long 0x4 +diff -rupN binutils.orig/ld/testsuite/ld-elf/pr27590a.d binutils-2.35.2/ld/testsuite/ld-elf/pr27590a.d +--- binutils.orig/ld/testsuite/ld-elf/pr27590a.d 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.35.2/ld/testsuite/ld-elf/pr27590a.d 2024-06-20 16:51:39.111295967 +0100 +@@ -0,0 +1,12 @@ ++#source: pr27590.s ++#ld: -r tmpdir/pr27590.o ++#readelf: -rW ++#xfail: [is_generic] ++ ++Relocation section '\.rel.*\.gnu\.debuglto_\.debug_macro' at offset 0x[0-9a-z]+ contains 2 entries: ++[ \t]+Offset[ \t]+Info[ \t]+Type[ \t]+Sym.* ++[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0]+[ \t]+(\.gnu\.debuglto_\.debug_macro|\.Ldebug_macro2).* ++#?.*R_MIPS_NONE.* ++#?.*R_MIPS_NONE.* ++[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0]+[ \t]+(\.gnu\.debuglto_\.debug_macro|\.Ldebug_macro2).* ++#pass +diff -rupN binutils.orig/ld/testsuite/ld-elf/pr27590b.d binutils-2.35.2/ld/testsuite/ld-elf/pr27590b.d +--- binutils.orig/ld/testsuite/ld-elf/pr27590b.d 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.35.2/ld/testsuite/ld-elf/pr27590b.d 2024-06-20 16:51:39.111295967 +0100 +@@ -0,0 +1,12 @@ ++#source: pr27590.s ++#ld: -r tmpdir/pr27590.o --reduce-memory-overheads ++#readelf: -rW ++#xfail: [is_generic] ++ ++Relocation section '\.rel.*\.gnu\.debuglto_\.debug_macro' at offset 0x[0-9a-z]+ contains 2 entries: ++[ \t]+Offset[ \t]+Info[ \t]+Type[ \t]+Sym.* ++[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0]+[ \t]+(\.gnu\.debuglto_\.debug_macro|\.Ldebug_macro2).* ++#?.*R_MIPS_NONE.* ++#?.*R_MIPS_NONE.* ++[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0]+[ \t]+(\.gnu\.debuglto_\.debug_macro|\.Ldebug_macro2).* ++#pass diff --git a/SOURCES/binutils-objcopy-pe-section-align.patch b/SOURCES/binutils-objcopy-pe-section-align.patch new file mode 100644 index 0000000..8dfccc2 --- /dev/null +++ b/SOURCES/binutils-objcopy-pe-section-align.patch @@ -0,0 +1,365 @@ +diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.35.2/binutils/doc/binutils.texi +--- binutils.orig/binutils/doc/binutils.texi 2024-04-03 11:32:37.507595411 +0100 ++++ binutils-2.35.2/binutils/doc/binutils.texi 2024-04-03 11:32:53.188615675 +0100 +@@ -1643,6 +1643,10 @@ above. If @var{sectionpattern} does not + input file, a warning will be issued, unless + @option{--no-change-warnings} is used. + ++Note - changing the VMA of sections in a fully linked binary can be ++dangerous since there may be code that expects the sections to be ++located at their old address. ++ + @item --change-warnings + @itemx --adjust-warnings + If @option{--change-section-address} or @option{--change-section-lma} or +@@ -1671,7 +1675,14 @@ ELF format files. + @item --set-section-alignment @var{sectionpattern}=@var{align} + Set the alignment for any sections matching @var{sectionpattern}. + @var{align} specifies the alignment in bytes and must be a power of +-two, i.e. 1, 2, 4, 8@dots{}. ++two, i.e. 1, 2, 4, 8@dots{}. ++ ++Note - setting a section's alignment will not automatically align its ++LMA or VMA addresses. If those need to be changed as well then the ++@option{--change-section-lma} and/or @option{--change-section-vma} ++options should be used. Also note that changing VMAs can cause ++problems in fully linked binaries where there may be code that expects ++the contents of the sections to be located at their old address. + + @item --add-section @var{sectionname}=@var{filename} + Add a new section named @var{sectionname} while copying the file. The +@@ -2029,11 +2040,21 @@ for dlls. + [This option is specific to PE targets.] + + @item --section-alignment @var{num} +-Sets the section alignment field in the PE header. Sections in memory +-will always begin at addresses which are a multiple of this number. +-Defaults to 0x1000. + [This option is specific to PE targets.] + ++Sets the section alignment field in the PE header - if one is present ++in the binary. Sections in memory will always begin at addresses ++which are a multiple of this number. Defaults to 0x1000. ++ ++Note - this option will also set the alignment field in each section's ++flags. ++ ++Note - if a section's LMA or VMA addresses are no longer aligned, and ++those addresses have not been set via the @option{--set-section-lma} or ++@option{--set-section-vma} options, and the file has been fully ++relocated then a warning message will be issued. It will then be up ++to the user to decide if the LMA and VMA need updating. ++ + @item --stack @var{reserve} + @itemx --stack @var{reserve},@var{commit} + Specify the number of bytes of memory to reserve (and optionally commit) +diff -rup binutils.orig/binutils/objcopy.c binutils-2.35.2/binutils/objcopy.c +--- binutils.orig/binutils/objcopy.c 2024-04-03 11:32:37.862595870 +0100 ++++ binutils-2.35.2/binutils/objcopy.c 2024-04-03 11:32:53.189615676 +0100 +@@ -3954,6 +3954,50 @@ setup_bfd_headers (bfd *ibfd, bfd *obfd) + return; + } + ++static inline signed int ++power_of_two (bfd_vma val) ++{ ++ signed int result = 0; ++ ++ if (val == 0) ++ return 0; ++ ++ while ((val & 1) == 0) ++ { ++ val >>= 1; ++ ++result; ++ } ++ ++ if (val != 1) ++ /* Number has more than one 1, i.e. wasn't a power of 2. */ ++ return -1; ++ ++ return result; ++} ++ ++static unsigned int ++image_scn_align (unsigned int alignment) ++{ ++ switch (alignment) ++ { ++ case 8192: return IMAGE_SCN_ALIGN_8192BYTES; ++ case 4096: return IMAGE_SCN_ALIGN_4096BYTES; ++ case 2048: return IMAGE_SCN_ALIGN_2048BYTES; ++ case 1024: return IMAGE_SCN_ALIGN_1024BYTES; ++ case 512: return IMAGE_SCN_ALIGN_512BYTES; ++ case 256: return IMAGE_SCN_ALIGN_256BYTES; ++ case 128: return IMAGE_SCN_ALIGN_128BYTES; ++ case 64: return IMAGE_SCN_ALIGN_64BYTES; ++ case 32: return IMAGE_SCN_ALIGN_32BYTES; ++ case 16: return IMAGE_SCN_ALIGN_16BYTES; ++ case 8: return IMAGE_SCN_ALIGN_8BYTES; ++ case 4: return IMAGE_SCN_ALIGN_4BYTES; ++ case 2: return IMAGE_SCN_ALIGN_2BYTES; ++ case 1: return IMAGE_SCN_ALIGN_1BYTES; ++ default: return 0; ++ } ++} ++ + /* Create a section in OBFD with the same + name and attributes as ISECTION in IBFD. */ + +@@ -4058,6 +4102,8 @@ setup_section (bfd *ibfd, sec_ptr isecti + goto loser; + } + ++ bfd_boolean vma_set_by_user = FALSE; ++ + vma = bfd_section_vma (isection); + p = find_section_list (bfd_section_name (isection), FALSE, + SECTION_CONTEXT_ALTER_VMA | SECTION_CONTEXT_SET_VMA); +@@ -4067,6 +4113,7 @@ setup_section (bfd *ibfd, sec_ptr isecti + vma = p->vma_val; + else + vma += p->vma_val; ++ vma_set_by_user = TRUE; + } + else + vma += change_section_address; +@@ -4077,6 +4124,8 @@ setup_section (bfd *ibfd, sec_ptr isecti + goto loser; + } + ++ bfd_boolean lma_set_by_user = FALSE; ++ + lma = isection->lma; + p = find_section_list (bfd_section_name (isection), FALSE, + SECTION_CONTEXT_ALTER_LMA | SECTION_CONTEXT_SET_LMA); +@@ -4086,6 +4135,7 @@ setup_section (bfd *ibfd, sec_ptr isecti + lma += p->lma_val; + else + lma = p->lma_val; ++ lma_set_by_user = TRUE; + } + else + lma += change_section_address; +@@ -4096,6 +4146,24 @@ setup_section (bfd *ibfd, sec_ptr isecti + SECTION_CONTEXT_SET_ALIGNMENT); + if (p != NULL) + alignment = p->alignment; ++ else if (pe_section_alignment != (bfd_vma) -1 ++ && bfd_get_flavour (obfd) == bfd_target_coff_flavour) ++ { ++ alignment = power_of_two (pe_section_alignment); ++ ++ if (coff_section_data (ibfd, isection)) ++ { ++ struct pei_section_tdata * pei_data = pei_section_data (ibfd, isection); ++ ++ if (pei_data != NULL) ++ { ++ /* Set the alignment flag of the input section, which will ++ be copied to the output section later on. */ ++ pei_data->pe_flags &= ~IMAGE_SCN_ALIGN_POWER_BIT_MASK; ++ pei_data->pe_flags |= image_scn_align (pe_section_alignment); ++ } ++ } ++ } + else + alignment = bfd_section_alignment (isection); + +@@ -4107,6 +4175,32 @@ setup_section (bfd *ibfd, sec_ptr isecti + goto loser; + } + ++ /* If the output section's VMA is not aligned ++ and the alignment has changed ++ and the VMA was not set by the user ++ and the section does not have relocations associated with it ++ then warn the user. */ ++ if (osection->vma & ((1 << alignment) - 1) ++ && alignment != bfd_section_alignment (isection) ++ && change_section_address == 0 ++ && ! vma_set_by_user ++ && bfd_get_reloc_upper_bound (ibfd, isection) < 1) ++ { ++ non_fatal (_("output section %s's alignment does not match its VMA"), name); ++ } ++ ++ /* Similar check for a non-aligned LMA. ++ FIXME: Since this is only an LMA, maybe it does not matter if ++ it is not aligned ? */ ++ if (osection->lma & ((1 << alignment) - 1) ++ && alignment != bfd_section_alignment (isection) ++ && change_section_address == 0 ++ && ! lma_set_by_user ++ && bfd_get_reloc_upper_bound (ibfd, isection) < 1) ++ { ++ non_fatal (_("output section %s's alignment does not match its LMA"), name); ++ } ++ + /* Copy merge entity size. */ + osection->entsize = isection->entsize; + +@@ -5530,15 +5624,8 @@ copy_main (int argc, char *argv[]) + fatal (_("bad format for --set-section-alignment: numeric argument needed")); + + /* Convert integer alignment into a power-of-two alignment. */ +- palign = 0; +- while ((align & 1) == 0) +- { +- align >>= 1; +- ++palign; +- } +- +- if (align != 1) +- /* Number has more than on 1, i.e. wasn't a power of 2. */ ++ palign = power_of_two (align); ++ if (palign == -1) + fatal (_("bad format for --set-section-alignment: alignment is not a power of two")); + + /* Add the alignment setting to the section list. */ +@@ -5751,6 +5838,11 @@ copy_main (int argc, char *argv[]) + case OPTION_PE_SECTION_ALIGNMENT: + pe_section_alignment = parse_vma (optarg, + "--section-alignment"); ++ if (power_of_two (pe_section_alignment) == -1) ++ { ++ non_fatal (_("--section-alignment argument is not a power of two: %s - ignoring"), optarg); ++ pe_section_alignment = (bfd_vma) -1; ++ } + break; + + case OPTION_SUBSYSTEM: +diff -rup binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.35.2/binutils/testsuite/binutils-all/objcopy.exp +--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2024-04-03 11:32:37.781595765 +0100 ++++ binutils-2.35.2/binutils/testsuite/binutils-all/objcopy.exp 2024-04-03 11:33:00.878625614 +0100 +@@ -1342,6 +1342,7 @@ objcopy_remove_relocations_from_executab + run_dump_test "pr23633" + + run_dump_test "set-section-alignment" ++run_dump_test "section-alignment" + + setup_xfail "hppa*-*-*" + setup_xfail "sh-*-coff*" +--- /dev/null 2024-06-27 08:39:51.717818400 +0100 ++++ binutils-2.35.2/binutils/testsuite/binutils-all/section-alignment.d 2024-06-27 15:43:00.626529058 +0100 +@@ -0,0 +1,9 @@ ++#source: pr23633.s ++#PROG: objcopy ++#objcopy: --section-alignment=512 ++#objdump: -P sections ++#target: [is_pecoff_format] ++ ++#... ++.* Align: 512.* ++#pass +--- binutils.orig/binutils/objcopy.c 2024-07-25 15:30:49.380323472 +0100 ++++ binutils-2.35.2/binutils/objcopy.c 2024-07-25 15:33:35.779466989 +0100 +@@ -4147,6 +4147,7 @@ setup_section (bfd *ibfd, sec_ptr isecti + if (p != NULL) + alignment = p->alignment; + else if (pe_section_alignment != (bfd_vma) -1 ++ && bfd_get_flavour (ibfd) == bfd_target_coff_flavour + && bfd_get_flavour (obfd) == bfd_target_coff_flavour) + { + alignment = power_of_two (pe_section_alignment); +--- binutils.orig/bfd/coffcode.h 2024-08-12 09:44:06.041128327 +0100 ++++ binutils-2.35.2/bfd/coffcode.h 2024-08-12 11:13:58.209619284 +0100 +@@ -2942,7 +2942,7 @@ coff_compute_section_file_positions (bfd + #endif + + #ifdef COFF_IMAGE_WITH_PE +- int page_size; ++ unsigned int page_size; + + if (coff_data (abfd)->link_info + || (pe_data (abfd) && pe_data (abfd)->pe_opthdr.FileAlignment)) +@@ -2953,22 +2953,12 @@ coff_compute_section_file_positions (bfd + This repairs 'ld -r' for arm-wince-pe target. */ + if (page_size == 0) + page_size = 1; +- +- /* PR 17512: file: 0ac816d3. */ +- if (page_size < 0) +- { +- bfd_set_error (bfd_error_file_too_big); +- _bfd_error_handler +- /* xgettext:c-format */ +- (_("%pB: page size is too large (0x%x)"), abfd, page_size); +- return FALSE; +- } + } + else + page_size = PE_DEF_FILE_ALIGNMENT; + #else + #ifdef COFF_PAGE_SIZE +- int page_size = COFF_PAGE_SIZE; ++ unsigned int page_size = COFF_PAGE_SIZE; + #endif + #endif + +@@ -3050,10 +3040,11 @@ coff_compute_section_file_positions (bfd + bfd_size_type amt; + + #ifdef COFF_PAGE_SIZE +- /* Clear D_PAGED if section alignment is smaller than +- COFF_PAGE_SIZE. */ +- if (pe_data (abfd)->pe_opthdr.SectionAlignment < COFF_PAGE_SIZE) +- abfd->flags &= ~D_PAGED; ++ /* Clear D_PAGED if section / file alignment aren't suitable for ++ paging at COFF_PAGE_SIZE granularity. */ ++ if (pe_data (abfd)->pe_opthdr.SectionAlignment < COFF_PAGE_SIZE ++ || page_size < COFF_PAGE_SIZE) ++ abfd->flags &= ~D_PAGED; + #endif + + count = 0; +@@ -3173,7 +3164,11 @@ coff_compute_section_file_positions (bfd + padding the previous section up if necessary. */ + old_sofar = sofar; + ++#ifdef COFF_IMAGE_WITH_PE ++ sofar = BFD_ALIGN (sofar, page_size); ++#else + sofar = BFD_ALIGN (sofar, 1 << current->alignment_power); ++#endif + + #ifdef RS6000COFF_C + /* Make sure the file offset and the vma of .text/.data are at the +@@ -3210,7 +3205,6 @@ coff_compute_section_file_positions (bfd + if (previous != NULL) + previous->size += sofar - old_sofar; + } +- + #endif + + /* In demand paged files the low order bits of the file offset +@@ -3221,7 +3215,7 @@ coff_compute_section_file_positions (bfd + sofar += (current->vma - (bfd_vma) sofar) % page_size; + #endif + current->filepos = sofar; +- ++ + #ifdef COFF_IMAGE_WITH_PE + /* Set the padded size. */ + current->size = (current->size + page_size - 1) & -page_size; +@@ -3244,7 +3238,11 @@ coff_compute_section_file_positions (bfd + else + { + old_sofar = sofar; ++#ifdef COFF_IMAGE_WITH_PE ++ sofar = BFD_ALIGN (sofar, page_size); ++#else + sofar = BFD_ALIGN (sofar, 1 << current->alignment_power); ++#endif + align_adjust = sofar != old_sofar; + current->size += sofar - old_sofar; + } +--- binutils.orig/binutils/testsuite/binutils-all/aarch64/pei-aarch64-little.d 2024-08-14 13:10:49.565104090 +0100 ++++ binutils-2.35.2/binutils/testsuite/binutils-all/aarch64/pei-aarch64-little.d 2024-08-14 13:15:44.378037490 +0100 +@@ -12,5 +12,5 @@ start address 0x0000000000000000 + + Sections: + Idx Name Size VMA LMA File off Algn +- 0 \.text 00000030 0[^ ]+ 0[^ ]+ 0[^ ]+ 2\*\*12 ++ 0 \.text 00000030 0[^ ]+ 0[^ ]+ 0[^ ]+ 2\*\*2 + CONTENTS, ALLOC, LOAD, READONLY, CODE diff --git a/SOURCES/binutils-prune-lto-messages.patch b/SOURCES/binutils-prune-lto-messages.patch new file mode 100644 index 0000000..c07458c --- /dev/null +++ b/SOURCES/binutils-prune-lto-messages.patch @@ -0,0 +1,16 @@ +--- binutils.orig/binutils/testsuite/lib/binutils-common.exp 2024-06-27 12:43:48.892438898 +0100 ++++ binutils-2.35.2/binutils/testsuite/lib/binutils-common.exp 2024-06-27 12:45:12.134877825 +0100 +@@ -523,8 +523,13 @@ proc prune_warnings_extra { text } { + # The "\\1" is to try to preserve a "\n" but only if necessary. + regsub -all "(^|\n)(\[^\n\]*: warning:\[^\n\]*unsupported GNU_PROPERTY_TYPE\[^\n\]*\n?)+" $text "\\1" text + } ++ + # PR binutils/23898: It is OK to have gaps in build notes. + regsub -all "(^|\n)(\[^\n\]*: Warning: Gap in build notes detected from\[^\n\]*\n?)+" $text "\\1" text ++ ++ # Ignore LTO warnings triggered by configuring with --enable-pgo-build=lto. ++ regsub -all "(^|\n)(\[^\n\]*lto-wrapper: warning: using serial compilation of \[0-9\]+ LTRANS jobs\[^\n\]*\n?)+" $text "\\1" text ++ + return $text + } + diff --git a/SOURCES/binutils-relro-padding.patch b/SOURCES/binutils-relro-padding.patch new file mode 100644 index 0000000..73d3615 --- /dev/null +++ b/SOURCES/binutils-relro-padding.patch @@ -0,0 +1,15 @@ +--- binutils.orig/bfd/elf.c 2024-07-25 09:01:36.091804849 +0100 ++++ binutils-2.35.2/bfd/elf.c 2024-07-25 09:02:22.645006725 +0100 +@@ -2759,6 +2759,12 @@ static const struct bfd_elf_special_sect + { STRING_COMMA_LEN (".rodata"), -2, SHT_PROGBITS, SHF_ALLOC }, + { STRING_COMMA_LEN (".rodata1"), 0, SHT_PROGBITS, SHF_ALLOC }, + { STRING_COMMA_LEN (".rela"), -1, SHT_RELA, 0 }, ++ /* .relro_padding is generated by lld. It should not be confused with a ++ reloc containing section, because otherwise elf_fake_sections() will ++ set the entsize to 8, which may not be an actual multiple of the ++ section's size. ++ Note - this entry must appear before the ".rel" entry below. */ ++ { STRING_COMMA_LEN (".relro_padding"), 0, SHT_NOBITS, SHF_ALLOC | SHF_WRITE }, + { STRING_COMMA_LEN (".rel"), -1, SHT_REL, 0 }, + { NULL, 0, 0, 0, 0 } + }; diff --git a/SOURCES/binutils-relro.patch b/SOURCES/binutils-relro.patch new file mode 100644 index 0000000..a07c221 --- /dev/null +++ b/SOURCES/binutils-relro.patch @@ -0,0 +1,140 @@ +diff -rup binutils.orig/ld/ldexp.c binutils-2.35.2/ld/ldexp.c +--- binutils.orig/ld/ldexp.c 2024-07-11 14:49:42.844809806 +0100 ++++ binutils-2.35.2/ld/ldexp.c 2024-07-11 15:36:22.841888968 +0100 +@@ -468,7 +468,8 @@ fold_segment_align (seg_align_type *seg, + } + else + { +- expld.result.value += expld.dot & (maxpage - 1); ++ if (!link_info.relro) ++ expld.result.value += expld.dot & (maxpage - 1); + if (seg->phase == exp_seg_done) + { + /* OK. */ +@@ -477,8 +478,9 @@ fold_segment_align (seg_align_type *seg, + { + seg->phase = exp_seg_align_seen; + seg->base = expld.result.value; +- seg->pagesize = commonpage; ++ seg->commonpagesize = commonpage; + seg->maxpagesize = maxpage; ++ seg->relropagesize = maxpage; + seg->relro_end = 0; + } + else +@@ -507,10 +509,10 @@ fold_segment_relro_end (seg_align_type * + seg->relro_end = lhs->value + expld.result.value; + + if (seg->phase == exp_seg_relro_adjust +- && (seg->relro_end & (seg->pagesize - 1))) ++ && (seg->relro_end & (seg->relropagesize - 1))) + { +- seg->relro_end += seg->pagesize - 1; +- seg->relro_end &= ~(seg->pagesize - 1); ++ seg->relro_end += seg->relropagesize - 1; ++ seg->relro_end &= ~(seg->relropagesize - 1); + expld.result.value = seg->relro_end - expld.result.value; + } + else +Only in binutils-2.35.2/ld: ldexp.c.orig +diff -rup binutils.orig/ld/ldexp.h binutils-2.35.2/ld/ldexp.h +--- binutils.orig/ld/ldexp.h 2024-07-11 14:49:42.845809808 +0100 ++++ binutils-2.35.2/ld/ldexp.h 2024-07-11 15:36:22.841888968 +0100 +@@ -136,7 +136,10 @@ enum relro_enum { + typedef struct { + enum phase_enum phase; + +- bfd_vma base, relro_offset, relro_end, end, pagesize, maxpagesize; ++ bfd_vma base, relro_offset, relro_end, end; ++ /* MAXPAGESIZE and COMMMONPAGESIZE as passed to DATA_SEGMENT_ALIGN. ++ relropagesize sets the alignment of the end of the relro segment. */ ++ bfd_vma maxpagesize, commonpagesize, relropagesize; + + enum relro_enum relro; + +diff -rup binutils.orig/ld/ldlang.c binutils-2.35.2/ld/ldlang.c +--- binutils.orig/ld/ldlang.c 2024-07-11 14:49:42.968810127 +0100 ++++ binutils-2.35.2/ld/ldlang.c 2024-07-11 15:36:22.842888972 +0100 +@@ -6251,12 +6251,12 @@ lang_size_segment (seg_align_type *seg) + a page could be saved in the data segment. */ + bfd_vma first, last; + +- first = -seg->base & (seg->pagesize - 1); +- last = seg->end & (seg->pagesize - 1); ++ first = -seg->base & (seg->commonpagesize - 1); ++ last = seg->end & (seg->commonpagesize - 1); + if (first && last +- && ((seg->base & ~(seg->pagesize - 1)) +- != (seg->end & ~(seg->pagesize - 1))) +- && first + last <= seg->pagesize) ++ && ((seg->base & ~(seg->commonpagesize - 1)) ++ != (seg->end & ~(seg->commonpagesize - 1))) ++ && first + last <= seg->commonpagesize) + { + seg->phase = exp_seg_adjust; + return TRUE; +@@ -6273,8 +6273,7 @@ lang_size_relro_segment_1 (seg_align_typ + asection *sec; + + /* Compute the expected PT_GNU_RELRO/PT_LOAD segment end. */ +- relro_end = ((seg->relro_end + seg->pagesize - 1) +- & ~(seg->pagesize - 1)); ++ relro_end = (seg->relro_end + seg->relropagesize - 1) & -seg->relropagesize; + + /* Adjust by the offset arg of XXX_SEGMENT_RELRO_END. */ + desired_end = relro_end - seg->relro_offset; +Only in binutils-2.35.2/ld: ldlang.c.orig +diff -rup binutils.orig/ld/emultempl/elf-x86.em binutils-2.35.2/ld/emultempl/elf-x86.em +--- binutils.orig/ld/emultempl/elf-x86.em 2024-07-12 10:24:52.597889981 +0100 ++++ binutils-2.35.2/ld/emultempl/elf-x86.em 2024-07-12 10:25:12.134935407 +0100 +@@ -33,6 +33,7 @@ static struct elf_linker_x86_params para + static void + elf_x86_create_output_section_statements (void) + { ++ config.relro_use_commonpagesize = TRUE; + _bfd_elf_linker_x86_set_options (&link_info, ¶ms); + } + +diff -rup binutils.orig/ld/ld.h binutils-2.35.2/ld/ld.h +--- binutils.orig/ld/ld.h 2024-07-12 10:24:52.620890034 +0100 ++++ binutils-2.35.2/ld/ld.h 2024-07-12 10:25:12.135935409 +0100 +@@ -280,6 +280,10 @@ typedef struct + /* If set, code and non-code sections should never be in one segment. */ + bfd_boolean separate_code; + ++ /* TRUE if the end of the relro segment should be aligned to ++ COMMONPAGESIZE rather than MAXPAGESIZE. */ ++ bfd_boolean relro_use_commonpagesize; ++ + /* The rpath separation character. Usually ':'. */ + char rpath_separator; + +Only in binutils-2.35.2/ld: ld.h.orig +diff -rup binutils.orig/ld/ldexp.c binutils-2.35.2/ld/ldexp.c +--- binutils.orig/ld/ldexp.c 2024-07-12 10:24:53.077891097 +0100 ++++ binutils-2.35.2/ld/ldexp.c 2024-07-12 10:25:12.136935412 +0100 +@@ -480,7 +480,10 @@ fold_segment_align (seg_align_type *seg, + seg->base = expld.result.value; + seg->commonpagesize = commonpage; + seg->maxpagesize = maxpage; +- seg->relropagesize = maxpage; ++ if (config.relro_use_commonpagesize) ++ seg->relropagesize = commonpage; ++ else ++ seg->relropagesize = maxpage; + seg->relro_end = 0; + } + else +Only in binutils-2.35.2/ld: ldexp.c.orig +diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr18176.d binutils-2.35.2/ld/testsuite/ld-x86-64/pr18176.d +--- binutils.orig/ld/testsuite/ld-x86-64/pr18176.d 2024-07-12 10:24:52.988890890 +0100 ++++ binutils-2.35.2/ld/testsuite/ld-x86-64/pr18176.d 2024-07-12 10:25:12.136935412 +0100 +@@ -3,6 +3,7 @@ + #ld: -melf_x86_64 -shared -z relro -T pr18176.t -z max-page-size=0x200000 -z common-page-size=0x1000 + #readelf: -l --wide + #target: x86_64-*-linux* ++#xfail: *-*-* + + #... + GNU_RELRO 0x04bd17 0x000000000024bd17 0x000000000024bd17 0x0022e9 0x0022e9 R 0x1 +Only in binutils-2.35.2/ld/testsuite/ld-x86-64: pr18176.d.orig diff --git a/SPECS/binutils.spec b/SPECS/binutils.spec index dc253bf..b4c60ec 100644 --- a/SPECS/binutils.spec +++ b/SPECS/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: binutils%{?_with_debug:-debug} Version: 2.35.2 -Release: 43%{?dist} +Release: 54%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -445,6 +445,26 @@ Patch66: binutils-aarch64-flagm.patch # Lifetime: Fixed in 2.38 Patch67: binutils-verdef.patch +# Purpose: Make objcopy's --section-alignment option also affect sections. +# Lifetime: Fixed in 2.43 +Patch68: binutils-objcopy-pe-section-align.patch + +# Purpose: Fix handling of .gnu.debuglto_.debug_* sections. +# Lifetime: Fixed in 2.37 +Patch69: binutils-gnu.debuglto_.patch + +# Purpose: Remove messages from gcc lto-wrapper which can confuse testsuite results. +# Lifetime: Fixed in 2.37 +Patch70: binutils-prune-lto-messages.patch + +# Purpose: Remove the gap between LOAD segments when using RELRO +# Lifetime: Fixed in 2.38 +Patch71: binutils-relro.patch + +# Purpose: Stop the BFD library from treating the .relro-padding section as a REL section. +# Lifetime: Fixed in 2.44 +Patch72: binutils-relro-padding.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -1285,6 +1305,39 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Wed Aug 14 2024 Nick Clifton - 2.35.2-54 +- Re fix AArch64 EFI test after applying previous delta. (RHEL-39953) + +* Mon Aug 12 2024 Nick Clifton - 2.35.2-53 +- Backport commit bc5baa9f13ff to ensure that objcopy does not loose the minimum section alignment for PE binaries. (RHEL-30268) + +* Thu Jul 25 2024 Nick Clifton - 2.35.2-52 +- Backport commit 6fde04116b4b to stop objcopy from crashing when copying non-PE binaries into a PE output. (RHEL-48882) + +* Thu Jul 25 2024 Nick Clifton - 2.35.2-51 +- Backport commit 88141209e25ce19473ec07d7aac09cc68f06a630 to fix stripping lld linked binaries. (RHEL-50536) + +* Fri Jul 12 2024 Nick Clifton - 2.35.2-50 +- Additional patch (commit 31b4d3a16f200bf04db8439a63b72bba7af4e1be). (RHEL-45873) + +* Thu Jul 11 2024 Nick Clifton - 2.35.2-49 +- Remove the gap between LOAD segments when using RELRO. (RHEL-45873) + +* Thu Jun 27 2024 Nick Clifton - 2.35.2-48 +- Add missing test driver for section-alignment patch. (RHEL-30268) + +* Thu Jun 27 2024 Nick Clifton - 2.35.2-47 +- Prune messages from gcc's lto-wrapper which can confure testsuite tests. (RHEL-45264) + +* Thu Jun 20 2024 Nick Clifton - 2.35.2-46 +- Fix handling of .gnu.debuglto_.debug_* sections. (RHEL-43758) + +* Tue Jun 04 2024 Nick Clifton - 2.35.2-45 +- Fix AArch64 EFI test. (RHEL-39953) + +* Thu Jan 25 2024 Nick Clifton - 2.35.2-44 +- Make objcopy's --section-alignment option also affect sections. (RHEL-30268) + * Thu Jan 25 2024 Nick Clifton - 2.35.2-43 - Do not set version info on unversion symbols. (RHEL-22601)