diff options
author | Han Shen <shenhan@google.com> | 2016-07-26 08:49:12 -0700 |
---|---|---|
committer | Han Shen <shenhan@google.com> | 2016-07-26 08:55:14 -0700 |
commit | 8769bc4bab847cefc2bb5682a0a0dad579528ac8 (patch) | |
tree | b93a01a9472bc7677a46cfb2156cfcb0f7e3c84d /gold/aarch64-reloc-property.cc | |
parent | e0461dbb653dbb3c46ea7a15054fd2c98f879f31 (diff) | |
download | gdb-8769bc4bab847cefc2bb5682a0a0dad579528ac8.zip gdb-8769bc4bab847cefc2bb5682a0a0dad579528ac8.tar.gz gdb-8769bc4bab847cefc2bb5682a0a0dad579528ac8.tar.bz2 |
[Gold, aarch64] Implement some AArch64 relocs.
This CL implemented the following relocs for AArch64 target.
- R_AARCH64_MOVW_UABS_G*
- R_AARCH64_MOVW_SABS_G* relocations
gold/ChangeLog
2016-07-26 Igor Kudrin <ikudrin@accesssoftek.com>
* aarch64-reloc-property.cc (Rvalue_bit_select_impl): New class.
(rvalue_bit_select): Use Rvalue_bit_select_impl.
* aarch64-reloc.def (MOVW_UABS_G0, MOVW_UABS_G0_NC,
MOVW_UABS_G1,
MOVW_UABS_G1_NC, MOVW_UABS_G2, MOVW_UABS_G2_NC, MOVW_UABS_G3,
MOVW_SABS_G0, MOVW_SABS_G1, MOVW_SABS_G2): New relocations.
* aarch64.cc (Target_aarch64::Scan::local): Add cases for new
MOVW_UABS_* and MOVW_SABS_* relocations.
(Target_aarch64::Scan::global): Likewise.
(Target_aarch64::Relocate::relocate): Add cases and handlings
for new MOVW_UABS_* and MOVW_SABS_* relocations.
* testsuite/Makefile.am (aarch64_relocs): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/aarch64_globals.s: New test source file.
* testsuite/aarch64_relocs.s: Likewise.
* testsuite/aarch64_relocs.sh: New test script.
Diffstat (limited to 'gold/aarch64-reloc-property.cc')
-rw-r--r-- | gold/aarch64-reloc-property.cc | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/gold/aarch64-reloc-property.cc b/gold/aarch64-reloc-property.cc index bf521d7..d0dee40 100644 --- a/gold/aarch64-reloc-property.cc +++ b/gold/aarch64-reloc-property.cc @@ -59,18 +59,52 @@ template<> bool rvalue_checkup<0, 0>(int64_t) { return true; } +namespace +{ + +template<int L, int U> +class Rvalue_bit_select_impl +{ +public: + static uint64_t + calc(uint64_t x) + { + return (x & ((1ULL << (U+1)) - 1)) >> L; + } +}; + +template<int L> +class Rvalue_bit_select_impl<L, 63> +{ +public: + static uint64_t + calc(uint64_t x) + { + return x >> L; + } +}; + +// By our convention, L=U=0 means that the whole value should be retrieved. +template<> +class Rvalue_bit_select_impl<0, 0> +{ +public: + static uint64_t + calc(uint64_t x) + { + return x; + } +}; + +} // End anonymous namespace. + template<int L, int U> uint64_t rvalue_bit_select(uint64_t x) { - if (U == 63) return x >> L; - return (x & (((uint64_t)1 << (U+1)) - 1)) >> L; + return Rvalue_bit_select_impl<L, U>::calc(x); } -template<> -uint64_t -rvalue_bit_select<0, 0>(uint64_t x) { return x; } - AArch64_reloc_property::AArch64_reloc_property( unsigned int code, const char* name, |