[binutils-gdb] Fix a bug recently introduced to the linker where it would complain about a section being larger tha

Nick Clifton nickc@sourceware.org
Tue Jul 2 13:15:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=125f83f66c10c89530d011f4f81324b1f43afcda

commit 125f83f66c10c89530d011f4f81324b1f43afcda
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Jul 2 14:14:13 2019 +0100

    Fix a bug recently introduced to the linker where it would complain about a section being larger than a file, even if the section was artificial.
    
    	PR 24753
    bfd	* compress.c (bfd_get_full_section_contents): Do not complain
    	about linker created sections that are larger than the file size.
    
    ld	* emultempl/aarch64elf.em (_aarch64_add_stub_section): Include the
    	LINKER_CREATED section flag when creating the stub section.

Diff:
---
 bfd/ChangeLog              | 6 ++++++
 bfd/compress.c             | 3 +++
 ld/ChangeLog               | 6 ++++++
 ld/emultempl/aarch64elf.em | 2 +-
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index af25e43..063af9c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-02  Nick Clifton  <nickc@redhat.com>
+
+	PR 24753
+	* compress.c (bfd_get_full_section_contents): Do not complain
+	about linker created sections that are larger than the file size.
+
 2019-07-02  Christophe Lyon  <christophe.lyon@linaro.org>
 
 	* bfd/elf32-arm.c (CMSE_STUB_NAME): New define.
diff --git a/bfd/compress.c b/bfd/compress.c
index cba281d..32de099 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -253,6 +253,9 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
 	  ufile_ptr filesize = bfd_get_file_size (abfd);
 	  if (filesize > 0
 	      && filesize < sz
+	      /* PR 24753: Linker created sections can be larger than
+		 the file size, eg if they are being used to hold stubs.  */
+	      && (bfd_get_section_flags (abfd, sec) & SEC_LINKER_CREATED) == 0
 	      /* The MMO file format supports its own special compression
 		 technique, but it uses COMPRESS_SECTION_NONE when loading
 		 a section's contents.  */
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 0f06196..d4916f4 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-02  Nick Clifton  <nickc@redhat.com>
+
+	PR 24753
+	* emultempl/aarch64elf.em (_aarch64_add_stub_section): Include the
+	LINKER_CREATED section flag when creating the stub section.
+
 2019-07-02  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>
 
 	* testsuite/ld-arm/arm-elf.exp: Add tests.
diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em
index 4c13f26..93f60a9 100644
--- a/ld/emultempl/aarch64elf.em
+++ b/ld/emultempl/aarch64elf.em
@@ -169,7 +169,7 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char *stub_sec_name,
   lang_output_section_statement_type *os;
   struct hook_stub_info info;
 
-  flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_LINKER_CREATED
 	   | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP);
   stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd,
 						 stub_sec_name, flags);



More information about the Binutils-cvs mailing list