diff options
author | Cary Coutant <ccoutant@google.com> | 2012-04-24 22:05:28 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2012-04-24 22:05:28 +0000 |
commit | f038d49652c08bc36a5f606879d59c2a8270ad4a (patch) | |
tree | 6821ff1df888d9a49b665dbbec4863cb735984f5 /gold/incremental.h | |
parent | 6321c22a8c33b07349532156764fecf9a01a2396 (diff) | |
download | gdb-f038d49652c08bc36a5f606879d59c2a8270ad4a.zip gdb-f038d49652c08bc36a5f606879d59c2a8270ad4a.tar.gz gdb-f038d49652c08bc36a5f606879d59c2a8270ad4a.tar.bz2 |
* incremental-dump.cc (find_input_containing_global): Replace
magic number with symbolic constant.
(dump_incremental_inputs): Update version number.
* incremental.cc (Output_section_incremental_inputs): Update version
number; import symbolic constants from Incremental_inputs_reader.
(Incremental_inputs::create_data_sections): Align relocations
section correctly for 64-bit targets.
(Output_section_incremental_inputs::set_final_data_size): Use symbolic
constants; add padding.
(Output_section_incremental_inputs::write_header): Add assert for
header_size.
(Output_section_incremental_inputs::write_input_files): Add assert
for input_entry_size.
(Output_section_incremental_inputs::write_info_blocks): Add padding;
add assert for object_info_size, input_section_entry_size,
global_sym_entry_size.
* incremental.h (Incremental_inputs_reader): Add symbolic constants
for data structure sizes; use them.
(Incremental_input_entry_reader): Import symbolic constants from
Incremental_inputs_reader; use them.
Diffstat (limited to 'gold/incremental.h')
-rw-r--r-- | gold/incremental.h | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/gold/incremental.h b/gold/incremental.h index b631ae2..20ae772 100644 --- a/gold/incremental.h +++ b/gold/incremental.h @@ -758,6 +758,23 @@ class Incremental_inputs_reader typedef elfcpp::Swap<64, big_endian> Swap64; public: + // Size of the .gnu_incremental_inputs header. + // (3 x 4-byte fields, plus 4 bytes padding.) + static const unsigned int header_size = 16; + // Size of an input file entry. + // (2 x 4-byte fields, 1 x 12-byte field, 2 x 2-byte fields.) + static const unsigned int input_entry_size = 24; + // Size of the first part of the supplemental info block for + // relocatable objects and archive members. + // (7 x 4-byte fields, plus 4 bytes padding.) + static const unsigned int object_info_size = 32; + // Size of an input section entry. + // (2 x 4-byte fields, 2 x address-sized fields.) + static const unsigned int input_section_entry_size = 8 + 2 * size / 8; + // Size of a global symbol entry in the supplemental info block. + // (5 x 4-byte fields.) + static const unsigned int global_sym_entry_size = 20; + Incremental_inputs_reader() : p_(NULL), strtab_(NULL, 0), input_file_count_(0) { } @@ -788,6 +805,14 @@ class Incremental_inputs_reader // Reader class for an input file entry and its supplemental info. class Incremental_input_entry_reader { + private: + static const unsigned int object_info_size = + Incremental_inputs_reader<size, big_endian>::object_info_size; + static const unsigned int input_section_entry_size = + Incremental_inputs_reader<size, big_endian>::input_section_entry_size; + static const unsigned int global_sym_entry_size = + Incremental_inputs_reader<size, big_endian>::global_sym_entry_size; + public: Incremental_input_entry_reader(const Incremental_inputs_reader* inputs, unsigned int offset) @@ -866,9 +891,10 @@ class Incremental_inputs_reader || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); unsigned int section_count = this->get_input_section_count(); - return (this->info_offset_ + 28 - + section_count * input_section_entry_size - + symndx * 20); + return (this->info_offset_ + + this->object_info_size + + section_count * this->input_section_entry_size + + symndx * this->global_sym_entry_size); } // Return the global symbol count -- for objects & shared libraries only. @@ -1001,8 +1027,9 @@ class Incremental_inputs_reader { Input_section_info info; const unsigned char* p = (this->inputs_->p_ - + this->info_offset_ + 28 - + n * input_section_entry_size); + + this->info_offset_ + + this->object_info_size + + n * this->input_section_entry_size); unsigned int name_offset = Swap32::readval(p); info.name = this->inputs_->get_string(name_offset); info.output_shndx = Swap32::readval(p + 4); @@ -1019,9 +1046,10 @@ class Incremental_inputs_reader || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER); unsigned int section_count = this->get_input_section_count(); const unsigned char* p = (this->inputs_->p_ - + this->info_offset_ + 28 - + section_count * input_section_entry_size - + n * 20); + + this->info_offset_ + + this->object_info_size + + section_count * this->input_section_entry_size + + n * this->global_sym_entry_size); return Incremental_global_symbol_reader<big_endian>(p); } @@ -1032,9 +1060,10 @@ class Incremental_inputs_reader unsigned int section_count = this->get_input_section_count(); unsigned int symbol_count = this->get_global_symbol_count(); const unsigned char* p = (this->inputs_->p_ - + this->info_offset_ + 28 - + section_count * input_section_entry_size - + symbol_count * 20 + + this->info_offset_ + + this->object_info_size + + section_count * this->input_section_entry_size + + symbol_count * this->global_sym_entry_size + n * 4); unsigned int name_offset = Swap32::readval(p); return this->inputs_->get_string(name_offset); @@ -1072,8 +1101,6 @@ class Incremental_inputs_reader } private: - // Size of an input section entry. - static const unsigned int input_section_entry_size = 8 + 2 * size / 8; // The reader instance for the containing section. const Incremental_inputs_reader* inputs_; // The flags, including the type of input file. @@ -1089,14 +1116,14 @@ class Incremental_inputs_reader input_file_offset(unsigned int n) const { gold_assert(n < this->input_file_count_); - return 16 + n * 24; + return this->header_size + n * this->input_entry_size; } // Return the index of an input file entry given its OFFSET. unsigned int input_file_index(unsigned int offset) const { - int n = (offset - 16) / 24; + int n = ((offset - this->header_size) / this->input_entry_size); gold_assert(input_file_offset(n) == offset); return n; } @@ -1110,7 +1137,8 @@ class Incremental_inputs_reader Incremental_input_entry_reader input_file_at_offset(unsigned int offset) const { - gold_assert(offset < 16 + this->input_file_count_ * 24); + gold_assert(offset < (this->header_size + + this->input_file_count_ * this->input_entry_size)); return Incremental_input_entry_reader(this, offset); } |