From 2ad4be22580b5742abbded710c51e7dd1af3072f Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Tue, 24 May 2011 21:57:27 +0000 Subject: * dynobj.h (Dynobj::do_dynobj): New function. * incremental-dump.cc (dump_incremental_inputs): Print as_needed flag and soname for shared objects. * incremental.cc (Incremental_inputs::report_object): Make either Incremental_object_entry or Incremental_dynobj_entry; add soname to string table. (Incremental_inputs::report_input_section): Add assertion. (Output_section_incremental_inputs::set_final_data_size): Adjust type of input file entry for shared libraries; adjust size of shared library info entry. (Output_section_incremental_inputs::write_input_files): Write as_needed flag for shared libraries. (Output_section_incremental_inputs::write_info_blocks): Adjust type of input file entry for shared libraries; write soname. (Sized_incr_dynobj::Sized_incr_dynobj): Read as_needed flag and soname from incremental info. * incremental.h (enum Incremental_input_flags): Add INCREMENTAL_INPUT_AS_NEEDED. (Incremental_input_entry::Incremental_input_entry): Initialize new data member. (Incremental_input_entry::set_as_needed): New function. (Incremental_input_entry::as_needed): New function. (Incremental_input_entry::do_dynobj_entry): New function. (Incremental_input_entry::as_needed_): New data member. (Incremental_object_entry::Incremental_object_entry): Don't check for shared library. (Incremental_object_entry::do_type): Likewise. (class Incremental_dynobj_entry): New class. (Incremental_input_entry_reader::as_needed): New function. (Incremental_input_entry_reader::get_soname): New function. (Incremental_input_entry_reader::get_global_symbol_count): Rewrite. (Incremental_input_entry_reader::get_output_symbol_index): Adjust size of shared library info entry. * layout.cc (Layout::finish_dynamic_section): Don't test for incremental link when adding DT_NEEDED entries. * object.h (Object::Object): Initialize new data member. (Object::dynobj): New function. (Object::set_as_needed): New function. (Object::as_needed): New function. (Object::do_dynobj): New function. (Object::as_needed_): New data member. --- gold/incremental.cc | 66 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 17 deletions(-) (limited to 'gold/incremental.cc') diff --git a/gold/incremental.cc b/gold/incremental.cc index d49c8a5df4..0a8994078f 100644 --- a/gold/incremental.cc +++ b/gold/incremental.cc @@ -975,28 +975,48 @@ Incremental_inputs::report_object(Object* obj, unsigned int arg_serial, arg_serial = 0; this->strtab_->add(obj->name().c_str(), false, &filename_key); - Incremental_object_entry* obj_entry = - new Incremental_object_entry(filename_key, obj, arg_serial, mtime); - if (obj->is_in_system_directory()) - obj_entry->set_is_in_system_directory(); - this->inputs_.push_back(obj_entry); - if (arch != NULL) + Incremental_input_entry* input_entry; + + this->current_object_ = obj; + + if (!obj->is_dynamic()) { - Incremental_archive_entry* arch_entry = arch->incremental_info(); - gold_assert(arch_entry != NULL); - arch_entry->add_object(obj_entry); + this->current_object_entry_ = + new Incremental_object_entry(filename_key, obj, arg_serial, mtime); + input_entry = this->current_object_entry_; + if (arch != NULL) + { + Incremental_archive_entry* arch_entry = arch->incremental_info(); + gold_assert(arch_entry != NULL); + arch_entry->add_object(this->current_object_entry_); + } } + else + { + this->current_object_entry_ = NULL; + Stringpool::Key soname_key; + Dynobj* dynobj = obj->dynobj(); + gold_assert(dynobj != NULL); + this->strtab_->add(dynobj->soname(), false, &soname_key); + input_entry = new Incremental_dynobj_entry(filename_key, soname_key, obj, + arg_serial, mtime); + } + + if (obj->is_in_system_directory()) + input_entry->set_is_in_system_directory(); + + if (obj->as_needed()) + input_entry->set_as_needed(); + + this->inputs_.push_back(input_entry); if (script_info != NULL) { Incremental_script_entry* script_entry = script_info->incremental_info(); gold_assert(script_entry != NULL); - script_entry->add_object(obj_entry); + script_entry->add_object(input_entry); } - - this->current_object_ = obj; - this->current_object_entry_ = obj_entry; } // Record the input object file OBJ. If ARCH is not NULL, attach @@ -1013,6 +1033,7 @@ Incremental_inputs::report_input_section(Object* obj, unsigned int shndx, this->strtab_->add(name, true, &key); gold_assert(obj == this->current_object_); + gold_assert(this->current_object_entry_ != NULL); this->current_object_entry_->add_input_section(shndx, key, sh_size); } @@ -1155,11 +1176,11 @@ Output_section_incremental_inputs::set_final_data_size() break; case INCREMENTAL_INPUT_SHARED_LIBRARY: { - Incremental_object_entry* entry = (*p)->object_entry(); + Incremental_dynobj_entry* entry = (*p)->dynobj_entry(); gold_assert(entry != NULL); (*p)->set_info_offset(info_offset); - // Global symbol count. - info_offset += 4; + // Global symbol count, soname index. + info_offset += 8; // Each global symbol. const Object::Symbols* syms = entry->object()->get_global_symbols(); gold_assert(syms != NULL); @@ -1321,6 +1342,8 @@ Output_section_incremental_inputs::write_input_files( unsigned int flags = (*p)->type(); if ((*p)->is_in_system_directory()) flags |= INCREMENTAL_INPUT_IN_SYSTEM_DIR; + if ((*p)->as_needed()) + flags |= INCREMENTAL_INPUT_AS_NEEDED; Swap32::writeval(pov, filename_offset); Swap32::writeval(pov + 4, (*p)->get_info_offset()); Swap64::writeval(pov + 8, mtime.seconds); @@ -1483,11 +1506,17 @@ Output_section_incremental_inputs::write_info_blocks( { gold_assert(static_cast(pov - oview) == (*p)->get_info_offset()); - Incremental_object_entry* entry = (*p)->object_entry(); + Incremental_dynobj_entry* entry = (*p)->dynobj_entry(); gold_assert(entry != NULL); const Object* obj = entry->object(); const Object::Symbols* syms = obj->get_global_symbols(); + // Write the soname string table index. + section_offset_type soname_offset = + strtab->get_offset_from_key(entry->get_soname_key()); + Swap32::writeval(pov, soname_offset); + pov += 4; + // Skip the global symbol count for now. unsigned char* orig_pov = pov; pov += 4; @@ -2347,6 +2376,9 @@ Sized_incr_dynobj::Sized_incr_dynobj( { if (this->input_reader_.is_in_system_directory()) this->set_is_in_system_directory(); + if (this->input_reader_.as_needed()) + this->set_as_needed(); + this->set_soname_string(this->input_reader_.get_soname()); this->set_shnum(0); } -- cgit v1.2.1