diff --git a/bfd/compress.c b/bfd/compress.c index cba281dca4..00ff10df22 100644 --- a/bfd/compress.c +++ b/bfd/compress.c @@ -253,6 +253,10 @@ 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 created by the + linker. */ + && (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/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em index 4c13f26f4e..93f60a9b61 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);