]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ARM/FDPIC: Add gdbserver support
authorChristophe Lyon <christophe.lyon@linaro.org>
Wed, 14 Apr 2021 14:22:25 +0000 (14:22 +0000)
committerChristophe Lyon <christophe.lyon@linaro.org>
Wed, 14 Apr 2021 14:22:25 +0000 (14:22 +0000)
This patch extends the existing support for FDPIC on bfin/frv/sh to arm.
It is enabled when configuring with --host arm-none-uclinuxfdpiceabi,
using arm-none-uclinuxfdpiceabi-gcc.

We also change the way HAS_NOMMU is defined to make sure we use vfork
instead of fork (which is not available in the ARM FDPIC
configuration).

2021-04-14  Mickael Guene <mickael.guene@st.com>
Christophe Lyon <christophe.lyon@st.com>

* gdb/common/linux-ptrace.h: Define PTRACE for FDPIC for arm too.
* gdb/gdbserver/configure.srv: Accept arm*-*-uclinuxfdpiceabi
target.
* gdb/gdbserver/linux-low.c (elf32_fdpic_loadseg): New.
(elf32_fdpic_loadmap): New.
(HAS_NOMMU): Fix definition.
(linux_read_offsets): Add support for arm FDPIC.

gdb/common/linux-ptrace.h
gdb/gdbserver/configure.srv
gdb/gdbserver/linux-low.c

index 96ad33d630c647918a5bfdd5e9a6b2022efc3233..d56a1a578045534d42f66ab45ea366058b07bcb3 100644 (file)
@@ -53,7 +53,7 @@ struct buffer;
 
 #endif /* PTRACE_EVENT_FORK */
 
-#if (defined __bfin__ || defined __frv__ || defined __sh__) \
+#if (defined __bfin__ || defined __frv__ || defined __sh__ || defined __arm__) \
     && !defined PTRACE_GETFDPIC
 #define PTRACE_GETFDPIC                31
 #define PTRACE_GETFDPIC_EXEC   0
index d1e04a9685c4d8258bee20ec0dece26a6ecc1392..dfe5b014e1df9236b1b423be7a663a5fa49693b6 100644 (file)
@@ -42,7 +42,7 @@ srv_amd64_linux_xmlfiles="i386/amd64-linux.xml i386/amd64-avx-linux.xml i386/64b
 # Input is taken from the "${target}" variable.
 
 case "${target}" in
-  arm*-*-linux*)       srv_regobj="reg-arm.o arm-with-iwmmxt.o"
+  arm*-*-linux*|arm*-*-uclinuxfdpiceabi)       srv_regobj="reg-arm.o arm-with-iwmmxt.o"
                        srv_regobj="${srv_regobj} arm-with-vfpv2.o"
                        srv_regobj="${srv_regobj} arm-with-vfpv3.o"
                        srv_regobj="${srv_regobj} arm-with-neon.o"
index a476031faf48be31b9dc5911771caf525d23cbbc..e4e7bb686b36b98018ad548872c8860e90ce425f 100644 (file)
 #endif
 
 #ifdef __UCLIBC__
-#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
+#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_USE_MMU__))
 /* PTRACE_TEXT_ADDR and friends.  */
 #include <asm/ptrace.h>
 #define HAS_NOMMU
 #endif
 #endif
 
+/* ARM FDPIC support.  */
+#if defined(__FDPIC__)
+/* This data structure represents a PT_LOAD segment.  */
+struct elf32_fdpic_loadseg
+{
+  /* Core address at which the segment is mapped.  */
+  Elf32_Addr addr;
+  /* VMA recorded in the program header.  */
+  Elf32_Addr p_vaddr;
+  /* Size of this segment in memory.  */
+  Elf32_Word p_memsz;
+};
+
+struct elf32_fdpic_loadmap
+{
+  /* Protocol version number, must be zero.  */
+  Elf32_Half version;
+  /* Number of segments in this map.  */
+  Elf32_Half nsegs;
+  /* The actual memory map.  */
+  struct elf32_fdpic_loadseg segs[/*nsegs*/];
+};
+#endif
+
 #ifndef HAVE_ELF32_AUXV_T
 /* Copied from glibc's elf.h.  */
 typedef struct
@@ -4855,6 +4879,19 @@ linux_read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
       *text_p = text;
       *data_p = data - (text_end - text);
 
+      return 1;
+    }
+#elif defined(__FDPIC__)
+  long ret;
+  struct elf32_fdpic_loadmap *loadmap;
+  int pid = lwpid_of (get_thread_lwp (current_inferior));
+
+  ret = ptrace (PTRACE_GETFDPIC, pid, PTRACE_GETFDPIC_EXEC, &loadmap);
+  if (ret == 0)
+    {
+      *text_p = (CORE_ADDR) (loadmap->segs[0].addr - loadmap->segs[0].p_vaddr);
+      *data_p = (CORE_ADDR) (loadmap->segs[1].addr - loadmap->segs[1].p_vaddr);
+
       return 1;
     }
 #endif