gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gold / aarch64-reloc-property.cc
index beaed10f87278e73ccb8dc8bf18952caada981f0..5f5e695fbc227b0f3d47963f0f5fb648dcd57b0b 100644 (file)
@@ -1,6 +1,6 @@
 // aarch64-reloc-property.cc -- AArch64 relocation properties   -*- C++ -*-
 
-// Copyright (C) 2014 Free Software Foundation, Inc.
+// Copyright (C) 2014-2020 Free Software Foundation, Inc.
 // Written by Han Shen <shenhan@google.com> and Jing Yu <jingyu@google.com>.
 
 // This file is part of gold.
@@ -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,
@@ -130,9 +164,8 @@ AArch64_reloc_property_table::AArch64_reloc_property_table()
 std::string
 AArch64_reloc_property_table::reloc_name_in_error_message(unsigned int code)
 {
-  gold_assert(code < Property_table_size);
-
-  const AArch64_reloc_property* arp = this->table_[code];
+  int tidx = code_to_array_index(code);
+  const AArch64_reloc_property* arp = this->table_[tidx];
 
   if (arp == NULL)
     {
This page took 0.023452 seconds and 4 git commands to generate.