X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gold%2Faarch64-reloc-property.cc;h=02f45478fd361e4af6350410405d521fb31ca450;hb=c9dcc18f8ded97ed7cd1dd64da8c7b37b86f61bb;hp=16f844984e702a6bf9c5a611b11ac69ca8d939d6;hpb=8e33481e13facdf33c732e25d18b4b9772cc4e9c;p=binutils-gdb.git diff --git a/gold/aarch64-reloc-property.cc b/gold/aarch64-reloc-property.cc index 16f844984e7..02f45478fd3 100644 --- a/gold/aarch64-reloc-property.cc +++ b/gold/aarch64-reloc-property.cc @@ -1,6 +1,6 @@ // aarch64-reloc-property.cc -- AArch64 relocation properties -*- C++ -*- -// Copyright (C) 2014 Free Software Foundation, Inc. +// Copyright (C) 2014-2021 Free Software Foundation, Inc. // Written by Han Shen and Jing Yu . // This file is part of gold. @@ -59,18 +59,52 @@ template<> bool rvalue_checkup<0, 0>(int64_t) { return true; } +namespace +{ + +template +class Rvalue_bit_select_impl +{ +public: + static uint64_t + calc(uint64_t x) + { + return (x & ((1ULL << (U+1)) - 1)) >> L; + } +}; + +template +class Rvalue_bit_select_impl +{ +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 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::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,