OSDN Git Service

Fix some errors in symbol placement.
[pf3gnuchains/pf3gnuchains3x.git] / gold / defstd.cc
1 // defstd.cc -- define standard symbols for gold.
2
3 #include "gold.h"
4
5 #include "symtab.h"
6 #include "defstd.h"
7
8 // This is a simple file which defines the standard symbols like
9 // "_end".
10
11 namespace
12 {
13
14 using namespace gold;
15
16 const Define_symbol_in_section in_section[] =
17 {
18   {
19     "__preinit_array_start",    // name
20     ".preinit_array",           // output_section
21     0,                          // value
22     0,                          // size
23     elfcpp::STT_NOTYPE,         // type
24     elfcpp::STB_GLOBAL,         // binding
25     elfcpp::STV_HIDDEN,         // visibility
26     0,                          // nonvis
27     false,                      // offset_is_from_end
28     true                        // only_if_ref
29   },
30   {
31     "__preinit_array_end",      // name
32     ".preinit_array",           // output_section
33     0,                          // value
34     0,                          // size
35     elfcpp::STT_NOTYPE,         // type
36     elfcpp::STB_GLOBAL,         // binding
37     elfcpp::STV_HIDDEN,         // visibility
38     0,                          // nonvis
39     true,                       // offset_is_from_end
40     true                        // only_if_ref
41   },
42   {
43     "__init_array_start",       // name
44     ".init_array",              // output_section
45     0,                          // value
46     0,                          // size
47     elfcpp::STT_NOTYPE,         // type
48     elfcpp::STB_GLOBAL,         // binding
49     elfcpp::STV_HIDDEN,         // visibility
50     0,                          // nonvis
51     false,                      // offset_is_from_end
52     true                        // only_if_ref
53   },
54   {
55     "__init_array_end",         // name
56     ".init_array",              // output_section
57     0,                          // value
58     0,                          // size
59     elfcpp::STT_NOTYPE,         // type
60     elfcpp::STB_GLOBAL,         // binding
61     elfcpp::STV_HIDDEN,         // visibility
62     0,                          // nonvis
63     true,                       // offset_is_from_end
64     true                        // only_if_ref
65   },
66   {
67     "__fini_array_start",       // name
68     ".fini_array",              // output_section
69     0,                          // value
70     0,                          // size
71     elfcpp::STT_NOTYPE,         // type
72     elfcpp::STB_GLOBAL,         // binding
73     elfcpp::STV_HIDDEN,         // visibility
74     0,                          // nonvis
75     false,                      // offset_is_from_end
76     true                        // only_if_ref
77   },
78   {
79     "__fini_array_end",         // name
80     ".fini_array",              // output_section
81     0,                          // value
82     0,                          // size
83     elfcpp::STT_NOTYPE,         // type
84     elfcpp::STB_GLOBAL,         // binding
85     elfcpp::STV_HIDDEN,         // visibility
86     0,                          // nonvis
87     true,                       // offset_is_from_end
88     true                        // only_if_ref
89   }
90 };
91
92 const int in_section_count = sizeof in_section / sizeof in_section[0];
93
94 const Define_symbol_in_segment in_segment[] =
95 {
96   {
97     "__executable_start",       // name
98     elfcpp::PT_LOAD,            // segment_type
99     elfcpp::PF(0),              // segment_flags_set
100     elfcpp::PF(0),              // segment_flags_clear
101     0,                          // value
102     0,                          // size
103     elfcpp::STT_NOTYPE,         // type
104     elfcpp::STB_GLOBAL,         // binding
105     elfcpp::STV_DEFAULT,        // visibility
106     0,                          // nonvis
107     Symbol::SEGMENT_START,      // offset_from_base
108     true                        // only_if_ref
109   },
110   {
111     "etext",                    // name
112     elfcpp::PT_LOAD,            // segment_type
113     elfcpp::PF_X,               // segment_flags_set
114     elfcpp::PF_W,               // segment_flags_clear
115     0,                          // value
116     0,                          // size
117     elfcpp::STT_NOTYPE,         // type
118     elfcpp::STB_GLOBAL,         // binding
119     elfcpp::STV_DEFAULT,        // visibility
120     0,                          // nonvis
121     Symbol::SEGMENT_END,        // offset_from_base
122     true                        // only_if_ref
123   },
124   {
125     "_etext",                   // name
126     elfcpp::PT_LOAD,            // segment_type
127     elfcpp::PF_X,               // segment_flags_set
128     elfcpp::PF_W,               // segment_flags_clear
129     0,                          // value
130     0,                          // size
131     elfcpp::STT_NOTYPE,         // type
132     elfcpp::STB_GLOBAL,         // binding
133     elfcpp::STV_DEFAULT,        // visibility
134     0,                          // nonvis
135     Symbol::SEGMENT_END,        // offset_from_base
136     true                        // only_if_ref
137   },
138   {
139     "__etext",                  // name
140     elfcpp::PT_LOAD,            // segment_type
141     elfcpp::PF_X,               // segment_flags_set
142     elfcpp::PF_W,               // segment_flags_clear
143     0,                          // value
144     0,                          // size
145     elfcpp::STT_NOTYPE,         // type
146     elfcpp::STB_GLOBAL,         // binding
147     elfcpp::STV_DEFAULT,        // visibility
148     0,                          // nonvis
149     Symbol::SEGMENT_END,        // offset_from_base
150     true                        // only_if_ref
151   },
152   {
153     "_edata",                   // name
154     elfcpp::PT_LOAD,            // segment_type
155     elfcpp::PF_W,               // segment_flags_set
156     elfcpp::PF(0),              // segment_flags_clear
157     0,                          // value
158     0,                          // size
159     elfcpp::STT_NOTYPE,         // type
160     elfcpp::STB_GLOBAL,         // binding
161     elfcpp::STV_DEFAULT,        // visibility
162     0,                          // nonvis
163     Symbol::SEGMENT_BSS,        // offset_from_base
164     false                       // only_if_ref
165   },
166   {
167     "edata",                    // name
168     elfcpp::PT_LOAD,            // segment_type
169     elfcpp::PF_W,               // segment_flags_set
170     elfcpp::PF(0),              // segment_flags_clear
171     0,                          // value
172     0,                          // size
173     elfcpp::STT_NOTYPE,         // type
174     elfcpp::STB_GLOBAL,         // binding
175     elfcpp::STV_DEFAULT,        // visibility
176     0,                          // nonvis
177     Symbol::SEGMENT_BSS,        // offset_from_base
178     true                        // only_if_ref
179   },
180   {
181     "__bss_start",              // name
182     elfcpp::PT_LOAD,            // segment_type
183     elfcpp::PF_W,               // segment_flags_set
184     elfcpp::PF(0),              // segment_flags_clear
185     0,                          // value
186     0,                          // size
187     elfcpp::STT_NOTYPE,         // type
188     elfcpp::STB_GLOBAL,         // binding
189     elfcpp::STV_DEFAULT,        // visibility
190     0,                          // nonvis
191     Symbol::SEGMENT_BSS,        // offset_from_base
192     false                       // only_if_ref
193   },
194   {
195     "_end",                     // name
196     elfcpp::PT_LOAD,            // segment_type
197     elfcpp::PF_W,               // segment_flags_set
198     elfcpp::PF(0),              // segment_flags_clear
199     0,                          // value
200     0,                          // size
201     elfcpp::STT_NOTYPE,         // type
202     elfcpp::STB_GLOBAL,         // binding
203     elfcpp::STV_DEFAULT,        // visibility
204     0,                          // nonvis
205     Symbol::SEGMENT_END,        // offset_from_base
206     false                       // only_if_ref
207   },
208   {
209     "end",                      // name
210     elfcpp::PT_LOAD,            // segment_type
211     elfcpp::PF_W,               // segment_flags_set
212     elfcpp::PF(0),              // segment_flags_clear
213     0,                          // value
214     0,                          // size
215     elfcpp::STT_NOTYPE,         // type
216     elfcpp::STB_GLOBAL,         // binding
217     elfcpp::STV_DEFAULT,        // visibility
218     0,                          // nonvis
219     Symbol::SEGMENT_END,        // offset_from_base
220     false                       // only_if_ref
221   }
222 };
223
224 const int in_segment_count = sizeof in_segment / sizeof in_segment[0];
225
226 } // End anonymous namespace.
227
228 namespace gold
229 {
230
231 void
232 define_standard_symbols(Symbol_table* symtab, const Layout* layout,
233                         Target* target)
234 {
235   symtab->define_symbols(layout, target, in_section_count, in_section);
236   symtab->define_symbols(layout, target, in_segment_count, in_segment);
237 }
238
239 } // End namespace gold.