diff options
author | Ian Lance Taylor <iant@google.com> | 2007-10-01 21:25:23 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-10-01 21:25:23 +0000 |
commit | 5b3463d9ee95e3b9631851ef51dd37377949b06d (patch) | |
tree | a97823681001d33a2eb5b078babde3f1f7812ad9 /gold/reloc.h | |
parent | 3a9eaa7da6fb02fcd137b2b7a4f99c6eb0221abd (diff) | |
download | gdb-5b3463d9ee95e3b9631851ef51dd37377949b06d.zip gdb-5b3463d9ee95e3b9631851ef51dd37377949b06d.tar.gz gdb-5b3463d9ee95e3b9631851ef51dd37377949b06d.tar.bz2 |
Add Signed_valtype and use it for sign extension. Fix names of rela8.
Diffstat (limited to 'gold/reloc.h')
-rw-r--r-- | gold/reloc.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/gold/reloc.h b/gold/reloc.h index 1ad8f25..bc538c5 100644 --- a/gold/reloc.h +++ b/gold/reloc.h @@ -228,14 +228,20 @@ private: const Symbol_value<size>* psymval) { typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype; + typedef typename elfcpp::Swap<valsize, big_endian>::Signed_valtype + Signed_valtype; typedef typename elfcpp::Swap<size, big_endian>::Valtype Sizetype; + typedef typename elfcpp::Swap<size, big_endian>::Signed_valtype + Signed_sizetype; Valtype* wv = reinterpret_cast<Valtype*>(view); Valtype x = elfcpp::Swap<valsize, big_endian>::readval(wv); - // Fancy formula to sign-extend x to size. - const Sizetype mask = 1U << (sizeof(valsize) * 8 - 1); - Sizetype sign_extended_x = x; - sign_extended_x = (sign_extended_x ^ mask) - mask; - x = psymval->value(object, sign_extended_x); + + // Sign extend the value. + Signed_valtype signed_x = static_cast<Signed_valtype>(x); + Signed_sizetype signed_extended_x = static_cast<Signed_sizetype>(signed_x); + Sizetype unsigned_extended_x = static_cast<Sizetype>(signed_extended_x); + + x = psymval->value(object, unsigned_extended_x); elfcpp::Swap<valsize, big_endian>::writeval(wv, x); } @@ -317,11 +323,11 @@ public: // Do an 8-bit RELA relocation with the addend in the relocation. static inline void - rel8a(unsigned char* view, unsigned char value, unsigned char addend) + rela8(unsigned char* view, unsigned char value, unsigned char addend) { This::template rela<8>(view, value, addend); } static inline void - rel8a(unsigned char* view, + rela8(unsigned char* view, const Sized_relobj<size, big_endian>* object, const Symbol_value<size>* psymval, unsigned char addend) |