// script-sections.h -- linker script SECTIONS for gold -*- C++ -*-
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008, 2009 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
#define GOLD_SCRIPT_SECTIONS_H
#include <cstdio>
+#include <list>
#include <vector>
namespace gold
class Output_section_definition;
class Output_section;
class Output_segment;
+class Orphan_section_placement;
class Script_sections
{
+ private:
+ // This is a list, not a vector, because we insert orphan sections
+ // in the middle.
+ typedef std::list<Sections_element*> Sections_elements;
+
public:
Script_sections();
void
add_input_section(const Input_section_spec* spec, bool keep);
+ // Saw DATA_SEGMENT_ALIGN.
+ void
+ data_segment_align();
+
+ // Saw DATA_SEGMENT_RELRO_END.
+ void
+ data_segment_relro_end();
+
// Create any required sections.
void
create_sections(Layout*);
void
put_headers_in_phdrs(Output_data* file_header, Output_data* segment_headers);
+ // Look for an output section by name and return the address, the
+ // load address, the alignment, and the size. This is used when an
+ // expression refers to an output section which was not actually
+ // created. This returns true if the section was found, false
+ // otherwise.
+ bool
+ get_output_section_info(const char* name, uint64_t* address,
+ uint64_t* load_address, uint64_t* addralign,
+ uint64_t* size) const;
+
+ // Release all Output_segments. This is used in relaxation.
+ void
+ release_segments();
+
+ // Whether we ever saw a SEGMENT_START expression, the presence of which
+ // changes the behaviour of -Ttext, -Tdata and -Tbss options.
+ bool
+ saw_segment_start_expression() const
+ { return this->saw_segment_start_expression_; }
+
+ // Set the flag which indicates whether we saw a SEGMENT_START expression.
+ void
+ set_saw_segment_start_expression(bool value)
+ { this->saw_segment_start_expression_ = value; }
+
// Print the contents to the FILE. This is for debugging.
void
print(FILE*) const;
- private:
- typedef std::vector<Sections_element*> Sections_elements;
+ // Used for orphan sections.
+ typedef Sections_elements::iterator Elements_iterator;
+ private:
typedef std::vector<Phdrs_element*> Phdrs_elements;
// Create segments.
Output_section_definition* output_section_;
// The list of program headers in the PHDRS clause.
Phdrs_elements* phdrs_elements_;
+ // Where to put orphan sections.
+ Orphan_section_placement* orphan_section_placement_;
+ // A pointer to the last Sections_element when we see
+ // DATA_SEGMENT_ALIGN.
+ Sections_elements::iterator data_segment_align_start_;
+ // Whether we have seen DATA_SEGMENT_ALIGN.
+ bool saw_data_segment_align_;
+ // Whether we have seen DATA_SEGMENT_RELRO_END.
+ bool saw_relro_end_;
+ // Whether we have seen SEGMENT_START.
+ bool saw_segment_start_expression_;
};
} // End namespace gold.