diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-04-04 07:49:35 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-04-04 07:49:35 -0700 |
commit | 8bed4e0f7b0f82bff55798465bfef2a6986758d3 (patch) | |
tree | f9f3d1826f58d0a0518245fb7a67ceedf3ff9a0b /bfd | |
parent | e268c0a63c2c4c60d54c07d1c3055cb0e62f6b40 (diff) | |
download | gdb-8bed4e0f7b0f82bff55798465bfef2a6986758d3.zip gdb-8bed4e0f7b0f82bff55798465bfef2a6986758d3.tar.gz gdb-8bed4e0f7b0f82bff55798465bfef2a6986758d3.tar.bz2 |
Extract get_uncompressed_size
* compress.c (get_uncompressed_size): New. Extracted from ...
(bfd_init_section_decompress_status): This. Use it.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/compress.c | 31 |
2 files changed, 27 insertions, 9 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 810705f..654408e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2015-04-04 H.J. Lu <hongjiu.lu@intel.com> + + * compress.c (get_uncompressed_size): New. Extracted from ... + (bfd_init_section_decompress_status): This. Use it. + 2015-04-02 Andrew Turner <andrew@freebsd.org> * config.bfd: Add aarch64-*-freebsd* target triple. diff --git a/bfd/compress.c b/bfd/compress.c index 7e498fa..6621dff 100644 --- a/bfd/compress.c +++ b/bfd/compress.c @@ -59,6 +59,27 @@ decompress_contents (bfd_byte *compressed_buffer, return rc == Z_OK && strm.avail_out == 0; } +static bfd_size_type +get_uncompressed_size (bfd_byte *uncompressed_size_buffer) +{ + bfd_size_type uncompressed_size = uncompressed_size_buffer[0]; + uncompressed_size <<= 8; + uncompressed_size += uncompressed_size_buffer[1]; + uncompressed_size <<= 8; + uncompressed_size += uncompressed_size_buffer[2]; + uncompressed_size <<= 8; + uncompressed_size += uncompressed_size_buffer[3]; + uncompressed_size <<= 8; + uncompressed_size += uncompressed_size_buffer[4]; + uncompressed_size <<= 8; + uncompressed_size += uncompressed_size_buffer[5]; + uncompressed_size <<= 8; + uncompressed_size += uncompressed_size_buffer[6]; + uncompressed_size <<= 8; + uncompressed_size += uncompressed_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 @@ -347,15 +368,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec) return FALSE; } - uncompressed_size = compressed_buffer[4]; uncompressed_size <<= 8; - uncompressed_size += compressed_buffer[5]; uncompressed_size <<= 8; - uncompressed_size += compressed_buffer[6]; uncompressed_size <<= 8; - uncompressed_size += compressed_buffer[7]; uncompressed_size <<= 8; - uncompressed_size += compressed_buffer[8]; uncompressed_size <<= 8; - uncompressed_size += compressed_buffer[9]; uncompressed_size <<= 8; - uncompressed_size += compressed_buffer[10]; uncompressed_size <<= 8; - uncompressed_size += compressed_buffer[11]; - + uncompressed_size = get_uncompressed_size (compressed_buffer + 4); sec->compressed_size = sec->size; sec->size = uncompressed_size; sec->compress_status = DECOMPRESS_SECTION_SIZED; |