Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / contrib / binutils-2.20 / gold / defstd.cc
1 // defstd.cc -- define standard symbols for gold.
2
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
5
6 // This file is part of gold.
7
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.
12
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.
17
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.
22
23 #include "gold.h"
24
25 #include "symtab.h"
26 #include "layout.h"
27 #include "defstd.h"
28
29 // This is a simple file which defines the standard symbols like
30 // "_end".
31
32 namespace
33 {
34
35 using namespace gold;
36
37 const Define_symbol_in_section in_section[] =
38 {
39   {
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
50   },
51   {
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
62   },
63   {
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
74   },
75   {
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
86   },
87   {
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
98   },
99   {
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
110   },
111   {
112     "__rel_iplt_start",         // name
113     ".rel.iplt",                // output_section
114     0,                          // value
115     0,                          // size
116     elfcpp::STT_NOTYPE,         // type
117     elfcpp::STB_GLOBAL,         // binding
118     elfcpp::STV_HIDDEN,         // visibility
119     0,                          // nonvis
120     false,                      // offset_is_from_end
121     true                        // only_if_ref
122   },
123   {
124     "__rel_iplt_end",           // name
125     ".rel.iplt",                // output_section
126     0,                          // value
127     0,                          // size
128     elfcpp::STT_NOTYPE,         // type
129     elfcpp::STB_GLOBAL,         // binding
130     elfcpp::STV_HIDDEN,         // visibility
131     0,                          // nonvis
132     true,                       // offset_is_from_end
133     true                        // only_if_ref
134   },
135   {
136     "__rela_iplt_start",        // name
137     ".rela.iplt",               // output_section
138     0,                          // value
139     0,                          // size
140     elfcpp::STT_NOTYPE,         // type
141     elfcpp::STB_GLOBAL,         // binding
142     elfcpp::STV_HIDDEN,         // visibility
143     0,                          // nonvis
144     false,                      // offset_is_from_end
145     true                        // only_if_ref
146   },
147   {
148     "__rela_iplt_end",          // name
149     ".rela.iplt",               // output_section
150     0,                          // value
151     0,                          // size
152     elfcpp::STT_NOTYPE,         // type
153     elfcpp::STB_GLOBAL,         // binding
154     elfcpp::STV_HIDDEN,         // visibility
155     0,                          // nonvis
156     true,                       // offset_is_from_end
157     true                        // only_if_ref
158   },
159   {
160     "__stack",                  // name
161     ".stack",                   // output_section
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     false,                      // offset_is_from_end
169     true                        // only_if_ref
170   },
171 };
172
173 const int in_section_count = sizeof in_section / sizeof in_section[0];
174
175 const Define_symbol_in_segment in_segment[] =
176 {
177   {
178     "__executable_start",       // name
179     elfcpp::PT_LOAD,            // segment_type
180     elfcpp::PF(0),              // segment_flags_set
181     elfcpp::PF(0),              // segment_flags_clear
182     0,                          // value
183     0,                          // size
184     elfcpp::STT_NOTYPE,         // type
185     elfcpp::STB_GLOBAL,         // binding
186     elfcpp::STV_DEFAULT,        // visibility
187     0,                          // nonvis
188     Symbol::SEGMENT_START,      // offset_from_base
189     true                        // only_if_ref
190   },
191   {
192     "etext",                    // name
193     elfcpp::PT_LOAD,            // segment_type
194     elfcpp::PF_X,               // segment_flags_set
195     elfcpp::PF_W,               // segment_flags_clear
196     0,                          // value
197     0,                          // size
198     elfcpp::STT_NOTYPE,         // type
199     elfcpp::STB_GLOBAL,         // binding
200     elfcpp::STV_DEFAULT,        // visibility
201     0,                          // nonvis
202     Symbol::SEGMENT_END,        // offset_from_base
203     true                        // only_if_ref
204   },
205   {
206     "_etext",                   // name
207     elfcpp::PT_LOAD,            // segment_type
208     elfcpp::PF_X,               // segment_flags_set
209     elfcpp::PF_W,               // segment_flags_clear
210     0,                          // value
211     0,                          // size
212     elfcpp::STT_NOTYPE,         // type
213     elfcpp::STB_GLOBAL,         // binding
214     elfcpp::STV_DEFAULT,        // visibility
215     0,                          // nonvis
216     Symbol::SEGMENT_END,        // offset_from_base
217     true                        // only_if_ref
218   },
219   {
220     "__etext",                  // name
221     elfcpp::PT_LOAD,            // segment_type
222     elfcpp::PF_X,               // segment_flags_set
223     elfcpp::PF_W,               // segment_flags_clear
224     0,                          // value
225     0,                          // size
226     elfcpp::STT_NOTYPE,         // type
227     elfcpp::STB_GLOBAL,         // binding
228     elfcpp::STV_DEFAULT,        // visibility
229     0,                          // nonvis
230     Symbol::SEGMENT_END,        // offset_from_base
231     true                        // only_if_ref
232   },
233   {
234     "_edata",                   // name
235     elfcpp::PT_LOAD,            // segment_type
236     elfcpp::PF_W,               // segment_flags_set
237     elfcpp::PF(0),              // segment_flags_clear
238     0,                          // value
239     0,                          // size
240     elfcpp::STT_NOTYPE,         // type
241     elfcpp::STB_GLOBAL,         // binding
242     elfcpp::STV_DEFAULT,        // visibility
243     0,                          // nonvis
244     Symbol::SEGMENT_BSS,        // offset_from_base
245     false                       // only_if_ref
246   },
247   {
248     "edata",                    // name
249     elfcpp::PT_LOAD,            // segment_type
250     elfcpp::PF_W,               // segment_flags_set
251     elfcpp::PF(0),              // segment_flags_clear
252     0,                          // value
253     0,                          // size
254     elfcpp::STT_NOTYPE,         // type
255     elfcpp::STB_GLOBAL,         // binding
256     elfcpp::STV_DEFAULT,        // visibility
257     0,                          // nonvis
258     Symbol::SEGMENT_BSS,        // offset_from_base
259     true                        // only_if_ref
260   },
261   {
262     "__bss_start",              // name
263     elfcpp::PT_LOAD,            // segment_type
264     elfcpp::PF_W,               // segment_flags_set
265     elfcpp::PF(0),              // segment_flags_clear
266     0,                          // value
267     0,                          // size
268     elfcpp::STT_NOTYPE,         // type
269     elfcpp::STB_GLOBAL,         // binding
270     elfcpp::STV_DEFAULT,        // visibility
271     0,                          // nonvis
272     Symbol::SEGMENT_BSS,        // offset_from_base
273     false                       // only_if_ref
274   },
275   {
276     "_end",                     // name
277     elfcpp::PT_LOAD,            // segment_type
278     elfcpp::PF_W,               // segment_flags_set
279     elfcpp::PF(0),              // segment_flags_clear
280     0,                          // value
281     0,                          // size
282     elfcpp::STT_NOTYPE,         // type
283     elfcpp::STB_GLOBAL,         // binding
284     elfcpp::STV_DEFAULT,        // visibility
285     0,                          // nonvis
286     Symbol::SEGMENT_END,        // offset_from_base
287     false                       // only_if_ref
288   },
289   {
290     "end",                      // name
291     elfcpp::PT_LOAD,            // segment_type
292     elfcpp::PF_W,               // segment_flags_set
293     elfcpp::PF(0),              // segment_flags_clear
294     0,                          // value
295     0,                          // size
296     elfcpp::STT_NOTYPE,         // type
297     elfcpp::STB_GLOBAL,         // binding
298     elfcpp::STV_DEFAULT,        // visibility
299     0,                          // nonvis
300     Symbol::SEGMENT_END,        // offset_from_base
301     true                        // only_if_ref
302   }
303 };
304
305 const int in_segment_count = sizeof in_segment / sizeof in_segment[0];
306
307 } // End anonymous namespace.
308
309 namespace gold
310 {
311
312 void
313 define_standard_symbols(Symbol_table* symtab, const Layout* layout)
314 {
315   bool saw_sections_clause = layout->script_options()->saw_sections_clause();
316   symtab->define_symbols(layout, in_section_count, in_section,
317                          saw_sections_clause);
318   symtab->define_symbols(layout, in_segment_count, in_segment,
319                          saw_sections_clause);
320 }
321
322 } // End namespace gold.