1 // script-sections.h -- linker script SECTIONS for gold -*- C++ -*-
3 // Copyright 2008 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
23 // This is for the support of the SECTIONS clause in linker scripts.
25 #ifndef GOLD_SCRIPT_SECTIONS_H
26 #define GOLD_SCRIPT_SECTIONS_H
34 struct Parser_output_section_header
;
35 struct Parser_output_section_trailer
;
36 struct Input_section_spec
;
38 class Sections_element
;
39 class Output_section_definition
;
48 // Start a SECTIONS clause.
52 // Finish a SECTIONS clause.
56 // Return whether we ever saw a SECTIONS clause. If we did, then
57 // all section layout needs to go through this class.
59 saw_sections_clause() const
60 { return this->saw_sections_clause_
; }
62 // Return whether we are currently processing a SECTIONS clause.
64 in_sections_clause() const
65 { return this->in_sections_clause_
; }
67 // Start processing entries for an output section.
69 start_output_section(const char* name
, size_t namelen
,
70 const Parser_output_section_header
*);
72 // Finish processing entries for an output section.
74 finish_output_section(const Parser_output_section_trailer
*);
76 // Add a data item to the current output section.
78 add_data(int size
, bool is_signed
, Expression
* val
);
80 // Add a symbol to be defined.
82 add_symbol_assignment(const char* name
, size_t length
, Expression
* value
,
83 bool provide
, bool hidden
);
85 // Add an assignment to the special dot symbol.
87 add_dot_assignment(Expression
* value
);
91 add_assertion(Expression
* check
, const char* message
, size_t messagelen
);
93 // Add a setting for the fill value.
95 add_fill(Expression
* val
);
97 // Add an input section specification.
99 add_input_section(const Input_section_spec
* spec
, bool keep
);
101 // Add any symbols we are defining to the symbol table.
103 add_symbols_to_table(Symbol_table
*);
105 // Finalize symbol values and check assertions.
107 finalize_symbols(Symbol_table
* symtab
, const Layout
* layout
);
109 // Find the name of the output section to use for an input file name
110 // and section name. This returns a name, and sets
111 // *OUTPUT_SECTION_SLOT to point to the address where the actual
112 // output section may be stored.
113 // 1) If the input section should be discarded, this returns NULL
114 // and sets *OUTPUT_SECTION_SLOT to NULL.
115 // 2) If the input section is mapped by the SECTIONS clause, this
116 // returns the name to use for the output section (in permanent
117 // storage), and sets *OUTPUT_SECTION_SLOT to point to where the
118 // output section should be stored. **OUTPUT_SECTION_SLOT will be
119 // non-NULL if we have seen this output section already.
120 // 3) If the input section is not mapped by the SECTIONS clause,
121 // this returns SECTION_NAME, and sets *OUTPUT_SECTION_SLOT to
124 output_section_name(const char* file_name
, const char* section_name
,
125 Output_section
*** output_section_slot
);
127 // Place a marker for an orphan output section into the SECTIONS
130 place_orphan(Output_section
* os
);
132 // Set the addresses of all the output sections. Return the segment
133 // which holds the file header and segment headers, if any.
135 set_section_addresses(Symbol_table
*, Layout
*);
137 // Return the number of segments we expect to create based on the
140 expected_segment_count(const Layout
*) const;
142 // Print the contents to the FILE. This is for debugging.
147 typedef std::vector
<Sections_element
*> Sections_elements
;
151 create_segments(Layout
*);
153 // Create PT_NOTE and PT_TLS segments.
155 create_note_and_tls_segments(Layout
*, const std::vector
<Output_section
*>*);
157 // Return whether the section is a BSS section.
159 is_bss_section(const Output_section
*);
161 // True if we ever saw a SECTIONS clause.
162 bool saw_sections_clause_
;
163 // True if we are currently processing a SECTIONS clause.
164 bool in_sections_clause_
;
165 // The list of elements in the SECTIONS clause.
166 Sections_elements
* sections_elements_
;
167 // The current output section, if there is one.
168 Output_section_definition
* output_section_
;
171 } // End namespace gold.
173 #endif // !defined(GOLD_SCRIPT_SECTIONS_H