aboutsummaryrefslogtreecommitdiff
path: root/gold/merge.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2012-02-29 21:22:29 +0000
committerCary Coutant <ccoutant@google.com>2012-02-29 21:22:29 +0000
commit5dd8762ad1a47548394c76ead1b56fc5dab64628 (patch)
tree54eeb14cc262fb233284909e649157185c6a92d2 /gold/merge.cc
parent718cb7da5d4c438d89fc9aeac7f535d01d64af42 (diff)
downloadgdb-5dd8762ad1a47548394c76ead1b56fc5dab64628.zip
gdb-5dd8762ad1a47548394c76ead1b56fc5dab64628.tar.gz
gdb-5dd8762ad1a47548394c76ead1b56fc5dab64628.tar.bz2
* dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info):
Call Object::decompressed_section_contents. * dwarf_reader.h (Sized_dwarf_line_info::~Sized_dwarf_line_info): New dtor. (Sized_dwarf_line_info::buffer_start_): New data member. * merge.cc (Output_merge_data::do_add_input_section): Call Object::decompressed_section_contents. (Output_merge_string::do_add_input_section): Likewise. * object.cc (need_decompressed_section): New function. (build_compressed_section_map): Decompress sections needed later. (Sized_relobj_file::do_decompressed_section_contents): New function. (Sized_relobj_file::do_discard_decompressed_sections): New function. * object.h (Object::decompressed_section_contents): New function. (Object::discard_decompressed_sections): New function. (Object::do_decompressed_section_contents): New function. (Object::do_discard_decompressed_sections): New function. (Compressed_section_info): New type. (Compressed_section_map): Include decompressed section contents. (Sized_relobj_file::do_decompressed_section_contents): New function. (Sized_relobj_file::do_discard_decompressed_sections): New function.
Diffstat (limited to 'gold/merge.cc')
-rw-r--r--gold/merge.cc51
1 files changed, 15 insertions, 36 deletions
diff --git a/gold/merge.cc b/gold/merge.cc
index 093b6fc..dde43e9 100644
--- a/gold/merge.cc
+++ b/gold/merge.cc
@@ -406,27 +406,16 @@ bool
Output_merge_data::do_add_input_section(Relobj* object, unsigned int shndx)
{
section_size_type len;
- section_size_type uncompressed_size = 0;
- unsigned char* uncompressed_data = NULL;
- const unsigned char* p = object->section_contents(shndx, &len, false);
-
- if (object->section_is_compressed(shndx, &uncompressed_size))
- {
- uncompressed_data = new unsigned char[uncompressed_size];
- if (!decompress_input_section(p, len, uncompressed_data,
- uncompressed_size))
- object->error(_("could not decompress section %s"),
- object->section_name(shndx).c_str());
- p = uncompressed_data;
- len = uncompressed_size;
- }
+ bool is_new;
+ const unsigned char* p = object->decompressed_section_contents(shndx, &len,
+ &is_new);
section_size_type entsize = convert_to_section_size_type(this->entsize());
if (len % entsize != 0)
{
- if (uncompressed_data != NULL)
- delete[] uncompressed_data;
+ if (is_new)
+ delete[] p;
return false;
}
@@ -457,8 +446,8 @@ Output_merge_data::do_add_input_section(Relobj* object, unsigned int shndx)
if (this->keeps_input_sections())
record_input_section(object, shndx);
- if (uncompressed_data != NULL)
- delete[] uncompressed_data;
+ if (is_new)
+ delete[] p;
return true;
}
@@ -517,20 +506,10 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
unsigned int shndx)
{
section_size_type len;
- section_size_type uncompressed_size = 0;
- unsigned char* uncompressed_data = NULL;
- const unsigned char* pdata = object->section_contents(shndx, &len, false);
-
- if (object->section_is_compressed(shndx, &uncompressed_size))
- {
- uncompressed_data = new unsigned char[uncompressed_size];
- if (!decompress_input_section(pdata, len, uncompressed_data,
- uncompressed_size))
- object->error(_("could not decompress section %s"),
- object->section_name(shndx).c_str());
- pdata = uncompressed_data;
- len = uncompressed_size;
- }
+ bool is_new;
+ const unsigned char* pdata = object->decompressed_section_contents(shndx,
+ &len,
+ &is_new);
const Char_type* p = reinterpret_cast<const Char_type*>(pdata);
const Char_type* pend = p + len / sizeof(Char_type);
@@ -540,8 +519,8 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
{
object->error(_("mergeable string section length not multiple of "
"character size"));
- if (uncompressed_data != NULL)
- delete[] uncompressed_data;
+ if (is_new)
+ delete[] pdata;
return false;
}
@@ -606,8 +585,8 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
if (this->keeps_input_sections())
record_input_section(object, shndx);
- if (uncompressed_data != NULL)
- delete[] uncompressed_data;
+ if (is_new)
+ delete[] pdata;
return true;
}