aboutsummaryrefslogtreecommitdiff
path: root/gas/write.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-05-14 15:58:51 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-05-14 16:02:08 -0700
commitdab394de9e41de54df5e2310e081e1c550326f5b (patch)
treefbdbe4f564baa35e7fb4bea28416a531fcb9d916 /gas/write.c
parent61a7418ccb7c2de12d4c4df79e193f32db938a11 (diff)
downloadgdb-dab394de9e41de54df5e2310e081e1c550326f5b.zip
gdb-dab394de9e41de54df5e2310e081e1c550326f5b.tar.gz
gdb-dab394de9e41de54df5e2310e081e1c550326f5b.tar.bz2
Don't add the zlib header to SHF_COMPRESSED section
In a SHF_COMPRESSED compressed section, the raw compressed data should begin immediately after the compression header. This patch removes the extra zlib header from the SHF_COMPRESSED section. bfd/ * bfd.c (bfd_update_compression_header): Also write the zlib header if the SHF_COMPRESSED bit cleared.. (bfd_check_compression_header): Return the uncompressed size. * compress.c (decompress_contents): Don't skip the zlib header. (bfd_compress_section_contents): Properly handle ELFCOMPRESS_ZLIB, which doesn't have the zlib header. (bfd_init_section_decompress_status): Likewise. (bfd_get_full_section_contents): Updated. (bfd_is_section_compressed): Likewise. (bfd_is_section_compressed_with_header): Return the uncompressed size. * elf.c (_bfd_elf_make_section_from_shdr): Updated. * bfd-in2.h: Regenerated. binutils/ * readelf.c (uncompress_section_contents): Add a parameter for uncompressed size. Don't check the zlib header. (load_specific_debug_section): Updated. binutils/testsuite/ * binutils-all/compress.exp: Replace "$OBJDUMP -s -j .debug_info" with "$OBJDUMP -W". * binutils-all/libdw2-compressedgabi.out: Updated. gas/ 2015-05-14 H.J. Lu <hongjiu.lu@intel.com> * write.c (compress_debug): Don't write the zlib header, which is handled by bfd_update_compression_header.
Diffstat (limited to 'gas/write.c')
-rw-r--r--gas/write.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/gas/write.c b/gas/write.c
index bc76962..894b271 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1414,8 +1414,6 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
int x;
flagword flags = bfd_get_section_flags (abfd, sec);
unsigned int header_size, compression_header_size;
- /* Maximimum compression header is 24 bytes. */
- bfd_byte compression_header[24];
if (seginfo == NULL
|| sec->size < 32
@@ -1431,14 +1429,20 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
return;
if (flag_compress_debug == COMPRESS_DEBUG_GABI_ZLIB)
- stdoutput->flags |= BFD_COMPRESS | BFD_COMPRESS_GABI;
+ {
+ stdoutput->flags |= BFD_COMPRESS | BFD_COMPRESS_GABI;
+ compression_header_size
+ = bfd_get_compression_header_size (stdoutput, NULL);
+ header_size = compression_header_size;
+ }
else
- stdoutput->flags |= BFD_COMPRESS;
- compression_header_size
- = bfd_get_compression_header_size (stdoutput, NULL);
+ {
+ stdoutput->flags |= BFD_COMPRESS;
+ compression_header_size = 0;
+ header_size = 12;
+ }
- /* Create a new frag to contain the "ZLIB" header. */
- header_size = 12 + compression_header_size;
+ /* Create a new frag to contain the compression header. */
first_newf = frag_alloc (ob);
if (obstack_room (ob) < header_size)
first_newf = frag_alloc (ob);
@@ -1533,11 +1537,6 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
if (compressed_size >= uncompressed_size)
return;
- if (compression_header_size)
- memcpy (header, compression_header, compression_header_size);
- memcpy (header + compression_header_size, "ZLIB", 4);
- bfd_putb64 (uncompressed_size, header + compression_header_size + 4);
-
/* Replace the uncompressed frag list with the compressed frag list. */
seginfo->frchainP->frch_root = first_newf;
seginfo->frchainP->frch_last = last_newf;