PR 10450
* i386.cc (class Target_i386): Initialize global_offset_table_ in constructor. Add global_offset_table_ field. (Target_i386::got_section): Set global_offset_table_. (Target_i386::do_finalize_sections): Set global_offset_table_ size. * x86_64.cc (class Target_x86_64): Initialize global_offset_table_ in constructor. Add global_offset_table_ field. (Target_x86_64::got_section): Set global_offset_table_. (Target_x86_64::do_finalize_sections): Set global_offset_table_ size.
This commit is contained in:
parent
1a2dff539b
commit
e785ec03fb
3 changed files with 56 additions and 20 deletions
|
@ -1,5 +1,17 @@
|
|||
2009-12-29 Ian Lance Taylor <iant@google.com>
|
||||
|
||||
PR 10450
|
||||
* i386.cc (class Target_i386): Initialize global_offset_table_ in
|
||||
constructor. Add global_offset_table_ field.
|
||||
(Target_i386::got_section): Set global_offset_table_.
|
||||
(Target_i386::do_finalize_sections): Set global_offset_table_
|
||||
size.
|
||||
* x86_64.cc (class Target_x86_64): Initialize global_offset_table_
|
||||
in constructor. Add global_offset_table_ field.
|
||||
(Target_x86_64::got_section): Set global_offset_table_.
|
||||
(Target_x86_64::do_finalize_sections): Set global_offset_table_
|
||||
size.
|
||||
|
||||
* layout.cc (Layout::Layout): Initialize increase_relro_.
|
||||
(Layout::get_output_section): Add is_relro, is_last_relro, and
|
||||
is_first_non_relro parameters. Change all callers.
|
||||
|
|
32
gold/i386.cc
32
gold/i386.cc
|
@ -59,8 +59,8 @@ class Target_i386 : public Target_freebsd<32, false>
|
|||
|
||||
Target_i386()
|
||||
: Target_freebsd<32, false>(&i386_info),
|
||||
got_(NULL), plt_(NULL), got_plt_(NULL), rel_dyn_(NULL),
|
||||
copy_relocs_(elfcpp::R_386_COPY), dynbss_(NULL),
|
||||
got_(NULL), plt_(NULL), got_plt_(NULL), global_offset_table_(NULL),
|
||||
rel_dyn_(NULL), copy_relocs_(elfcpp::R_386_COPY), dynbss_(NULL),
|
||||
got_mod_index_offset_(-1U), tls_base_symbol_defined_(false)
|
||||
{ }
|
||||
|
||||
|
@ -412,6 +412,8 @@ class Target_i386 : public Target_freebsd<32, false>
|
|||
Output_data_plt_i386* plt_;
|
||||
// The GOT PLT section.
|
||||
Output_data_space* got_plt_;
|
||||
// The _GLOBAL_OFFSET_TABLE_ symbol.
|
||||
Symbol* global_offset_table_;
|
||||
// The dynamic reloc section.
|
||||
Reloc_section* rel_dyn_;
|
||||
// Relocs saved to avoid a COPY reloc.
|
||||
|
@ -478,13 +480,14 @@ Target_i386::got_section(Symbol_table* symtab, Layout* layout)
|
|||
layout->increase_relro(3 * 4);
|
||||
|
||||
// Define _GLOBAL_OFFSET_TABLE_ at the start of the PLT.
|
||||
symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL,
|
||||
Symbol_table::PREDEFINED,
|
||||
this->got_plt_,
|
||||
0, 0, elfcpp::STT_OBJECT,
|
||||
elfcpp::STB_LOCAL,
|
||||
elfcpp::STV_HIDDEN, 0,
|
||||
false, false);
|
||||
this->global_offset_table_ =
|
||||
symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL,
|
||||
Symbol_table::PREDEFINED,
|
||||
this->got_plt_,
|
||||
0, 0, elfcpp::STT_OBJECT,
|
||||
elfcpp::STB_LOCAL,
|
||||
elfcpp::STV_HIDDEN, 0,
|
||||
false, false);
|
||||
}
|
||||
|
||||
return this->got_;
|
||||
|
@ -1560,7 +1563,7 @@ void
|
|||
Target_i386::do_finalize_sections(
|
||||
Layout* layout,
|
||||
const Input_objects*,
|
||||
Symbol_table*)
|
||||
Symbol_table* symtab)
|
||||
{
|
||||
// Fill in some more dynamic tags.
|
||||
Output_data_dynamic* const odyn = layout->dynamic_data();
|
||||
|
@ -1601,6 +1604,15 @@ Target_i386::do_finalize_sections(
|
|||
// relocs.
|
||||
if (this->copy_relocs_.any_saved_relocs())
|
||||
this->copy_relocs_.emit(this->rel_dyn_section(layout));
|
||||
|
||||
// Set the size of the _GLOBAL_OFFSET_TABLE_ symbol to the size of
|
||||
// the .got.plt section.
|
||||
Symbol* sym = this->global_offset_table_;
|
||||
if (sym != NULL)
|
||||
{
|
||||
uint32_t data_size = this->got_plt_->current_data_size();
|
||||
symtab->get_sized_symbol<32>(sym)->set_symsize(data_size);
|
||||
}
|
||||
}
|
||||
|
||||
// Return whether a direct absolute static relocation needs to be applied.
|
||||
|
|
|
@ -63,8 +63,8 @@ class Target_x86_64 : public Target_freebsd<64, false>
|
|||
|
||||
Target_x86_64()
|
||||
: Target_freebsd<64, false>(&x86_64_info),
|
||||
got_(NULL), plt_(NULL), got_plt_(NULL), rela_dyn_(NULL),
|
||||
copy_relocs_(elfcpp::R_X86_64_COPY), dynbss_(NULL),
|
||||
got_(NULL), plt_(NULL), got_plt_(NULL), global_offset_table_(NULL),
|
||||
rela_dyn_(NULL), copy_relocs_(elfcpp::R_X86_64_COPY), dynbss_(NULL),
|
||||
got_mod_index_offset_(-1U), tls_base_symbol_defined_(false)
|
||||
{ }
|
||||
|
||||
|
@ -410,6 +410,8 @@ class Target_x86_64 : public Target_freebsd<64, false>
|
|||
Output_data_plt_x86_64* plt_;
|
||||
// The GOT PLT section.
|
||||
Output_data_space* got_plt_;
|
||||
// The _GLOBAL_OFFSET_TABLE_ symbol.
|
||||
Symbol* global_offset_table_;
|
||||
// The dynamic reloc section.
|
||||
Reloc_section* rela_dyn_;
|
||||
// Relocs saved to avoid a COPY reloc.
|
||||
|
@ -486,13 +488,14 @@ Target_x86_64::got_section(Symbol_table* symtab, Layout* layout)
|
|||
layout->increase_relro(3 * 8);
|
||||
|
||||
// Define _GLOBAL_OFFSET_TABLE_ at the start of the PLT.
|
||||
symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL,
|
||||
Symbol_table::PREDEFINED,
|
||||
this->got_plt_,
|
||||
0, 0, elfcpp::STT_OBJECT,
|
||||
elfcpp::STB_LOCAL,
|
||||
elfcpp::STV_HIDDEN, 0,
|
||||
false, false);
|
||||
this->global_offset_table_ =
|
||||
symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL,
|
||||
Symbol_table::PREDEFINED,
|
||||
this->got_plt_,
|
||||
0, 0, elfcpp::STT_OBJECT,
|
||||
elfcpp::STB_LOCAL,
|
||||
elfcpp::STV_HIDDEN, 0,
|
||||
false, false);
|
||||
}
|
||||
|
||||
return this->got_;
|
||||
|
@ -1650,7 +1653,7 @@ void
|
|||
Target_x86_64::do_finalize_sections(
|
||||
Layout* layout,
|
||||
const Input_objects*,
|
||||
Symbol_table*)
|
||||
Symbol_table* symtab)
|
||||
{
|
||||
// Fill in some more dynamic tags.
|
||||
Output_data_dynamic* const odyn = layout->dynamic_data();
|
||||
|
@ -1701,6 +1704,15 @@ Target_x86_64::do_finalize_sections(
|
|||
// relocs.
|
||||
if (this->copy_relocs_.any_saved_relocs())
|
||||
this->copy_relocs_.emit(this->rela_dyn_section(layout));
|
||||
|
||||
// Set the size of the _GLOBAL_OFFSET_TABLE_ symbol to the size of
|
||||
// the .got.plt section.
|
||||
Symbol* sym = this->global_offset_table_;
|
||||
if (sym != NULL)
|
||||
{
|
||||
uint64_t data_size = this->got_plt_->current_data_size();
|
||||
symtab->get_sized_symbol<64>(sym)->set_symsize(data_size);
|
||||
}
|
||||
}
|
||||
|
||||
// Perform a relocation.
|
||||
|
|
Loading…
Reference in a new issue