summaryrefslogtreecommitdiff
path: root/gold/incremental.h
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2011-05-23 23:27:11 +0000
committerCary Coutant <ccoutant@google.com>2011-05-23 23:27:11 +0000
commit4829d394dedd7953e0ee0cf540ffccc01936499d (patch)
treeeb77be5d59cedf93ed8a5ed3e7feb32530d51a65 /gold/incremental.h
parentdd931b2ff2bf7cecc09dba03e8916e4adc9406be (diff)
* gold.cc (queue_middle_tasks): Process existing GOT/PLT entries.
* incremental-dump.cc (dump_incremental_inputs): Mask high-order bit when checking got_type. * incremental.cc (Sized_incremental_binary::setup_readers): Store symbol table and string table locations; initialize bit vector of file status flags. (Sized_incremental_binary::do_reserve_layout): Set bit flag for unchanged files. (Sized_incremental_binary::do_process_got_plt): New function. (Sized_incremental_binary::get_symtab_view): Use stored locations. (Output_section_incremental_inputs::set_final_data_size): Record file index for each input file. (Output_section_incremental_inputs::write_got_plt): Store file index instead of input entry offset for each GOT entry. * incremental.h (Incremental_input_entry::Incremental_input_entry): Initialize new data member. (Incremental_input_entry::set_offset): Store file index. (Incremental_input_entry::get_file_index): New function. (Incremental_input_entry::file_index_): New data member. (Incremental_binary::process_got_plt): New function. (Incremental_binary::do_process_got_plt): New function. (Sized_incremental_binary::Sized_incremental_binary): Initialize new data members. (Sized_incremental_binary::~Sized_incremental_binary): New destructor. (Sized_incremental_binary::set_file_is_unchanged): New function. (Sized_incremental_binary::file_is_unchanged): New function. (Sized_incremental_binary::do_process_got_plt): New function. (Sized_incremental_binary::file_status_): New data member. (Sized_incremental_binary::main_symtab_loc_): New data member. (Sized_incremental_binary::main_strtab_loc_): New data member. * output.cc (Output_data_got::Got_entry::write): Add case RESERVED_CODE. (Output_data_got::add_global): Call add_got_entry. (Output_data_got::add_global_plt): Likewise. (Output_data_got::add_global_with_rel): Likewise. (Output_data_got::add_global_with_rela): Likewise. (Output_data_got::add_global_pair_with_rel): Call add_got_entry_pair. (Output_data_got::add_global_pair_with_rela): Likewise. (Output_data_got::add_local): Call add_got_entry. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Likewise. (Output_data_got::add_local_with_rela): Likewise. (Output_data_got::add_local_pair_with_rel): Call add_got_entry_pair. (Output_data_got::add_local_pair_with_rela): Likewise. (Output_data_got::reserve_slot): New function. (Output_data_got::reserve_slot_for_global): New function. (Output_data_got::add_got_entry): New function. (Output_data_got::add_got_entry_pair): New function. (Output_section::add_output_section_data): Edit FIXME. * output.h (Output_section_data_build::Output_section_data_build): New constructor with size parameter. (Output_data_space::Output_data_space): Likewise. (Output_data_got::Output_data_got): Initialize new data member; new constructor with size parameter. (Output_data_got::add_constant): Call add_got_entry. (Output_data_got::reserve_slot): New function. (Output_data_got::reserve_slot_for_global): New function. (class Output_data_got::Got_entry): Add RESERVED_CODE. (Output_data_got::add_got_entry): New function. (Output_data_got::add_got_entry_pair): New function. (Output_data_got::free_list_): New data member. * target.h (Sized_target::init_got_plt_for_update): New function. (Sized_target::register_global_plt_entry): New function. * x86_64.cc (Output_data_plt_x86_64::Output_data_plt_x86_64): Initialize new data member; call init; add constructor with PLT count. (Output_data_plt_x86_64::init): New function. (Output_data_plt_x86_64::add_relocation): New function. (Output_data_plt_x86_64::reserve_slot): New function. (Output_data_plt_x86_64::free_list_): New data member. (Target_x86_64::init_got_plt_for_update): New function. (Target_x86_64::register_global_plt_entry): New function. (Output_data_plt_x86_64::add_entry): Allocate from free list for incremental updates. (Output_data_plt_x86_64::add_relocation): New function. * testsuite/object_unittest.cc (Object_test): Set default options.
Diffstat (limited to 'gold/incremental.h')
-rw-r--r--gold/incremental.h73
1 files changed, 65 insertions, 8 deletions
diff --git a/gold/incremental.h b/gold/incremental.h
index 41ae188cd7..5c0f937dc1 100644
--- a/gold/incremental.h
+++ b/gold/incremental.h
@@ -79,7 +79,7 @@ class Incremental_input_entry
public:
Incremental_input_entry(Stringpool::Key filename_key, unsigned int arg_serial,
Timespec mtime)
- : filename_key_(filename_key), offset_(0), info_offset_(0),
+ : filename_key_(filename_key), file_index_(0), offset_(0), info_offset_(0),
arg_serial_(arg_serial), mtime_(mtime), is_in_system_directory_(false)
{ }
@@ -92,16 +92,24 @@ class Incremental_input_entry
type() const
{ return this->do_type(); }
- // Set the section offset of this input file entry.
+ // Set the index and section offset of this input file entry.
void
- set_offset(unsigned int offset)
- { this->offset_ = offset; }
+ set_offset(unsigned int file_index, unsigned int offset)
+ {
+ this->file_index_ = file_index;
+ this->offset_ = offset;
+ }
// Set the section offset of the supplemental information for this entry.
void
set_info_offset(unsigned int info_offset)
{ this->info_offset_ = info_offset; }
+ // Get the index of this input file entry.
+ unsigned int
+ get_file_index() const
+ { return this->file_index_; }
+
// Get the section offset of this input file entry.
unsigned int
get_offset() const
@@ -182,6 +190,9 @@ class Incremental_input_entry
// Key of the filename string in the section stringtable.
Stringpool::Key filename_key_;
+ // Index of the entry in the output section.
+ unsigned int file_index_;
+
// Offset of the entry in the output section.
unsigned int offset_;
@@ -1235,6 +1246,11 @@ class Incremental_binary
reserve_layout(unsigned int input_file_index)
{ this->do_reserve_layout(input_file_index); }
+ // Process the GOT and PLT entries from the existing output file.
+ void
+ process_got_plt(Symbol_table* symtab, Layout* layout)
+ { this->do_process_got_plt(symtab, layout); }
+
// Apply incremental relocations for symbols whose values have changed.
void
apply_incremental_relocs(const Symbol_table* symtab, Layout* layout,
@@ -1313,6 +1329,10 @@ class Incremental_binary
virtual void
do_reserve_layout(unsigned int input_file_index) = 0;
+ // Process the GOT and PLT entries from the existing output file.
+ virtual void
+ do_process_got_plt(Symbol_table* symtab, Layout* layout) = 0;
+
// Apply incremental relocations for symbols whose values have changed.
virtual void
do_apply_incremental_relocs(const Symbol_table*, Layout*, Output_file*) = 0;
@@ -1345,29 +1365,53 @@ class Sized_incremental_binary : public Incremental_binary
const elfcpp::Ehdr<size, big_endian>& ehdr,
Target* target)
: Incremental_binary(output, target), elf_file_(this, ehdr),
- section_map_(), symbol_map_(), has_incremental_info_(false),
- inputs_reader_(), symtab_reader_(), relocs_reader_(), got_plt_reader_(),
+ file_status_(NULL), section_map_(), symbol_map_(), main_symtab_loc_(),
+ main_strtab_loc_(), has_incremental_info_(false), inputs_reader_(),
+ symtab_reader_(), relocs_reader_(), got_plt_reader_(),
input_entry_readers_()
{ this->setup_readers(); }
+ virtual
+ ~Sized_incremental_binary()
+ {
+ if (this->file_status_ != NULL)
+ delete[] this->file_status_;
+ }
+
// Returns TRUE if the file contains incremental info.
bool
has_incremental_info() const
{ return this->has_incremental_info_; }
+ // Set the flag for input file N to indicate that the file is unchanged.
+ void
+ set_file_is_unchanged(unsigned int n)
+ {
+ gold_assert(this->file_status_ != NULL);
+ this->file_status_[n / 8] |= 1U << (n % 8);
+ }
+
+ // Returns TRUE if input file N is unchanged.
+ bool
+ file_is_unchanged(unsigned int n) const
+ {
+ gold_assert(this->file_status_ != NULL);
+ return (this->file_status_[n / 8] & (1U << (n % 8))) != 0;
+ }
+
// Return the Output_section for section index SHNDX.
Output_section*
output_section(unsigned int shndx)
{ return this->section_map_[shndx]; }
- // Map a symbol table entry from the input file to the output symbol table.
+ // Map a symbol table entry from the base file to the output symbol table.
// SYMNDX is relative to the first forced-local or global symbol in the
// input file symbol table.
void
add_global_symbol(unsigned int symndx, Symbol* gsym)
{ this->symbol_map_[symndx] = gsym; }
- // Map a symbol table entry from the input file to the output symbol table.
+ // Map a symbol table entry from the base file to the output symbol table.
// SYMNDX is relative to the first forced-local or global symbol in the
// input file symbol table.
Symbol*
@@ -1418,6 +1462,10 @@ class Sized_incremental_binary : public Incremental_binary
virtual void
do_reserve_layout(unsigned int input_file_index);
+ // Process the GOT and PLT entries from the existing output file.
+ virtual void
+ do_process_got_plt(Symbol_table* symtab, Layout* layout);
+
// Apply incremental relocations for symbols whose values have changed.
virtual void
do_apply_incremental_relocs(const Symbol_table* symtab, Layout* layout,
@@ -1489,12 +1537,21 @@ class Sized_incremental_binary : public Incremental_binary
// Output as an ELF file.
elfcpp::Elf_file<size, big_endian, Incremental_binary> elf_file_;
+ // Status flags for each input file. Each bit represents one input file;
+ // 0 indicates that the file was replaced; 1 indicates that the file was
+ // unchanged.
+ unsigned char* file_status_;
+
// Map section index to an Output_section in the updated layout.
std::vector<Output_section*> section_map_;
// Map global symbols from the input file to the symbol table.
std::vector<Symbol*> symbol_map_;
+ // Locations of the main symbol table and symbol string table.
+ Location main_symtab_loc_;
+ Location main_strtab_loc_;
+
// Readers for the incremental info sections.
bool has_incremental_info_;
Incremental_inputs_reader<size, big_endian> inputs_reader_;