Fix building for the s390 target with clang
[binutils-gdb.git] / gold / defstd.cc
blob98b69b34f612bebd225a665af0b741a7b2d73694
1 // defstd.cc -- define standard symbols for gold.
3 // Copyright (C) 2006-2023 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 #include "gold.h"
25 #include "symtab.h"
26 #include "layout.h"
27 #include "defstd.h"
29 // This is a simple file which defines the standard symbols like
30 // "_end".
32 namespace
35 using namespace gold;
37 const Define_symbol_in_section in_section[] =
40 "__preinit_array_start", // name
41 ".preinit_array", // output_section
42 0, // value
43 0, // size
44 elfcpp::STT_NOTYPE, // type
45 elfcpp::STB_GLOBAL, // binding
46 elfcpp::STV_HIDDEN, // visibility
47 0, // nonvis
48 false, // offset_is_from_end
49 true // only_if_ref
52 "__preinit_array_end", // name
53 ".preinit_array", // output_section
54 0, // value
55 0, // size
56 elfcpp::STT_NOTYPE, // type
57 elfcpp::STB_GLOBAL, // binding
58 elfcpp::STV_HIDDEN, // visibility
59 0, // nonvis
60 true, // offset_is_from_end
61 true // only_if_ref
64 "__init_array_start", // name
65 ".init_array", // output_section
66 0, // value
67 0, // size
68 elfcpp::STT_NOTYPE, // type
69 elfcpp::STB_GLOBAL, // binding
70 elfcpp::STV_HIDDEN, // visibility
71 0, // nonvis
72 false, // offset_is_from_end
73 true // only_if_ref
76 "__init_array_end", // name
77 ".init_array", // output_section
78 0, // value
79 0, // size
80 elfcpp::STT_NOTYPE, // type
81 elfcpp::STB_GLOBAL, // binding
82 elfcpp::STV_HIDDEN, // visibility
83 0, // nonvis
84 true, // offset_is_from_end
85 true // only_if_ref
88 "__fini_array_start", // name
89 ".fini_array", // output_section
90 0, // value
91 0, // size
92 elfcpp::STT_NOTYPE, // type
93 elfcpp::STB_GLOBAL, // binding
94 elfcpp::STV_HIDDEN, // visibility
95 0, // nonvis
96 false, // offset_is_from_end
97 true // only_if_ref
100 "__fini_array_end", // name
101 ".fini_array", // output_section
102 0, // value
103 0, // size
104 elfcpp::STT_NOTYPE, // type
105 elfcpp::STB_GLOBAL, // binding
106 elfcpp::STV_HIDDEN, // visibility
107 0, // nonvis
108 true, // offset_is_from_end
109 true // only_if_ref
112 "__stack", // name
113 ".stack", // output_section
114 0, // value
115 0, // size
116 elfcpp::STT_NOTYPE, // type
117 elfcpp::STB_GLOBAL, // binding
118 elfcpp::STV_DEFAULT, // visibility
119 0, // nonvis
120 false, // offset_is_from_end
121 true // only_if_ref
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
134 0, // value
135 0, // size
136 elfcpp::STT_NOTYPE, // type
137 elfcpp::STB_GLOBAL, // binding
138 elfcpp::STV_DEFAULT, // visibility
139 0, // nonvis
140 Symbol::SEGMENT_START, // offset_from_base
141 true // only_if_ref
144 "__ehdr_start", // name
145 elfcpp::PT_LOAD, // segment_type
146 elfcpp::PF(0), // segment_flags_set
147 elfcpp::PF(0), // segment_flags_clear
148 0, // value
149 0, // size
150 elfcpp::STT_NOTYPE, // type
151 elfcpp::STB_GLOBAL, // binding
152 elfcpp::STV_HIDDEN, // visibility
153 0, // nonvis
154 Symbol::SEGMENT_START, // offset_from_base
155 true // only_if_ref
158 "etext", // name
159 elfcpp::PT_LOAD, // segment_type
160 elfcpp::PF_X, // segment_flags_set
161 elfcpp::PF_W, // segment_flags_clear
162 0, // value
163 0, // size
164 elfcpp::STT_NOTYPE, // type
165 elfcpp::STB_GLOBAL, // binding
166 elfcpp::STV_DEFAULT, // visibility
167 0, // nonvis
168 Symbol::SEGMENT_END, // offset_from_base
169 true // only_if_ref
172 "_etext", // name
173 elfcpp::PT_LOAD, // segment_type
174 elfcpp::PF_X, // segment_flags_set
175 elfcpp::PF_W, // segment_flags_clear
176 0, // value
177 0, // size
178 elfcpp::STT_NOTYPE, // type
179 elfcpp::STB_GLOBAL, // binding
180 elfcpp::STV_DEFAULT, // visibility
181 0, // nonvis
182 Symbol::SEGMENT_END, // offset_from_base
183 true // only_if_ref
186 "__etext", // name
187 elfcpp::PT_LOAD, // segment_type
188 elfcpp::PF_X, // segment_flags_set
189 elfcpp::PF_W, // segment_flags_clear
190 0, // value
191 0, // size
192 elfcpp::STT_NOTYPE, // type
193 elfcpp::STB_GLOBAL, // binding
194 elfcpp::STV_DEFAULT, // visibility
195 0, // nonvis
196 Symbol::SEGMENT_END, // offset_from_base
197 true // only_if_ref
200 "_edata", // name
201 elfcpp::PT_LOAD, // segment_type
202 elfcpp::PF_W, // segment_flags_set
203 elfcpp::PF(0), // segment_flags_clear
204 0, // value
205 0, // size
206 elfcpp::STT_NOTYPE, // type
207 elfcpp::STB_GLOBAL, // binding
208 elfcpp::STV_DEFAULT, // visibility
209 0, // nonvis
210 Symbol::SEGMENT_BSS, // offset_from_base
211 false // only_if_ref
214 "edata", // name
215 elfcpp::PT_LOAD, // segment_type
216 elfcpp::PF_W, // segment_flags_set
217 elfcpp::PF(0), // segment_flags_clear
218 0, // value
219 0, // size
220 elfcpp::STT_NOTYPE, // type
221 elfcpp::STB_GLOBAL, // binding
222 elfcpp::STV_DEFAULT, // visibility
223 0, // nonvis
224 Symbol::SEGMENT_BSS, // offset_from_base
225 true // only_if_ref
228 "__bss_start", // name
229 elfcpp::PT_LOAD, // segment_type
230 elfcpp::PF_W, // segment_flags_set
231 elfcpp::PF(0), // segment_flags_clear
232 0, // value
233 0, // size
234 elfcpp::STT_NOTYPE, // type
235 elfcpp::STB_GLOBAL, // binding
236 elfcpp::STV_DEFAULT, // visibility
237 0, // nonvis
238 Symbol::SEGMENT_BSS, // offset_from_base
239 false // only_if_ref
242 "_end", // name
243 elfcpp::PT_LOAD, // segment_type
244 elfcpp::PF_W, // segment_flags_set
245 elfcpp::PF(0), // segment_flags_clear
246 0, // value
247 0, // size
248 elfcpp::STT_NOTYPE, // type
249 elfcpp::STB_GLOBAL, // binding
250 elfcpp::STV_DEFAULT, // visibility
251 0, // nonvis
252 Symbol::SEGMENT_END, // offset_from_base
253 false // only_if_ref
256 "end", // name
257 elfcpp::PT_LOAD, // segment_type
258 elfcpp::PF_W, // segment_flags_set
259 elfcpp::PF(0), // segment_flags_clear
260 0, // value
261 0, // size
262 elfcpp::STT_NOTYPE, // type
263 elfcpp::STB_GLOBAL, // binding
264 elfcpp::STV_DEFAULT, // visibility
265 0, // nonvis
266 Symbol::SEGMENT_END, // offset_from_base
267 true // only_if_ref
271 const int in_segment_count = sizeof in_segment / sizeof in_segment[0];
273 } // End anonymous namespace.
275 namespace gold
278 void
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.