* object.h (Relobj::local_symbol_value): New function.

(Relobj::local_plt_offset): New function.
	(Relobj::local_has_got_offset): New function.
	(Relobj::local_got_offset): New function.
	(Relobj::set_local_got_offset): New function.
	(Relobj::do_local_symbol_value): New pure virtual function.
	(Relobj::do_local_plt_offset): Likewise.
	(Relobj::do_local_has_got_offset): Likewise.
	(Relobj::do_local_got_offset): Likewise.
	(Relobj::do_set_local_got_offset): Likewise.
	(Sized_relobj::do_local_has_got_offset): Rename from
	local_has_got_offset.
	(Sized_relobj::do_local_got_offset): Rename from local_got_offset.
	(Sized_relobj::do_set_local_got_offset): Rename from
	set_local_got_offset.
	(Sized_relobj_file::do_local_plt_offset): Rename from
	local_plt_offset.
	(Sized_relobj_file::do_local_symbol_value): New function.
	* object.cc (Sized_relobj_file::do_local_plt_offset): Rename from
	local_plt_offset.
	* output.cc (Output_data_got::Got_entry::write): Change object to
	Relobj.  Use local_symbol_value.
	(Output_data_got::add_global_with_rel): Change rel_dyn to
	Output_data_reloc_generic*.  Use add_global_generic.
	(Output_data_got::add_global_with_rela): Remove.  Change all
	callers to use add_global_with_rel.
	(Output_data_got::add_global_pair_with_rel): Change rel_dyn to
	Output_data_reloc_generic*.  Use add_global_generic.
	(Output_data_got::add_global_pair_with_rela): Remove.  Change all
	callers to use add_global_pair_with_rel.
	(Output_data_got::add_local): Change object to Relobj*.
	(Output_data_got::add_local_plt): Likewise.
	(Output_data_got::add_local_with_rel): Change object to Relobj*,
	change rel_dyn to Output_data_reloc_generic*.  Use
	add_local_generic.
	(Output_data_got::add_local_with_rela): Remove.  Change all
	callers to use all_local_with_rel.
	(Output_data_got::add_local_pair_with_rel): Change object to
	Relobj*, change rel_dyn to Output_data_reloc_generic*.  Use
	add_output_section_generic.
	(Output_data_got::add_local_pair_with_rela): Remove.  Change all
	callers to use add_local_pair_with_rel.
	(Output_data_got::reserve_local): Change object to Relobj*.
	* output.h: (class Output_data_reloc_generic): Add pure virtual
	declarations for add_global_generic, add_local_generic,
	add_output_section_generic.
	(class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new
	functions for Output_data_reloc_generic.  Update declarations for
	changes listed in output.cc.
	(class Output_data_got): Change template parameter to got_size.
	Don't define Rel_dyn or Rela_dyn.  Update declarations per above.
	* incremental.h (Sized_relobj_incr::do_local_symbol_value): New
	function.
	(Sized_relobj_incr::do_local_plt_offset): New function.
	* copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call
	add_global_generic.
This commit is contained in:
Ian Lance Taylor
2011-12-19 21:07:16 +00:00
parent 984ac46443
commit 83896202bf
11 changed files with 475 additions and 264 deletions

View File

@@ -1387,11 +1387,13 @@ Output_data_got<size, big_endian>::Got_entry::write(unsigned char* pov) const
default:
{
const Sized_relobj_file<size, big_endian>* object = this->u_.object;
const Relobj* object = this->u_.object;
const unsigned int lsi = this->local_sym_index_;
const Symbol_value<size>* symval = object->local_symbol(lsi);
if (!this->use_plt_offset_)
val = symval->value(this->u_.object, 0);
{
uint64_t lval = object->local_symbol_value(lsi, 0);
val = convert_types<Valtype, uint64_t>(lval);
}
else
{
uint64_t plt_address =
@@ -1448,7 +1450,7 @@ void
Output_data_got<size, big_endian>::add_global_with_rel(
Symbol* gsym,
unsigned int got_type,
Rel_dyn* rel_dyn,
Output_data_reloc_generic* rel_dyn,
unsigned int r_type)
{
if (gsym->has_got_offset(got_type))
@@ -1456,23 +1458,7 @@ Output_data_got<size, big_endian>::add_global_with_rel(
unsigned int got_offset = this->add_got_entry(Got_entry());
gsym->set_got_offset(got_type, got_offset);
rel_dyn->add_global(gsym, r_type, this, got_offset);
}
template<int size, bool big_endian>
void
Output_data_got<size, big_endian>::add_global_with_rela(
Symbol* gsym,
unsigned int got_type,
Rela_dyn* rela_dyn,
unsigned int r_type)
{
if (gsym->has_got_offset(got_type))
return;
unsigned int got_offset = this->add_got_entry(Got_entry());
gsym->set_got_offset(got_type, got_offset);
rela_dyn->add_global(gsym, r_type, this, got_offset, 0);
rel_dyn->add_global_generic(gsym, r_type, this, got_offset, 0);
}
// Add a pair of entries for a global symbol to the GOT, and add
@@ -1483,7 +1469,7 @@ void
Output_data_got<size, big_endian>::add_global_pair_with_rel(
Symbol* gsym,
unsigned int got_type,
Rel_dyn* rel_dyn,
Output_data_reloc_generic* rel_dyn,
unsigned int r_type_1,
unsigned int r_type_2)
{
@@ -1492,30 +1478,11 @@ Output_data_got<size, big_endian>::add_global_pair_with_rel(
unsigned int got_offset = this->add_got_entry_pair(Got_entry(), Got_entry());
gsym->set_got_offset(got_type, got_offset);
rel_dyn->add_global(gsym, r_type_1, this, got_offset);
rel_dyn->add_global_generic(gsym, r_type_1, this, got_offset, 0);
if (r_type_2 != 0)
rel_dyn->add_global(gsym, r_type_2, this, got_offset + size / 8);
}
template<int size, bool big_endian>
void
Output_data_got<size, big_endian>::add_global_pair_with_rela(
Symbol* gsym,
unsigned int got_type,
Rela_dyn* rela_dyn,
unsigned int r_type_1,
unsigned int r_type_2)
{
if (gsym->has_got_offset(got_type))
return;
unsigned int got_offset = this->add_got_entry_pair(Got_entry(), Got_entry());
gsym->set_got_offset(got_type, got_offset);
rela_dyn->add_global(gsym, r_type_1, this, got_offset, 0);
if (r_type_2 != 0)
rela_dyn->add_global(gsym, r_type_2, this, got_offset + size / 8, 0);
rel_dyn->add_global_generic(gsym, r_type_2, this,
got_offset + size / 8, 0);
}
// Add an entry for a local symbol to the GOT. This returns true if
@@ -1525,7 +1492,7 @@ Output_data_got<size, big_endian>::add_global_pair_with_rela(
template<int size, bool big_endian>
bool
Output_data_got<size, big_endian>::add_local(
Sized_relobj_file<size, big_endian>* object,
Relobj* object,
unsigned int symndx,
unsigned int got_type)
{
@@ -1543,7 +1510,7 @@ Output_data_got<size, big_endian>::add_local(
template<int size, bool big_endian>
bool
Output_data_got<size, big_endian>::add_local_plt(
Sized_relobj_file<size, big_endian>* object,
Relobj* object,
unsigned int symndx,
unsigned int got_type)
{
@@ -1562,10 +1529,10 @@ Output_data_got<size, big_endian>::add_local_plt(
template<int size, bool big_endian>
void
Output_data_got<size, big_endian>::add_local_with_rel(
Sized_relobj_file<size, big_endian>* object,
Relobj* object,
unsigned int symndx,
unsigned int got_type,
Rel_dyn* rel_dyn,
Output_data_reloc_generic* rel_dyn,
unsigned int r_type)
{
if (object->local_has_got_offset(symndx, got_type))
@@ -1573,24 +1540,7 @@ Output_data_got<size, big_endian>::add_local_with_rel(
unsigned int got_offset = this->add_got_entry(Got_entry());
object->set_local_got_offset(symndx, got_type, got_offset);
rel_dyn->add_local(object, symndx, r_type, this, got_offset);
}
template<int size, bool big_endian>
void
Output_data_got<size, big_endian>::add_local_with_rela(
Sized_relobj_file<size, big_endian>* object,
unsigned int symndx,
unsigned int got_type,
Rela_dyn* rela_dyn,
unsigned int r_type)
{
if (object->local_has_got_offset(symndx, got_type))
return;
unsigned int got_offset = this->add_got_entry(Got_entry());
object->set_local_got_offset(symndx, got_type, got_offset);
rela_dyn->add_local(object, symndx, r_type, this, got_offset, 0);
rel_dyn->add_local_generic(object, symndx, r_type, this, got_offset, 0);
}
// Add a pair of entries for a local symbol to the GOT, and add
@@ -1599,11 +1549,11 @@ Output_data_got<size, big_endian>::add_local_with_rela(
template<int size, bool big_endian>
void
Output_data_got<size, big_endian>::add_local_pair_with_rel(
Sized_relobj_file<size, big_endian>* object,
Relobj* object,
unsigned int symndx,
unsigned int shndx,
unsigned int got_type,
Rel_dyn* rel_dyn,
Output_data_reloc_generic* rel_dyn,
unsigned int r_type_1,
unsigned int r_type_2)
{
@@ -1615,35 +1565,11 @@ Output_data_got<size, big_endian>::add_local_pair_with_rel(
Got_entry(object, symndx, false));
object->set_local_got_offset(symndx, got_type, got_offset);
Output_section* os = object->output_section(shndx);
rel_dyn->add_output_section(os, r_type_1, this, got_offset);
rel_dyn->add_output_section_generic(os, r_type_1, this, got_offset, 0);
if (r_type_2 != 0)
rel_dyn->add_output_section(os, r_type_2, this, got_offset + size / 8);
}
template<int size, bool big_endian>
void
Output_data_got<size, big_endian>::add_local_pair_with_rela(
Sized_relobj_file<size, big_endian>* object,
unsigned int symndx,
unsigned int shndx,
unsigned int got_type,
Rela_dyn* rela_dyn,
unsigned int r_type_1,
unsigned int r_type_2)
{
if (object->local_has_got_offset(symndx, got_type))
return;
unsigned int got_offset =
this->add_got_entry_pair(Got_entry(),
Got_entry(object, symndx, false));
object->set_local_got_offset(symndx, got_type, got_offset);
Output_section* os = object->output_section(shndx);
rela_dyn->add_output_section(os, r_type_1, this, got_offset, 0);
if (r_type_2 != 0)
rela_dyn->add_output_section(os, r_type_2, this, got_offset + size / 8, 0);
rel_dyn->add_output_section_generic(os, r_type_2, this,
got_offset + size / 8, 0);
}
// Reserve a slot in the GOT for a local symbol or the second slot of a pair.
@@ -1652,7 +1578,7 @@ template<int size, bool big_endian>
void
Output_data_got<size, big_endian>::reserve_local(
unsigned int i,
Sized_relobj<size, big_endian>* object,
Relobj* object,
unsigned int sym_index,
unsigned int got_type)
{