]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
BFD: Exclude sections with no content from compress check.
authorTamar Christina <tamar.christina@arm.com>
Tue, 21 Apr 2020 14:16:21 +0000 (15:16 +0100)
committerTamar Christina <tamar.christina@arm.com>
Tue, 21 Apr 2020 14:23:59 +0000 (15:23 +0100)
The check in bfd_get_full_section_contents is trying to check that we don't
allocate more space for a section than the size of the section is on disk.

Previously we excluded linker created sections since they didn't have a size on
disk.  However we also need to exclude sections with no content as well such as
the BSS section.  Space for these would not have been allocated by the assembler
and so the check would incorrectly fail.

bfd/ChangeLog:

PR binutils/24753
* compress.c (bfd_get_full_section_contents): Exclude sections with no
content.

gas/ChangeLog:

PR binutils/24753
* testsuite/gas/arm/pr24753.d: New test.
* testsuite/gas/arm/pr24753.s: New test.

(cherry picked from commit c36876fe5b5bac1c404ab2ca82bfbfb2ed9a2717)

bfd/ChangeLog
bfd/compress.c
gas/ChangeLog
gas/testsuite/gas/arm/pr24753.d [new file with mode: 0644]
gas/testsuite/gas/arm/pr24753.s [new file with mode: 0644]

index 1b57d6b071c4ff3189ce816066e33f09884b7757..ca87f744a3d3b9e10d6f8de233a0042fa89a477a 100644 (file)
@@ -1,3 +1,12 @@
+2020-04-21  Tamar Christina  <tamar.christina@arm.com>
+
+       Backport from mainline.
+       2020-04-21  Tamar Christina  <tamar.christina@arm.com>
+
+       PR binutils/24753
+       * compress.c (bfd_get_full_section_contents): Exclude sections with no
+       content.
+
 2020-04-08  Tamar Christina  <tamar.christina@arm.com>
 
        Backport from mainline.
index ce6bb2beaee689d0eb700f69a08e7eb5fe92ab5c..728ba39dfbf748c688bb8c9f1a8d28c5a1ae9bd0 100644 (file)
@@ -255,6 +255,9 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
              /* PR 24753: Linker created sections can be larger than
                 the file size, eg if they are being used to hold stubs.  */
              && (bfd_section_flags (sec) & SEC_LINKER_CREATED) == 0
+             /* PR 24753: Sections which have no content should also be
+                excluded as they contain no size on disk.  */
+             && (bfd_section_flags (sec) & SEC_HAS_CONTENTS) != 0
              /* The MMO file format supports its own special compression
                 technique, but it uses COMPRESS_SECTION_NONE when loading
                 a section's contents.  */
index 4ad599ae7949d4f70de0017b9d304f41555ed5e2..3ebb0aa53efb1c4b4cab8a888b37ff26debc79ab 100644 (file)
@@ -1,3 +1,12 @@
+2020-04-21  Tamar Christina  <tamar.christina@arm.com>
+
+       Backport from mainline.
+       2020-04-21  Tamar Christina  <tamar.christina@arm.com>
+
+       PR binutils/24753
+       * testsuite/gas/arm/pr24753.d: New test.
+       * testsuite/gas/arm/pr24753.s: New test.
+
 2020-03-13  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        Backport from mainline.
diff --git a/gas/testsuite/gas/arm/pr24753.d b/gas/testsuite/gas/arm/pr24753.d
new file mode 100644 (file)
index 0000000..01990d1
--- /dev/null
@@ -0,0 +1,7 @@
+#skip: *-*-pe *-*-wince *-*-vxworks
+#objdump: -d
+#name: PR24753: Don't error on sections with no content size mismatch with file
+
+.*: +file format .*arm.*
+
+#...
diff --git a/gas/testsuite/gas/arm/pr24753.s b/gas/testsuite/gas/arm/pr24753.s
new file mode 100644 (file)
index 0000000..5ba33fd
--- /dev/null
@@ -0,0 +1,12 @@
+.text
+.global _start
+_start:
+       nop
+
+.section .text2, "ax", %progbits
+_func:
+       nop
+
+.bss
+.fill 0x8000
+