bool bfd_get_full_section_contents
(bfd *abfd, asection *section, bfd_byte **ptr);
-void bfd_cache_section_contents
- (asection *sec, void *contents);
-
bool bfd_is_section_compressed_info
(bfd *abfd, asection *section,
int *compression_header_size_p,
if (ohdr_size == sizeof (Elf32_External_Chdr))
{
Elf32_External_Chdr *echdr = (Elf32_External_Chdr *) contents;
- bfd_put_32 (obfd, ELFCOMPRESS_ZLIB, &echdr->ch_type);
+ bfd_put_32 (obfd, chdr.ch_type, &echdr->ch_type);
bfd_put_32 (obfd, chdr.ch_size, &echdr->ch_size);
bfd_put_32 (obfd, chdr.ch_addralign, &echdr->ch_addralign);
}
else
{
Elf64_External_Chdr *echdr = (Elf64_External_Chdr *) contents;
- bfd_put_32 (obfd, ELFCOMPRESS_ZLIB, &echdr->ch_type);
+ bfd_put_32 (obfd, chdr.ch_type, &echdr->ch_type);
bfd_put_32 (obfd, 0, &echdr->ch_reserved);
bfd_put_64 (obfd, chdr.ch_size, &echdr->ch_size);
bfd_put_64 (obfd, chdr.ch_addralign, &echdr->ch_addralign);
free (input_buffer);
bfd_set_section_alignment (sec, uncompressed_alignment_pow);
sec->contents = buffer;
- sec->compress_status = COMPRESS_SECTION_DONE;
+ sec->flags |= SEC_IN_MEMORY;
+ sec->compress_status = COMPRESS_SECTION_NONE;
sec->size = uncompressed_size;
input_buffer = buffer;
}
if (compressed_size >= uncompressed_size)
{
memcpy (buffer, input_buffer, uncompressed_size);
+ elf_section_flags (sec) &= ~SHF_COMPRESSED;
sec->compress_status = COMPRESS_SECTION_NONE;
}
else
sec->compress_status = COMPRESS_SECTION_DONE;
}
sec->contents = buffer;
+ sec->flags |= SEC_IN_MEMORY;
free (input_buffer);
return uncompressed_size;
}
ufile_ptr filesize = bfd_get_file_size (abfd);
if (filesize > 0
&& filesize < sz
+ && (bfd_section_flags (sec) & SEC_IN_MEMORY) == 0
/* 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
}
}
-/*
-FUNCTION
- bfd_cache_section_contents
-
-SYNOPSIS
- void bfd_cache_section_contents
- (asection *sec, void *contents);
-
-DESCRIPTION
- Stash @var(contents) so any following reads of @var(sec) do
- not need to decompress again.
-*/
-
-void
-bfd_cache_section_contents (asection *sec, void *contents)
-{
- if (sec->compress_status == DECOMPRESS_SECTION_ZLIB
- || sec->compress_status == DECOMPRESS_SECTION_ZSTD)
- sec->compress_status = COMPRESS_SECTION_DONE;
- sec->contents = contents;
- sec->flags |= SEC_IN_MEMORY;
-}
-
/*
FUNCTION
bfd_is_section_compressed_info
data = plt->contents;
if (data == NULL)
{
- if (!bfd_get_full_section_contents (abfd, (asection *) plt, &data) || data == NULL)
+ if (!bfd_get_full_section_contents (abfd, plt, &data)
+ || data == NULL)
return -1;
- bfd_cache_section_contents ((asection *) plt, data);
+ plt->contents = data;
+ plt->flags |= SEC_IN_MEMORY;
}
count = relplt->size / hdr->sh_entsize;