1 // defstd.cc -- define standard symbols for gold.
3 // Copyright 2006, 2007 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.
29 // This is a simple file which defines the standard symbols like
37 const Define_symbol_in_section in_section
[] =
40 "__preinit_array_start", // name
41 ".preinit_array", // output_section
44 elfcpp::STT_NOTYPE
, // type
45 elfcpp::STB_GLOBAL
, // binding
46 elfcpp::STV_HIDDEN
, // visibility
48 false, // offset_is_from_end
52 "__preinit_array_end", // name
53 ".preinit_array", // output_section
56 elfcpp::STT_NOTYPE
, // type
57 elfcpp::STB_GLOBAL
, // binding
58 elfcpp::STV_HIDDEN
, // visibility
60 true, // offset_is_from_end
64 "__init_array_start", // name
65 ".init_array", // output_section
68 elfcpp::STT_NOTYPE
, // type
69 elfcpp::STB_GLOBAL
, // binding
70 elfcpp::STV_HIDDEN
, // visibility
72 false, // offset_is_from_end
76 "__init_array_end", // name
77 ".init_array", // output_section
80 elfcpp::STT_NOTYPE
, // type
81 elfcpp::STB_GLOBAL
, // binding
82 elfcpp::STV_HIDDEN
, // visibility
84 true, // offset_is_from_end
88 "__fini_array_start", // name
89 ".fini_array", // output_section
92 elfcpp::STT_NOTYPE
, // type
93 elfcpp::STB_GLOBAL
, // binding
94 elfcpp::STV_HIDDEN
, // visibility
96 false, // offset_is_from_end
100 "__fini_array_end", // name
101 ".fini_array", // output_section
104 elfcpp::STT_NOTYPE
, // type
105 elfcpp::STB_GLOBAL
, // binding
106 elfcpp::STV_HIDDEN
, // visibility
108 true, // offset_is_from_end
113 const int in_section_count
= sizeof in_section
/ sizeof in_section
[0];
115 const Define_symbol_in_segment in_segment
[] =
118 "__executable_start", // name
119 elfcpp::PT_LOAD
, // segment_type
120 elfcpp::PF(0), // segment_flags_set
121 elfcpp::PF(0), // segment_flags_clear
124 elfcpp::STT_NOTYPE
, // type
125 elfcpp::STB_GLOBAL
, // binding
126 elfcpp::STV_DEFAULT
, // visibility
128 Symbol::SEGMENT_START
, // offset_from_base
133 elfcpp::PT_LOAD
, // segment_type
134 elfcpp::PF_X
, // segment_flags_set
135 elfcpp::PF_W
, // segment_flags_clear
138 elfcpp::STT_NOTYPE
, // type
139 elfcpp::STB_GLOBAL
, // binding
140 elfcpp::STV_DEFAULT
, // visibility
142 Symbol::SEGMENT_END
, // offset_from_base
147 elfcpp::PT_LOAD
, // segment_type
148 elfcpp::PF_X
, // segment_flags_set
149 elfcpp::PF_W
, // segment_flags_clear
152 elfcpp::STT_NOTYPE
, // type
153 elfcpp::STB_GLOBAL
, // binding
154 elfcpp::STV_DEFAULT
, // visibility
156 Symbol::SEGMENT_END
, // offset_from_base
161 elfcpp::PT_LOAD
, // segment_type
162 elfcpp::PF_X
, // segment_flags_set
163 elfcpp::PF_W
, // segment_flags_clear
166 elfcpp::STT_NOTYPE
, // type
167 elfcpp::STB_GLOBAL
, // binding
168 elfcpp::STV_DEFAULT
, // visibility
170 Symbol::SEGMENT_END
, // offset_from_base
175 elfcpp::PT_LOAD
, // segment_type
176 elfcpp::PF_W
, // segment_flags_set
177 elfcpp::PF(0), // segment_flags_clear
180 elfcpp::STT_NOTYPE
, // type
181 elfcpp::STB_GLOBAL
, // binding
182 elfcpp::STV_DEFAULT
, // visibility
184 Symbol::SEGMENT_BSS
, // offset_from_base
189 elfcpp::PT_LOAD
, // segment_type
190 elfcpp::PF_W
, // segment_flags_set
191 elfcpp::PF(0), // segment_flags_clear
194 elfcpp::STT_NOTYPE
, // type
195 elfcpp::STB_GLOBAL
, // binding
196 elfcpp::STV_DEFAULT
, // visibility
198 Symbol::SEGMENT_BSS
, // offset_from_base
202 "__bss_start", // name
203 elfcpp::PT_LOAD
, // segment_type
204 elfcpp::PF_W
, // segment_flags_set
205 elfcpp::PF(0), // segment_flags_clear
208 elfcpp::STT_NOTYPE
, // type
209 elfcpp::STB_GLOBAL
, // binding
210 elfcpp::STV_DEFAULT
, // visibility
212 Symbol::SEGMENT_BSS
, // offset_from_base
217 elfcpp::PT_LOAD
, // segment_type
218 elfcpp::PF_W
, // segment_flags_set
219 elfcpp::PF(0), // segment_flags_clear
222 elfcpp::STT_NOTYPE
, // type
223 elfcpp::STB_GLOBAL
, // binding
224 elfcpp::STV_DEFAULT
, // visibility
226 Symbol::SEGMENT_END
, // offset_from_base
231 elfcpp::PT_LOAD
, // segment_type
232 elfcpp::PF_W
, // segment_flags_set
233 elfcpp::PF(0), // segment_flags_clear
236 elfcpp::STT_NOTYPE
, // type
237 elfcpp::STB_GLOBAL
, // binding
238 elfcpp::STV_DEFAULT
, // visibility
240 Symbol::SEGMENT_END
, // offset_from_base
245 const int in_segment_count
= sizeof in_segment
/ sizeof in_segment
[0];
247 } // End anonymous namespace.
253 define_standard_symbols(Symbol_table
* symtab
, const Layout
* layout
)
255 bool saw_sections_clause
= layout
->script_options()->saw_sections_clause();
256 symtab
->define_symbols(layout
, in_section_count
, in_section
,
257 saw_sections_clause
);
258 symtab
->define_symbols(layout
, in_segment_count
, in_segment
,
259 saw_sections_clause
);
262 } // End namespace gold.