aboutsummaryrefslogtreecommitdiff
path: root/gold/reloc.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-05-16 17:42:48 +0000
committerIan Lance Taylor <iant@google.com>2007-05-16 17:42:48 +0000
commitb8e6aad9606384125f588d531c567f49bad346e2 (patch)
treee1172d50384713b91c329cc88cabcd2728f929a9 /gold/reloc.h
parent60dfee729999b913a247956c4816e758afb86a4b (diff)
downloadgdb-b8e6aad9606384125f588d531c567f49bad346e2.zip
gdb-b8e6aad9606384125f588d531c567f49bad346e2.tar.gz
gdb-b8e6aad9606384125f588d531c567f49bad346e2.tar.bz2
Add support for SHF_MERGE sections.
Diffstat (limited to 'gold/reloc.h')
-rw-r--r--gold/reloc.h136
1 files changed, 105 insertions, 31 deletions
diff --git a/gold/reloc.h b/gold/reloc.h
index 1edaa57..1aa0d89 100644
--- a/gold/reloc.h
+++ b/gold/reloc.h
@@ -13,13 +13,18 @@ namespace gold
class General_options;
class Relobj;
class Read_relocs_data;
-class Stringpool;
class Symbol;
class Layout;
template<int size>
class Sized_symbol;
+template<int size, bool big_endian>
+class Sized_relobj;
+
+template<int size>
+class Symbol_value;
+
template<int sh_type, bool dynamic, int size, bool big_endian>
class Output_data_reloc;
@@ -151,6 +156,22 @@ private:
elfcpp::Swap<valsize, big_endian>::writeval(wv, x + value);
}
+ // Do a simple relocation using a Symbol_value with the addend in
+ // the section contents. VALSIZE is the size of the value to
+ // relocate.
+ template<int valsize>
+ static inline void
+ rel(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval)
+ {
+ typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
+ Valtype* wv = reinterpret_cast<Valtype*>(view);
+ Valtype x = elfcpp::Swap<valsize, big_endian>::readval(wv);
+ x = psymval->value(object, x);
+ elfcpp::Swap<valsize, big_endian>::writeval(wv, x);
+ }
+
// Do a simple PC relative relocation with the addend in the section
// contents. VALSIZE is the size of the value.
template<int valsize>
@@ -165,76 +186,129 @@ private:
elfcpp::Swap<valsize, big_endian>::writeval(wv, x + value - address);
}
+ // Do a simple PC relative relocation with a Symbol_value with the
+ // addend in the section contents. VALSIZE is the size of the
+ // value.
+ template<int valsize>
+ static inline void
+ pcrel(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval,
+ typename elfcpp::Elf_types<size>::Elf_Addr address)
+ {
+ typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
+ Valtype* wv = reinterpret_cast<Valtype*>(view);
+ Valtype x = elfcpp::Swap<valsize, big_endian>::readval(wv);
+ x = psymval->value(object, x);
+ elfcpp::Swap<valsize, big_endian>::writeval(wv, x - address);
+ }
+
typedef Relocate_functions<size, big_endian> This;
public:
- // Do a simple 8-bit REL relocation with the addend in the object
- // file data.
+ // Do a simple 8-bit REL relocation with the addend in the section
+ // contents.
static inline void
rel8(unsigned char* view, unsigned char value)
- {
- This::template rel<8>(view, value);
- }
+ { This::template rel<8>(view, value); }
+
+ static inline void
+ rel8(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval)
+ { This::template rel<8>(view, object, psymval); }
// Do a simple 8-bit PC relative relocation with the addend in the
- // object file data.
+ // section contents.
static inline void
pcrel8(unsigned char* view, unsigned char value,
typename elfcpp::Elf_types<size>::Elf_Addr address)
- {
- This::template pcrel<8>(view, value, address);
- }
+ { This::template pcrel<8>(view, value, address); }
+
+ static inline void
+ pcrel8(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval,
+ typename elfcpp::Elf_types<size>::Elf_Addr address)
+ { This::template pcrel<8>(view, object, psymval, address); }
- // Do a simple 16-bit REL relocation with the addend in the object
- // file data.
+ // Do a simple 16-bit REL relocation with the addend in the section
+ // contents.
static inline void
rel16(unsigned char* view, elfcpp::Elf_Half value)
- {
- This::template rel<16>(view, value);
- }
+ { This::template rel<16>(view, value); }
+
+ static inline void
+ rel16(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval)
+ { This::template rel<16>(view, object, psymval); }
// Do a simple 32-bit PC relative REL relocation with the addend in
- // the object file data.
+ // the section contents.
static inline void
pcrel16(unsigned char* view, elfcpp::Elf_Word value,
typename elfcpp::Elf_types<size>::Elf_Addr address)
- {
- This::template pcrel<16>(view, value, address);
- }
+ { This::template pcrel<16>(view, value, address); }
+
+ static inline void
+ pcrel16(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval,
+ typename elfcpp::Elf_types<size>::Elf_Addr address)
+ { This::template pcrel<16>(view, object, psymval, address); }
// Do a simple 32-bit REL relocation with the addend in the section
// contents.
static inline void
rel32(unsigned char* view, elfcpp::Elf_Word value)
- {
- This::template rel<32>(view, value);
- }
+ { This::template rel<32>(view, value); }
+
+ static inline void
+ rel32(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval)
+ { This::template rel<32>(view, object, psymval); }
// Do a simple 32-bit PC relative REL relocation with the addend in
// the section contents.
static inline void
pcrel32(unsigned char* view, elfcpp::Elf_Word value,
typename elfcpp::Elf_types<size>::Elf_Addr address)
- {
- This::template pcrel<32>(view, value, address);
- }
+ { This::template pcrel<32>(view, value, address); }
+
+ static inline void
+ pcrel32(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval,
+ typename elfcpp::Elf_types<size>::Elf_Addr address)
+ { This::template pcrel<32>(view, object, psymval, address); }
// Do a simple 64-bit REL relocation with the addend in the section
// contents.
static inline void
rel64(unsigned char* view, elfcpp::Elf_Xword value)
- {
- This::template rel<64>(view, value);
- }
+ { This::template rel<64>(view, value); }
+
+ static inline void
+ rel64(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval)
+ { This::template rel<64>(view, object, psymval); }
// Do a simple 64-bit PC relative REL relocation with the addend in
// the section contents.
static inline void
pcrel64(unsigned char* view, elfcpp::Elf_Xword value,
typename elfcpp::Elf_types<size>::Elf_Addr address)
- {
- This::template pcrel<64>(view, value, address);
- }
+ { This::template pcrel<64>(view, value, address); }
+
+ static inline void
+ pcrel64(unsigned char* view,
+ const Sized_relobj<size, big_endian>* object,
+ const Symbol_value<size>* psymval,
+ typename elfcpp::Elf_types<size>::Elf_Addr address)
+ { This::template pcrel<64>(view, object, psymval, address); }
};
// We try to avoid COPY relocations when possible. A COPY relocation