[rtems commit] libdebugger/aarch64: Set .start section to RW

Chris Johns chrisj at rtems.org
Thu Aug 25 04:02:35 UTC 2022


Module:    rtems
Branch:    master
Commit:    a932829b01cb375ec9036da03bbe65e48ff82dd6
Changeset: http://git.rtems.org/rtems/commit/?id=a932829b01cb375ec9036da03bbe65e48ff82dd6

Author:    Chris Johns <chrisj at rtems.org>
Date:      Thu Aug 25 14:10:21 2022 +1000

libdebugger/aarch64: Set .start section to RW

- Stops the server crashing when setting breakpoints in .start

---

 cpukit/libdebugger/rtems-debugger-aarch64.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/cpukit/libdebugger/rtems-debugger-aarch64.c b/cpukit/libdebugger/rtems-debugger-aarch64.c
index 279c2d61ef..9a53da0de9 100644
--- a/cpukit/libdebugger/rtems-debugger-aarch64.c
+++ b/cpukit/libdebugger/rtems-debugger-aarch64.c
@@ -34,7 +34,9 @@
 #include <inttypes.h>
 #include <stdlib.h>
 
-/* Defined by linkcmds.base */
+/* Defined by linkcmds.base. This should be taken from <bsp/linker-symbols.h> */
+extern char bsp_section_start_begin[];
+extern char bsp_section_start_end[];
 extern char bsp_section_text_begin[];
 extern char bsp_section_text_end[];
 extern char bsp_section_fast_text_begin[];
@@ -1231,6 +1233,8 @@ static rtems_status_code rtems_debugger_target_set_text_writable(
   bool writable
 )
 {
+  uintptr_t         start_begin = (uintptr_t) bsp_section_start_begin;
+  uintptr_t         start_end = (uintptr_t) bsp_section_start_end;
   uintptr_t         text_begin = (uintptr_t) bsp_section_text_begin;
   uintptr_t         text_end = (uintptr_t) bsp_section_text_end;
   uintptr_t         fast_text_begin = (uintptr_t) bsp_section_fast_text_begin;
@@ -1242,6 +1246,23 @@ static rtems_status_code rtems_debugger_target_set_text_writable(
     mmu_flags = AARCH64_MMU_CODE_CACHED;
   }
 
+  target_printk(
+    "[} MMU edit: start_begin: 0x%016" PRIxPTR
+    " start_end: 0x%016" PRIxPTR "\n",
+    start_begin,
+    start_end
+  );
+  sc = aarch64_mmu_map(
+    start_begin,
+    start_end - start_begin,
+    mmu_flags
+  );
+
+  if ( sc != RTEMS_SUCCESSFUL ) {
+    target_printk( "[} MMU edit failed\n" );
+    return sc;
+  }
+
   target_printk(
     "[} MMU edit: text_begin: 0x%016" PRIxPTR
     " text_end: 0x%016" PRIxPTR "\n",



More information about the vc mailing list