aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfd.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-10-14 21:59:23 +1030
committerAlan Modra <amodra@gmail.com>2022-10-16 13:54:50 +1030
commit206e9791cb09459bf92603428370c16bfde282ac (patch)
tree697bb43e78ec7616c659a870e3f21043b3d1e5a7 /bfd/bfd.c
parent4f722d4a721aaee24323138fc3b564ad1545af93 (diff)
downloadgdb-206e9791cb09459bf92603428370c16bfde282ac.zip
gdb-206e9791cb09459bf92603428370c16bfde282ac.tar.gz
gdb-206e9791cb09459bf92603428370c16bfde282ac.tar.bz2
zlib-gabi to zstd woes
So we had a zlib-gabi .debug_info section that increased in size with zstd, so much so that it was better to leave the section uncompressed. Things went horribly wrong when the section was read again later. The section was read again off disk using the uncompressed size. So you get the zlib section again with some garbage at the end. Fix that particular problem by setting the section flag SEC_IN_MEMORY. Any future read will get sec->contents. Also, if the section is to be left uncompressed, the input SHF_COMPRESSED flag needs to be reset otherwise objcopy will copy it to output. Finally, bfd_convert_section_contents needed a small update to handle zstd compressed sections, and I've deleted bfd_cache_section_contents. * bfd.c (bfd_convert_section_contents): Handle zstd. * compress.c (bfd_compress_section_contents): When section contents are uncompressed set SEC_IN_MEMORY flag, compress_status to COMRESS_SECTION_NONE, and clear SHF_COMPRESSED. Set SEC_IN_MEMORY for compressed contents. (bfd_get_full_section_contents): Don't check section size against file size when SEC_IN_MEMORY. (bfd_cache_section_contents): Delete function. * elf32-arm.c (elf32_arm_get_synthetic_symtab): Expand bfd_cache_section_contents here. * bfd-in2.h: Regenerate.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r--bfd/bfd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 5f2033b..4fca825 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2801,14 +2801,14 @@ bfd_convert_section_contents (bfd *ibfd, sec_ptr isec, bfd *obfd,
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);