Backport commit bc5baa9f13ff to ensure that objcopy does not loose the minimum section alignment for PE binaries.
Resolves: RHEL-30268
This commit is contained in:
parent
74fb4dd099
commit
e0c487350c
@ -262,3 +262,95 @@ diff -rup binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.3
|
||||
&& 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;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
Summary: A GNU collection of binary utilities
|
||||
Name: binutils%{?_with_debug:-debug}
|
||||
Version: 2.35.2
|
||||
Release: 52%{?dist}
|
||||
Release: 53%{?dist}
|
||||
License: GPLv3+
|
||||
URL: https://sourceware.org/binutils
|
||||
|
||||
@ -1305,6 +1305,9 @@ exit 0
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
%changelog
|
||||
* Mon Aug 12 2024 Nick Clifton <nickc@redhat.com> - 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 <nickc@redhat.com> - 2.35.2-52
|
||||
- Backport commit 6fde04116b4b to stop objcopy from crashing when copying non-PE binaries into a PE output. (RHEL-48882)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user