2006-11-03 18:26:11 +00:00
|
|
|
// defstd.cc -- define standard symbols for gold.
|
|
|
|
|
2010-08-19 22:50:16 +00:00
|
|
|
// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
2007-09-22 21:02:10 +00:00
|
|
|
// Written by Ian Lance Taylor <iant@google.com>.
|
|
|
|
|
|
|
|
// This file is part of gold.
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
// MA 02110-1301, USA.
|
|
|
|
|
2006-11-03 18:26:11 +00:00
|
|
|
#include "gold.h"
|
|
|
|
|
|
|
|
#include "symtab.h"
|
2008-02-04 05:43:05 +00:00
|
|
|
#include "layout.h"
|
2006-11-03 18:26:11 +00:00
|
|
|
#include "defstd.h"
|
|
|
|
|
|
|
|
// This is a simple file which defines the standard symbols like
|
|
|
|
// "_end".
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
|
|
|
using namespace gold;
|
|
|
|
|
|
|
|
const Define_symbol_in_section in_section[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"__preinit_array_start", // name
|
|
|
|
".preinit_array", // output_section
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_HIDDEN, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
false, // offset_is_from_end
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"__preinit_array_end", // name
|
|
|
|
".preinit_array", // output_section
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_HIDDEN, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
true, // offset_is_from_end
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"__init_array_start", // name
|
|
|
|
".init_array", // output_section
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_HIDDEN, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
false, // offset_is_from_end
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"__init_array_end", // name
|
|
|
|
".init_array", // output_section
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_HIDDEN, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
true, // offset_is_from_end
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"__fini_array_start", // name
|
|
|
|
".fini_array", // output_section
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_HIDDEN, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
false, // offset_is_from_end
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"__fini_array_end", // name
|
|
|
|
".fini_array", // output_section
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_HIDDEN, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
true, // offset_is_from_end
|
|
|
|
true // only_if_ref
|
2009-11-03 15:41:50 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"__stack", // name
|
|
|
|
".stack", // output_section
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
false, // offset_is_from_end
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
2006-11-03 18:26:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const int in_section_count = sizeof in_section / sizeof in_section[0];
|
|
|
|
|
|
|
|
const Define_symbol_in_segment in_segment[] =
|
|
|
|
{
|
2006-11-06 22:46:08 +00:00
|
|
|
{
|
|
|
|
"__executable_start", // name
|
|
|
|
elfcpp::PT_LOAD, // segment_type
|
|
|
|
elfcpp::PF(0), // segment_flags_set
|
|
|
|
elfcpp::PF(0), // segment_flags_clear
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
Symbol::SEGMENT_START, // offset_from_base
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"etext", // name
|
|
|
|
elfcpp::PT_LOAD, // segment_type
|
|
|
|
elfcpp::PF_X, // segment_flags_set
|
|
|
|
elfcpp::PF_W, // segment_flags_clear
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
Symbol::SEGMENT_END, // offset_from_base
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"_etext", // name
|
|
|
|
elfcpp::PT_LOAD, // segment_type
|
|
|
|
elfcpp::PF_X, // segment_flags_set
|
|
|
|
elfcpp::PF_W, // segment_flags_clear
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
Symbol::SEGMENT_END, // offset_from_base
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"__etext", // name
|
|
|
|
elfcpp::PT_LOAD, // segment_type
|
|
|
|
elfcpp::PF_X, // segment_flags_set
|
|
|
|
elfcpp::PF_W, // segment_flags_clear
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
Symbol::SEGMENT_END, // offset_from_base
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"_edata", // name
|
|
|
|
elfcpp::PT_LOAD, // segment_type
|
2007-09-22 04:38:13 +00:00
|
|
|
elfcpp::PF_W, // segment_flags_set
|
2006-11-06 22:46:08 +00:00
|
|
|
elfcpp::PF(0), // segment_flags_clear
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
Symbol::SEGMENT_BSS, // offset_from_base
|
|
|
|
false // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"edata", // name
|
|
|
|
elfcpp::PT_LOAD, // segment_type
|
2007-09-22 04:38:13 +00:00
|
|
|
elfcpp::PF_W, // segment_flags_set
|
2006-11-06 22:46:08 +00:00
|
|
|
elfcpp::PF(0), // segment_flags_clear
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
Symbol::SEGMENT_BSS, // offset_from_base
|
|
|
|
true // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"__bss_start", // name
|
|
|
|
elfcpp::PT_LOAD, // segment_type
|
2007-09-22 04:38:13 +00:00
|
|
|
elfcpp::PF_W, // segment_flags_set
|
2006-11-06 22:46:08 +00:00
|
|
|
elfcpp::PF(0), // segment_flags_clear
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
|
|
|
Symbol::SEGMENT_BSS, // offset_from_base
|
|
|
|
false // only_if_ref
|
|
|
|
},
|
2006-11-03 18:26:11 +00:00
|
|
|
{
|
|
|
|
"_end", // name
|
|
|
|
elfcpp::PT_LOAD, // segment_type
|
2007-09-22 04:38:13 +00:00
|
|
|
elfcpp::PF_W, // segment_flags_set
|
2006-11-06 22:46:08 +00:00
|
|
|
elfcpp::PF(0), // segment_flags_clear
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
2007-09-22 04:38:13 +00:00
|
|
|
Symbol::SEGMENT_END, // offset_from_base
|
2006-11-06 22:46:08 +00:00
|
|
|
false // only_if_ref
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"end", // name
|
|
|
|
elfcpp::PT_LOAD, // segment_type
|
2007-09-22 04:38:13 +00:00
|
|
|
elfcpp::PF_W, // segment_flags_set
|
2006-11-03 18:26:11 +00:00
|
|
|
elfcpp::PF(0), // segment_flags_clear
|
|
|
|
0, // value
|
|
|
|
0, // size
|
|
|
|
elfcpp::STT_NOTYPE, // type
|
|
|
|
elfcpp::STB_GLOBAL, // binding
|
|
|
|
elfcpp::STV_DEFAULT, // visibility
|
|
|
|
0, // nonvis
|
2007-09-22 04:38:13 +00:00
|
|
|
Symbol::SEGMENT_END, // offset_from_base
|
2009-11-07 02:02:29 +00:00
|
|
|
true // only_if_ref
|
2006-11-03 18:26:11 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const int in_segment_count = sizeof in_segment / sizeof in_segment[0];
|
|
|
|
|
|
|
|
} // End anonymous namespace.
|
|
|
|
|
|
|
|
namespace gold
|
|
|
|
{
|
|
|
|
|
|
|
|
void
|
2008-01-26 01:17:45 +00:00
|
|
|
define_standard_symbols(Symbol_table* symtab, const Layout* layout)
|
2006-11-03 18:26:11 +00:00
|
|
|
{
|
2008-02-04 05:43:05 +00:00
|
|
|
bool saw_sections_clause = layout->script_options()->saw_sections_clause();
|
|
|
|
symtab->define_symbols(layout, in_section_count, in_section,
|
|
|
|
saw_sections_clause);
|
|
|
|
symtab->define_symbols(layout, in_segment_count, in_segment,
|
|
|
|
saw_sections_clause);
|
2006-11-03 18:26:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End namespace gold.
|