aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.h
diff options
context:
space:
mode:
Diffstat (limited to 'gold/layout.h')
-rw-r--r--gold/layout.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/gold/layout.h b/gold/layout.h
index ba5fa66..917856e 100644
--- a/gold/layout.h
+++ b/gold/layout.h
@@ -41,6 +41,7 @@ namespace gold
class General_options;
class Incremental_inputs;
+class Incremental_binary;
class Input_objects;
class Mapfile;
class Symbol_table;
@@ -64,6 +65,69 @@ struct Timespec;
extern bool
is_compressed_debug_section(const char* secname);
+// Maintain a list of free space within a section, segment, or file.
+// Used for incremental update links.
+
+class Free_list
+{
+ public:
+ Free_list()
+ : list_(), last_remove_(list_.begin()), extend_(false), length_(0)
+ { }
+
+ void
+ init(off_t len, bool extend);
+
+ void
+ remove(off_t start, off_t end);
+
+ off_t
+ allocate(off_t len, uint64_t align, off_t minoff);
+
+ void
+ dump();
+
+ static void
+ print_stats();
+
+ private:
+ struct Free_list_node
+ {
+ Free_list_node(off_t start, off_t end)
+ : start_(start), end_(end)
+ { }
+ off_t start_;
+ off_t end_;
+ };
+ typedef std::list<Free_list_node>::iterator Iterator;
+
+ // The free list.
+ std::list<Free_list_node> list_;
+
+ // The last node visited during a remove operation.
+ Iterator last_remove_;
+
+ // Whether we can extend past the original length.
+ bool extend_;
+
+ // The total length of the section, segment, or file.
+ off_t length_;
+
+ // Statistics:
+ // The total number of free lists used.
+ static unsigned int num_lists;
+ // The total number of free list nodes used.
+ static unsigned int num_nodes;
+ // The total number of calls to Free_list::remove.
+ static unsigned int num_removes;
+ // The total number of nodes visited during calls to Free_list::remove.
+ static unsigned int num_remove_visits;
+ // The total number of calls to Free_list::allocate.
+ static unsigned int num_allocates;
+ // The total number of nodes visited during calls to Free_list::allocate.
+ static unsigned int num_allocate_visits;
+};
+
// This task function handles mapping the input sections to output
// sections and laying them out in memory.
@@ -401,6 +465,20 @@ class Layout
delete this->segment_states_;
}
+ // For incremental links, record the base file to be modified.
+ void
+ set_incremental_base(Incremental_binary* base);
+
+ Incremental_binary*
+ incremental_base()
+ { return this->incremental_base_; }
+
+ // For incremental links, record the initial fixed layout of a section
+ // from the base file, and return a pointer to the Output_section.
+ template<int size, bool big_endian>
+ Output_section*
+ init_fixed_output_section(const char*, elfcpp::Shdr<size, big_endian>&);
+
// Given an input section SHNDX, named NAME, with data in SHDR, from
// the object file OBJECT, return the output section where this
// input section should go. RELOC_SHNDX is the index of a
@@ -414,6 +492,12 @@ class Layout
const char* name, const elfcpp::Shdr<size, big_endian>& shdr,
unsigned int reloc_shndx, unsigned int reloc_type, off_t* offset);
+ // For incremental updates, allocate a block of memory from the
+ // free list. Find a block starting at or after MINOFF.
+ off_t
+ allocate(off_t len, uint64_t align, off_t minoff)
+ { return this->free_list_.allocate(len, align, minoff); }
+
unsigned int
find_section_order_index(const std::string&);
@@ -1151,6 +1235,10 @@ class Layout
Unordered_map<std::string, unsigned int> input_section_position_;
// Vector of glob only patterns in the section_ordering file.
std::vector<std::string> input_section_glob_;
+ // For incremental links, the base file to be modified.
+ Incremental_binary* incremental_base_;
+ // For incremental links, a list of free space within the file.
+ Free_list free_list_;
};
// This task handles writing out data in output sections which is not