]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ARM/FDPIC: Add support for GDB call command
authorChristophe Lyon <christophe.lyon@linaro.org>
Wed, 14 Apr 2021 14:22:34 +0000 (14:22 +0000)
committerChristophe Lyon <christophe.lyon@linaro.org>
Wed, 14 Apr 2021 14:22:34 +0000 (14:22 +0000)
2021-04-14  Mickael Guene  <mickael.guene@st.com>
Christophe Lyon  <christophe.lyon@st.com>

* gdb/arm-tdep.c (arm_push_dummy_call): Handle FDPIC case.
* gdb/arm-tdep.h (fdpic_find_global_pointer): Declare.
* gdb/solib-fdpic.c (fdpic_find_global_pointer): New.

gdb/arm-tdep.c
gdb/arm-tdep.h
gdb/solib-fdpic.c

index 4b2130a4ead8020bb6eb06ffff73ca269a5dee43..9e8b382f66d342821b81dc25928c48d65ec2daf2 100644 (file)
@@ -44,6 +44,7 @@
 #include "target-descriptions.h"
 #include "user-regs.h"
 #include "observer.h"
+#include "infcall.h"
 
 #include "arm-tdep.h"
 #include "gdb/sim-arm.h"
@@ -3749,6 +3750,14 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       si = pop_stack_item (si);
     }
 
+  if (gdbarch_tdep (gdbarch)->is_fdpic)
+  {
+    CORE_ADDR func_addr = find_function_addr (function, NULL);
+
+    regcache_cooked_write_unsigned (regcache, 9,
+                                   fdpic_find_global_pointer (func_addr));
+  }
+
   /* Finally, update teh SP register.  */
   regcache_cooked_write_unsigned (regcache, ARM_SP_REGNUM, sp);
 
index d32e6561eb84c623cc261850889cf95a4afb92ea..8be97652f151c0d042e29eb16f015310b95114d0 100644 (file)
@@ -359,5 +359,6 @@ extern struct target_desc *tdesc_arm_with_neon;
 /* FDPIC structure and api.  */
 extern struct target_so_ops fdpic_so_ops;
 extern CORE_ADDR fdpic_fetch_objfile_link_map (struct objfile *objfile);
+extern CORE_ADDR fdpic_find_global_pointer (CORE_ADDR addr);
 
 #endif /* arm-tdep.h */
index a0b7db94c73427aaf68e557aea79da9517d81ad3..497742d00e8f0c2fc5cd8b9c4cdecb9de0757367 100644 (file)
@@ -598,6 +598,36 @@ enable_break2 (void)
   return 0;
 }
 
+/* Exported functions.  */
+/* Find the global pointer for the given function address ADDR.  */
+CORE_ADDR
+fdpic_find_global_pointer (CORE_ADDR addr)
+{
+  struct so_list *so;
+
+  so = master_so_list ();
+  while (so)
+    {
+      int seg;
+      struct elf32_fdpic_loadmap *map;
+
+      map = so->lm_info->map;
+
+      for (seg = 0; seg < map->nsegs; seg++)
+       {
+         if (map->segs[seg].addr <= addr
+             && addr < map->segs[seg].addr + map->segs[seg].p_memsz)
+           return so->lm_info->got_value;
+       }
+
+      so = so->next;
+    }
+
+  /* Didn't find it in any of the shared objects.
+     So assume it's in the main executable.  */
+  return main_got ();
+}
+
 /* Shared object operations.  */
 static int
 fdpic_in_dynsym_resolve_code (CORE_ADDR pc)