aboutsummaryrefslogtreecommitdiff
path: root/bfd/compress.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-04-06 09:01:43 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-04-06 09:02:52 -0700
commit4aa90cc007ff1e7c6525b3f5e573e3a4242091fa (patch)
treec2facfd8e1e98ecf2064cd76e8d8f4b563b49436 /bfd/compress.c
parentfd5136e57ca26072fa015a7563ba019b1b2b7d73 (diff)
downloadgdb-4aa90cc007ff1e7c6525b3f5e573e3a4242091fa.zip
gdb-4aa90cc007ff1e7c6525b3f5e573e3a4242091fa.tar.gz
gdb-4aa90cc007ff1e7c6525b3f5e573e3a4242091fa.tar.bz2
Use bfd_putb64/bfd_getb64
bfd/ * compress.c (get_uncompressed_size): Removed. (bfd_compress_section_contents): Use bfd_putb64 to write uncompressed section size. (bfd_init_section_decompress_status): Replace get_uncompressed_size with bfd_getb64. gas/ * write.c (compress_debug): Use bfd_putb64 to write uncompressed section size.
Diffstat (limited to 'bfd/compress.c')
-rw-r--r--bfd/compress.c33
1 files changed, 2 insertions, 31 deletions
diff --git a/bfd/compress.c b/bfd/compress.c
index 56d49fe..b57650f 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -59,27 +59,6 @@ decompress_contents (bfd_byte *compressed_buffer,
return rc == Z_OK && strm.avail_out == 0;
}
-static bfd_size_type
-get_uncompressed_size (bfd_byte *compressed_size_buffer)
-{
- bfd_size_type uncompressed_size = compressed_size_buffer[0];
- uncompressed_size <<= 8;
- uncompressed_size += compressed_size_buffer[1];
- uncompressed_size <<= 8;
- uncompressed_size += compressed_size_buffer[2];
- uncompressed_size <<= 8;
- uncompressed_size += compressed_size_buffer[3];
- uncompressed_size <<= 8;
- uncompressed_size += compressed_size_buffer[4];
- uncompressed_size <<= 8;
- uncompressed_size += compressed_size_buffer[5];
- uncompressed_size <<= 8;
- uncompressed_size += compressed_size_buffer[6];
- uncompressed_size <<= 8;
- uncompressed_size += compressed_size_buffer[7];
- return uncompressed_size;;
-}
-
/* Compress data of the size specified in @var{uncompressed_size}
and pointed to by @var{uncompressed_buffer} using zlib and store
as the contents field. This function assumes the contents
@@ -122,15 +101,7 @@ bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED, sec_ptr sec,
/* Write the zlib header. In this case, it should be "ZLIB" followed
by the uncompressed section size, 8 bytes in big-endian order. */
memcpy (compressed_buffer, "ZLIB", 4);
- compressed_buffer[11] = uncompressed_size; uncompressed_size >>= 8;
- compressed_buffer[10] = uncompressed_size; uncompressed_size >>= 8;
- compressed_buffer[9] = uncompressed_size; uncompressed_size >>= 8;
- compressed_buffer[8] = uncompressed_size; uncompressed_size >>= 8;
- compressed_buffer[7] = uncompressed_size; uncompressed_size >>= 8;
- compressed_buffer[6] = uncompressed_size; uncompressed_size >>= 8;
- compressed_buffer[5] = uncompressed_size; uncompressed_size >>= 8;
- compressed_buffer[4] = uncompressed_size;
-
+ bfd_putb64 (uncompressed_size, compressed_buffer + 4);
free (uncompressed_buffer);
sec->contents = compressed_buffer;
sec->size = compressed_size;
@@ -368,7 +339,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
return FALSE;
}
- uncompressed_size = get_uncompressed_size (compressed_buffer + 4);
+ uncompressed_size = bfd_getb64 (compressed_buffer + 4);
sec->compressed_size = sec->size;
sec->size = uncompressed_size;
sec->compress_status = DECOMPRESS_SECTION_SIZED;