|
From: openocd-gerrit <ope...@us...> - 2026-10-11 10:05:54
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 751e5af67bf487c0f45ed2f5b53043dacfe72404 (commit)
from f4a4ac23d64ff055baa0754a1d54b2b3a0a1a930 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 751e5af67bf487c0f45ed2f5b53043dacfe72404
Author: Kulyatskaya Alexandra <a.k...@sy...>
Date: Mon Nov 17 15:55:17 2025 +0300
target: prevent image load to overwrite a breakpoint
Call function 'is_breakpoint_in_range()' in handler_load_image_command and
handle_fast_load_command for detecting breakpoint memory overwriting.
Change-Id: I8fb6c9811dc7322d78ec9cbba0e4641d619b7e03
Signed-off-by: Kulyatskaya Alexandra <a.k...@sy...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9240
Reviewed-by: Antonio Borneo <bor...@gm...>
Tested-by: jenkins
diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c
index 2c46cd3a6..eb165bdb1 100644
--- a/src/target/breakpoints.c
+++ b/src/target/breakpoints.c
@@ -37,6 +37,23 @@ static const char * const watchpoint_rw_strings[] = {
/* monotonic counter/id-number for breakpoints and watch points */
static int bpwp_unique_id;
+COMMAND_HELPER(detect_breakpoints_in_section, struct target *target,
+ struct imagesection section)
+{
+ target_addr_t start = section.base_address;
+ uint32_t length = section.size;
+ bool found_breakpoint = false;
+
+ for (struct breakpoint *bp = target->breakpoints; bp; bp = bp->next)
+ if (is_memory_regions_overlap(start, length, bp->address, bp->length)) {
+ found_breakpoint = true;
+ command_print(cmd, "conflicting breakpoint at address: "
+ TARGET_ADDR_FMT, bp->address);
+ }
+
+ return found_breakpoint ? ERROR_FAIL : ERROR_OK;
+}
+
static int breakpoint_add_internal(struct target *target,
target_addr_t address,
unsigned int length,
diff --git a/src/target/breakpoints.h b/src/target/breakpoints.h
index 4f156cb16..3246b8a5c 100644
--- a/src/target/breakpoints.h
+++ b/src/target/breakpoints.h
@@ -11,6 +11,8 @@
#include <stdint.h>
#include "helper/types.h"
+#include "helper/command.h"
+#include "image.h"
struct target;
@@ -68,6 +70,9 @@ static inline void breakpoint_hw_set(struct breakpoint *breakpoint, unsigned int
breakpoint->number = hw_number;
}
+COMMAND_HELPER(detect_breakpoints_in_section, struct target *target,
+ struct imagesection section);
+
int watchpoint_add(struct target *target,
target_addr_t address, unsigned int length,
enum watchpoint_rw rw, uint64_t value, uint64_t mask);
diff --git a/src/target/target.c b/src/target/target.c
index 57470e7df..b1e28f008 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -3658,6 +3658,10 @@ COMMAND_HANDLER(handle_load_image_command)
image_size = 0x0;
retval = ERROR_OK;
for (unsigned int i = 0; i < image.num_sections; i++) {
+ retval = CALL_COMMAND_HANDLER(detect_breakpoints_in_section, target, image.sections[i]);
+ if (retval != ERROR_OK)
+ return retval;
+
buffer = malloc(image.sections[i].size);
if (!buffer) {
command_print(CMD,
@@ -6369,8 +6373,19 @@ COMMAND_HANDLER(handle_fast_load_command)
int64_t ms = timeval_ms();
int size = 0;
int retval = ERROR_OK;
+
+ struct target *target = get_current_target(CMD_CTX);
+ for (i = 0; i < fastload_num; i++) {
+ struct imagesection section = {
+ .base_address = fastload[i].address,
+ .size = fastload[i].length,
+ };
+ retval = CALL_COMMAND_HANDLER(detect_breakpoints_in_section, target, section);
+ if (retval != ERROR_OK)
+ return retval;
+ }
+
for (i = 0; i < fastload_num; i++) {
- struct target *target = get_current_target(CMD_CTX);
command_print(CMD, "Write to 0x%08x, length 0x%08x",
(unsigned int)(fastload[i].address),
(unsigned int)(fastload[i].length));
-----------------------------------------------------------------------
Summary of changes:
src/target/breakpoints.c | 17 +++++++++++++++++
src/target/breakpoints.h | 5 +++++
src/target/target.c | 17 ++++++++++++++++-
3 files changed, 38 insertions(+), 1 deletion(-)
hooks/post-receive
--
Main OpenOCD repository
|