]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/aarch64-linux-tdep.c
Support linkmap offsets for the AAPCS64-CAP ABI
[thirdparty/binutils-gdb.git] / gdb / aarch64-linux-tdep.c
index bada46f844245a2d8d4048ad3089a9c481b0773b..d04fe8961edb12cec7960078086e22cd0bd2b876 100644 (file)
@@ -54,6 +54,8 @@
 
 #include "elf/common.h"
 
+#include "gdbsupport/capability.h"
+
 /* Signal frame handling.
 
       +------------+  ^
@@ -1775,10 +1777,29 @@ maint_print_cap_from_addr_cmd (const char *args, int from_tty)
   CORE_ADDR addr = parse_and_eval_address (args);
   cap = target_read_capability (addr);
 
+  if (cap.empty ())
+    {
+      fprintf_unfiltered (gdb_stdlog,
+                         "Could not read capability from address %s.\n",
+                         phex_nz (addr, 8));
+      return;
+    }
+
   for (auto it : cap)
     fprintf_unfiltered (gdb_stdlog, "%02x ", it);
+  fputs_unfiltered ("\n", gdb_stdlog);
+
+  bool tag = (cap[0] == 1);
+  uint128_t cap_128bits;
+  memcpy (&cap_128bits, &cap[1], 16);
 
+  capability capability (cap_128bits, tag);
+
+  fprintf_unfiltered (gdb_stdlog, "verbose: %s\n",
+                     capability.to_str (false).c_str ());
   fputs_unfiltered ("\n", gdb_stdlog);
+  fprintf_unfiltered (gdb_stdlog, "compact: %s\n",
+                     capability.to_str (true).c_str ());
 }
 
 /* Implement the maintenance set capability in memory command.  */
@@ -2045,6 +2066,11 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   if (tdep->has_capability ())
     {
+      /* Register CHERI-specific linkmap offsets for the AAPCS64_CAP ABI.  */
+      if (tdep->abi == AARCH64_ABI_AAPCS64_CAP)
+       set_solib_svr4_fetch_link_map_offsets (gdbarch,
+                                       svr4_lp64_cheri_fetch_link_map_offsets);
+
       /* Initialize the register numbers for the core file register set.
         Please note the PCC/CSP position in GDB's target description is
         the inverse of the position in the Linux Kernel's user_morello_state