aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Machado <luis.machado@linaro.org>2021-04-29 15:10:06 -0300
committerLuis Machado <luis.machado@linaro.org>2021-05-13 10:15:26 -0300
commit0746f49b1dd44ce17b21468b9f8d9715e116a991 (patch)
tree0ff507addfcc548e2ad244b712f2ed621efa1797
parent7671eff8f08de314d8c9837225eba95ed5ea053b (diff)
downloadbinutils-0746f49b1dd44ce17b21468b9f8d9715e116a991.zip
binutils-0746f49b1dd44ce17b21468b9f8d9715e116a991.tar.gz
binutils-0746f49b1dd44ce17b21468b9f8d9715e116a991.tar.bz2
[AArch64] Fix off-by-one when calculating tag granules.
When we want to fetch tags from a memory range, the last address in that range is not included. There is a off-by-one error in aarch64_mte_get_tag_granules, which this patch fixes. gdb/ChangeLog: 2021-05-13 Luis Machado <luis.machado@linaro.org> * arch/aarch64-mte-linux.c (aarch64_mte_get_tag_granules): Don't include the last address in the range.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/arch/aarch64-mte-linux.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fe75cee..d411836 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-13 Luis Machado <luis.machado@linaro.org>
+
+ * arch/aarch64-mte-linux.c (aarch64_mte_get_tag_granules): Don't
+ include the last address in the range.
+
2021-05-12 Simon Marchi <simon.marchi@polymtl.ca>
* python/python-internal.h (gdbpy_parse_command_name): Return
diff --git a/gdb/arch/aarch64-mte-linux.c b/gdb/arch/aarch64-mte-linux.c
index 959c024..7c2ae9a 100644
--- a/gdb/arch/aarch64-mte-linux.c
+++ b/gdb/arch/aarch64-mte-linux.c
@@ -31,9 +31,10 @@ aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len, size_t granule_size)
/* Start address */
CORE_ADDR s_addr = align_down (addr, granule_size);
/* End address */
- CORE_ADDR e_addr = align_down (addr + len, granule_size);
+ CORE_ADDR e_addr = align_down (addr + len - 1, granule_size);
- /* We always have at least 1 granule. */
+ /* We always have at least 1 granule because len is non-zero at this
+ point. */
return 1 + (e_addr - s_addr) / granule_size;
}