aboutsummaryrefslogtreecommitdiff
path: root/gold/incremental.h
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2011-05-24 21:57:28 +0000
committerCary Coutant <ccoutant@google.com>2011-05-24 21:57:28 +0000
commit0f1c85a62235edfbe68c78b197dcdbbe94b0b160 (patch)
tree8354c13bf8f71048d9120527cac3493e9aafd0f3 /gold/incremental.h
parent6fa2a40bf45fcc738eb580a6b644ac74b42c2d6a (diff)
downloadgdb-0f1c85a62235edfbe68c78b197dcdbbe94b0b160.zip
gdb-0f1c85a62235edfbe68c78b197dcdbbe94b0b160.tar.gz
gdb-0f1c85a62235edfbe68c78b197dcdbbe94b0b160.tar.bz2
* 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.
Diffstat (limited to 'gold/incremental.h')
-rw-r--r--gold/incremental.h112
1 files changed, 92 insertions, 20 deletions
diff --git a/gold/incremental.h b/gold/incremental.h
index 3935186..dc8ef33 100644
--- a/gold/incremental.h
+++ b/gold/incremental.h
@@ -40,6 +40,7 @@ class Input_argument;
class Incremental_inputs_checker;
class Incremental_script_entry;
class Incremental_object_entry;
+class Incremental_dynobj_entry;
class Incremental_archive_entry;
class Incremental_inputs;
class Incremental_binary;
@@ -63,7 +64,8 @@ enum Incremental_input_type
enum Incremental_input_flags
{
- INCREMENTAL_INPUT_IN_SYSTEM_DIR = 0x0800
+ INCREMENTAL_INPUT_IN_SYSTEM_DIR = 0x8000,
+ INCREMENTAL_INPUT_AS_NEEDED = 0x4000
};
// Create an Incremental_binary object for FILE. Returns NULL is this is not
@@ -80,7 +82,8 @@ class Incremental_input_entry
Incremental_input_entry(Stringpool::Key filename_key, unsigned int arg_serial,
Timespec mtime)
: filename_key_(filename_key), file_index_(0), offset_(0), info_offset_(0),
- arg_serial_(arg_serial), mtime_(mtime), is_in_system_directory_(false)
+ arg_serial_(arg_serial), mtime_(mtime), is_in_system_directory_(false),
+ as_needed_(false)
{ }
virtual
@@ -145,6 +148,16 @@ class Incremental_input_entry
is_in_system_directory() const
{ return this->is_in_system_directory_; }
+ // Record that the file was linked with --as-needed.
+ void
+ set_as_needed()
+ { this->as_needed_ = true; }
+
+ // Return TRUE if the file was linked with --as-needed.
+ bool
+ as_needed() const
+ { return this->as_needed_; }
+
// Return a pointer to the derived Incremental_script_entry object.
// Return NULL for input entries that are not script files.
Incremental_script_entry*
@@ -157,6 +170,12 @@ class Incremental_input_entry
object_entry()
{ return this->do_object_entry(); }
+ // Return a pointer to the derived Incremental_dynobj_entry object.
+ // Return NULL for input entries that are not shared object files.
+ Incremental_dynobj_entry*
+ dynobj_entry()
+ { return this->do_dynobj_entry(); }
+
// Return a pointer to the derived Incremental_archive_entry object.
// Return NULL for input entries that are not archive files.
Incremental_archive_entry*
@@ -180,6 +199,12 @@ class Incremental_input_entry
do_object_entry()
{ return NULL; }
+ // Return a pointer to the derived Incremental_dynobj_entry object.
+ // Return NULL for input entries that are not shared object files.
+ virtual Incremental_dynobj_entry*
+ do_dynobj_entry()
+ { return NULL; }
+
// Return a pointer to the derived Incremental_archive_entry object.
// Return NULL for input entries that are not archive files.
virtual Incremental_archive_entry*
@@ -207,6 +232,9 @@ class Incremental_input_entry
// TRUE if the file was found in a system directory.
bool is_in_system_directory_;
+
+ // TRUE if the file was linked with --as-needed.
+ bool as_needed_;
};
// Information about a script input that will persist during the whole linker
@@ -298,10 +326,7 @@ class Incremental_object_entry : public Incremental_input_entry
unsigned int arg_serial, Timespec mtime)
: Incremental_input_entry(filename_key, arg_serial, mtime), obj_(obj),
is_member_(false), sections_()
- {
- if (!obj_->is_dynamic())
- this->sections_.reserve(obj->shnum());
- }
+ { this->sections_.reserve(obj->shnum()); }
// Get the object.
Object*
@@ -349,9 +374,7 @@ class Incremental_object_entry : public Incremental_input_entry
{
return (this->is_member_
? INCREMENTAL_INPUT_ARCHIVE_MEMBER
- : (this->obj_->is_dynamic()
- ? INCREMENTAL_INPUT_SHARED_LIBRARY
- : INCREMENTAL_INPUT_OBJECT));
+ : INCREMENTAL_INPUT_OBJECT);
}
// Return a pointer to the derived Incremental_object_entry object.
@@ -379,6 +402,46 @@ class Incremental_object_entry : public Incremental_input_entry
std::vector<Input_section> sections_;
};
+// Class for recording shared library input files.
+
+class Incremental_dynobj_entry : public Incremental_input_entry
+{
+ public:
+ Incremental_dynobj_entry(Stringpool::Key filename_key,
+ Stringpool::Key soname_key, Object* obj,
+ unsigned int arg_serial, Timespec mtime)
+ : Incremental_input_entry(filename_key, arg_serial, mtime),
+ soname_key_(soname_key), obj_(obj)
+ { }
+
+ // Get the object.
+ Object*
+ object() const
+ { return this->obj_; }
+
+ // Get the stringpool key for the soname.
+ Stringpool::Key
+ get_soname_key() const
+ { return this->soname_key_; }
+
+ protected:
+ virtual Incremental_input_type
+ do_type() const
+ { return INCREMENTAL_INPUT_SHARED_LIBRARY; }
+
+ // Return a pointer to the derived Incremental_dynobj_entry object.
+ virtual Incremental_dynobj_entry*
+ do_dynobj_entry()
+ { return this; }
+
+ private:
+ // Key of the soname string in the section stringtable.
+ Stringpool::Key soname_key_;
+
+ // The object file itself.
+ Object* obj_;
+};
+
// Class for recording archive library input files.
class Incremental_archive_entry : public Incremental_input_entry
@@ -718,6 +781,11 @@ class Incremental_inputs_reader
is_in_system_directory() const
{ return (this->flags_ & INCREMENTAL_INPUT_IN_SYSTEM_DIR) != 0; }
+ // Return TRUE if the file was linked with --as-needed.
+ bool
+ as_needed() const
+ { return (this->flags_ & INCREMENTAL_INPUT_AS_NEEDED) != 0; }
+
// Return the input section count -- for objects only.
unsigned int
get_input_section_count() const
@@ -727,6 +795,16 @@ class Incremental_inputs_reader
return Swap32::readval(this->inputs_->p_ + this->info_offset_);
}
+ // Return the soname -- for shared libraries only.
+ const char*
+ get_soname() const
+ {
+ gold_assert(this->type() == INCREMENTAL_INPUT_SHARED_LIBRARY);
+ unsigned int offset = Swap32::readval(this->inputs_->p_
+ + this->info_offset_);
+ return this->inputs_->get_string(offset);
+ }
+
// Return the offset of the supplemental info for symbol SYMNDX --
// for objects only.
unsigned int
@@ -745,16 +823,10 @@ class Incremental_inputs_reader
unsigned int
get_global_symbol_count() const
{
- switch (this->type())
- {
- case INCREMENTAL_INPUT_OBJECT:
- case INCREMENTAL_INPUT_ARCHIVE_MEMBER:
- return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 4);
- case INCREMENTAL_INPUT_SHARED_LIBRARY:
- return Swap32::readval(this->inputs_->p_ + this->info_offset_);
- default:
- gold_unreachable();
- }
+ gold_assert(this->type() == INCREMENTAL_INPUT_OBJECT
+ || this->type() == INCREMENTAL_INPUT_ARCHIVE_MEMBER
+ || this->type() == INCREMENTAL_INPUT_SHARED_LIBRARY);
+ return Swap32::readval(this->inputs_->p_ + this->info_offset_ + 4);
}
// Return the offset of the first local symbol -- for objects only.
@@ -899,7 +971,7 @@ class Incremental_inputs_reader
{
gold_assert(this->type() == INCREMENTAL_INPUT_SHARED_LIBRARY);
const unsigned char* p = (this->inputs_->p_
- + this->info_offset_ + 4
+ + this->info_offset_ + 8
+ n * 4);
unsigned int output_symndx = Swap32::readval(p);
*is_def = (output_symndx & (1U << 31)) != 0;