summaryrefslogtreecommitdiff
path: root/gold/target-reloc.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2006-11-16 00:38:25 +0000
committerIan Lance Taylor <iant@google.com>2006-11-16 00:38:25 +0000
commit0468de001cf096f21419373d7577b58d9b5977e0 (patch)
tree2ef13984d4c121ba39f97cb72b79eb77e00a338a /gold/target-reloc.h
parent6580ee5353cd78f4b7e8bc7fe1c84fc3b622300e (diff)
downloadbinutils-redhat-0468de001cf096f21419373d7577b58d9b5977e0.tar.gz
Snapshot. Includes first cut at output relocation sections.
Diffstat (limited to 'gold/target-reloc.h')
-rw-r--r--gold/target-reloc.h34
1 files changed, 8 insertions, 26 deletions
diff --git a/gold/target-reloc.h b/gold/target-reloc.h
index 70692783e0..5b057ac0fb 100644
--- a/gold/target-reloc.h
+++ b/gold/target-reloc.h
@@ -6,30 +6,11 @@
#include "elfcpp.h"
#include "object.h"
#include "symtab.h"
+#include "reloc-types.h"
namespace gold
{
-// Pick the ELF relocation accessor class and the size based on
-// SH_TYPE, which is either SHT_REL or SHT_RELA.
-
-template<int sh_type, int size, bool big_endian>
-struct Reloc_types;
-
-template<int size, bool big_endian>
-struct Reloc_types<elfcpp::SHT_REL, size, big_endian>
-{
- typedef typename elfcpp::Rel<size, big_endian> Reloc;
- static const int reloc_size = elfcpp::Elf_sizes<size>::rel_size;
-};
-
-template<int size, bool big_endian>
-struct Reloc_types<elfcpp::SHT_RELA, size, big_endian>
-{
- typedef typename elfcpp::Rela<size, big_endian> Reloc;
- static const int reloc_size = elfcpp::Elf_sizes<size>::rela_size;
-};
-
// This function implements the generic part of reloc scanning. This
// is an inline function which takes a class whose operator()
// implements the machine specific part of scanning. We do it this
@@ -140,8 +121,9 @@ relocate_section(
Relocate relocate;
unsigned int local_count = relinfo->local_symbol_count;
- typename elfcpp::Elf_types<size>::Elf_Addr *local_values = relinfo->values;
- Symbol** global_syms = relinfo->symbols;
+ const typename Sized_relobj<size, big_endian>::Local_values* local_values =
+ relinfo->local_values;
+ const Symbol* const * global_syms = relinfo->symbols;
for (size_t i = 0; i < reloc_count; ++i, prelocs += reloc_size)
{
@@ -153,22 +135,22 @@ relocate_section(
unsigned int r_sym = elfcpp::elf_r_sym<size>(r_info);
unsigned int r_type = elfcpp::elf_r_type<size>(r_info);
- Sized_symbol<size>* sym;
+ const Sized_symbol<size>* sym;
typename elfcpp::Elf_types<size>::Elf_Addr value;
if (r_sym < local_count)
{
sym = NULL;
- value = local_values[r_sym];
+ value = (*local_values)[r_sym];
}
else
{
- Symbol* gsym = global_syms[r_sym - local_count];
+ const Symbol* gsym = global_syms[r_sym - local_count];
assert(gsym != NULL);
if (gsym->is_forwarder())
gsym = relinfo->symtab->resolve_forwards(gsym);
- sym = static_cast<Sized_symbol<size>*>(gsym);
+ sym = static_cast<const Sized_symbol<size>*>(gsym);
value = sym->value();
}