Can now do a full static link of hello, world in C or C++
[platform/upstream/binutils.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     "_end",                     // name
98     elfcpp::PT_LOAD,            // segment_type
99     elfcpp::PF_W,               // 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_bas
108     false                       // only_if_ref
109   }
110 };
111
112 const int in_segment_count = sizeof in_segment / sizeof in_segment[0];
113
114 } // End anonymous namespace.
115
116 namespace gold
117 {
118
119 void
120 define_standard_symbols(Symbol_table* symtab, const Layout* layout,
121                         Target* target)
122 {
123   symtab->define_symbols(layout, target, in_section_count, in_section);
124   symtab->define_symbols(layout, target, in_segment_count, in_segment);
125 }
126
127 } // End namespace gold.