1 // defstd.cc -- define standard symbols for gold.
3 // Copyright (C) 2006-2019 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 ".stack", // output_section
116 elfcpp::STT_NOTYPE
, // type
117 elfcpp::STB_GLOBAL
, // binding
118 elfcpp::STV_DEFAULT
, // visibility
120 false, // offset_is_from_end
125 const int in_section_count
= sizeof in_section
/ sizeof in_section
[0];
127 const Define_symbol_in_segment in_segment
[] =
130 "__executable_start", // name
131 elfcpp::PT_LOAD
, // segment_type
132 elfcpp::PF(0), // segment_flags_set
133 elfcpp::PF(0), // segment_flags_clear
136 elfcpp::STT_NOTYPE
, // type
137 elfcpp::STB_GLOBAL
, // binding
138 elfcpp::STV_DEFAULT
, // visibility
140 Symbol::SEGMENT_START
, // offset_from_base
144 "__ehdr_start", // name
145 elfcpp::PT_LOAD
, // segment_type
146 elfcpp::PF(0), // segment_flags_set
147 elfcpp::PF(0), // segment_flags_clear
150 elfcpp::STT_NOTYPE
, // type
151 elfcpp::STB_GLOBAL
, // binding
152 elfcpp::STV_HIDDEN
, // visibility
154 Symbol::SEGMENT_START
, // offset_from_base
159 elfcpp::PT_LOAD
, // segment_type
160 elfcpp::PF_X
, // segment_flags_set
161 elfcpp::PF_W
, // segment_flags_clear
164 elfcpp::STT_NOTYPE
, // type
165 elfcpp::STB_GLOBAL
, // binding
166 elfcpp::STV_DEFAULT
, // visibility
168 Symbol::SEGMENT_END
, // offset_from_base
173 elfcpp::PT_LOAD
, // segment_type
174 elfcpp::PF_X
, // segment_flags_set
175 elfcpp::PF_W
, // segment_flags_clear
178 elfcpp::STT_NOTYPE
, // type
179 elfcpp::STB_GLOBAL
, // binding
180 elfcpp::STV_DEFAULT
, // visibility
182 Symbol::SEGMENT_END
, // offset_from_base
187 elfcpp::PT_LOAD
, // segment_type
188 elfcpp::PF_X
, // segment_flags_set
189 elfcpp::PF_W
, // segment_flags_clear
192 elfcpp::STT_NOTYPE
, // type
193 elfcpp::STB_GLOBAL
, // binding
194 elfcpp::STV_DEFAULT
, // visibility
196 Symbol::SEGMENT_END
, // offset_from_base
201 elfcpp::PT_LOAD
, // segment_type
202 elfcpp::PF_W
, // segment_flags_set
203 elfcpp::PF(0), // segment_flags_clear
206 elfcpp::STT_NOTYPE
, // type
207 elfcpp::STB_GLOBAL
, // binding
208 elfcpp::STV_DEFAULT
, // visibility
210 Symbol::SEGMENT_BSS
, // offset_from_base
215 elfcpp::PT_LOAD
, // segment_type
216 elfcpp::PF_W
, // segment_flags_set
217 elfcpp::PF(0), // segment_flags_clear
220 elfcpp::STT_NOTYPE
, // type
221 elfcpp::STB_GLOBAL
, // binding
222 elfcpp::STV_DEFAULT
, // visibility
224 Symbol::SEGMENT_BSS
, // offset_from_base
228 "__bss_start", // name
229 elfcpp::PT_LOAD
, // segment_type
230 elfcpp::PF_W
, // segment_flags_set
231 elfcpp::PF(0), // segment_flags_clear
234 elfcpp::STT_NOTYPE
, // type
235 elfcpp::STB_GLOBAL
, // binding
236 elfcpp::STV_DEFAULT
, // visibility
238 Symbol::SEGMENT_BSS
, // offset_from_base
243 elfcpp::PT_LOAD
, // segment_type
244 elfcpp::PF_W
, // segment_flags_set
245 elfcpp::PF(0), // segment_flags_clear
248 elfcpp::STT_NOTYPE
, // type
249 elfcpp::STB_GLOBAL
, // binding
250 elfcpp::STV_DEFAULT
, // visibility
252 Symbol::SEGMENT_END
, // offset_from_base
257 elfcpp::PT_LOAD
, // segment_type
258 elfcpp::PF_W
, // segment_flags_set
259 elfcpp::PF(0), // segment_flags_clear
262 elfcpp::STT_NOTYPE
, // type
263 elfcpp::STB_GLOBAL
, // binding
264 elfcpp::STV_DEFAULT
, // visibility
266 Symbol::SEGMENT_END
, // offset_from_base
271 const int in_segment_count
= sizeof in_segment
/ sizeof in_segment
[0];
273 } // End anonymous namespace.
279 define_standard_symbols(Symbol_table
* symtab
, const Layout
* layout
)
281 bool saw_sections_clause
= layout
->script_options()->saw_sections_clause();
282 symtab
->define_symbols(layout
, in_section_count
, in_section
,
283 saw_sections_clause
);
284 symtab
->define_symbols(layout
, in_segment_count
, in_segment
,
285 saw_sections_clause
);
288 } // End namespace gold.