aboutsummaryrefslogtreecommitdiff
path: root/gdb/aarch64-tdep.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-10-04 20:47:06 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-10-25 14:51:44 -0400
commit50888e42dcd32b30e1144c0aa6d1c1490da45cd9 (patch)
tree72fad89d67057ecb53f26bac0464542829053e3e /gdb/aarch64-tdep.c
parentd9f82e931394efed68858eb7c7bb5832ad888482 (diff)
downloadbinutils-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.zip
binutils-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.tar.gz
binutils-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.tar.bz2
gdb: change functions returning value contents to use gdb::array_view
The bug fixed by this [1] patch was caused by an out-of-bounds access to a value's content. The code gets the value's content (just a pointer) and then indexes it with a non-sensical index. This made me think of changing functions that return value contents to return array_views instead of a plain pointer. This has the advantage that when GDB is built with _GLIBCXX_DEBUG, accesses to the array_view are checked, making bugs more apparent / easier to find. This patch changes the return types of these functions, and updates callers to call .data() on the result, meaning it's not changing anything in practice. Additional work will be needed (which can be done little by little) to make callers propagate the use of array_view and reap the benefits. [1] https://sourceware.org/pipermail/gdb-patches/2021-September/182306.html Change-Id: I5151f888f169e1c36abe2cbc57620110673816f3
Diffstat (limited to 'gdb/aarch64-tdep.c')
-rw-r--r--gdb/aarch64-tdep.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 4b5af46..42b8494 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1593,7 +1593,7 @@ pass_in_x (struct gdbarch *gdbarch, struct regcache *regcache,
int len = TYPE_LENGTH (type);
enum type_code typecode = type->code ();
int regnum = AARCH64_X0_REGNUM + info->ngrn;
- const bfd_byte *buf = value_contents (arg);
+ const bfd_byte *buf = value_contents (arg).data ();
info->argnum++;
@@ -1663,7 +1663,7 @@ static void
pass_on_stack (struct aarch64_call_info *info, struct type *type,
struct value *arg)
{
- const bfd_byte *buf = value_contents (arg);
+ const bfd_byte *buf = value_contents (arg).data ();
int len = TYPE_LENGTH (type);
int align;
stack_item_t item;
@@ -1739,12 +1739,12 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache,
{
case TYPE_CODE_FLT:
return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (arg_type),
- value_contents (arg));
+ value_contents (arg).data ());
break;
case TYPE_CODE_COMPLEX:
{
- const bfd_byte *buf = value_contents (arg);
+ const bfd_byte *buf = value_contents (arg).data ();
struct type *target_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
if (!pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (target_type),
@@ -1758,7 +1758,7 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache,
case TYPE_CODE_ARRAY:
if (arg_type->is_vector ())
return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (arg_type),
- value_contents (arg));
+ value_contents (arg).data ());
/* fall through. */
case TYPE_CODE_STRUCT:
@@ -1900,7 +1900,7 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
sp = align_down (sp - len, 16);
/* Write the real data into the stack. */
- write_memory (sp, value_contents (arg), len);
+ write_memory (sp, value_contents (arg).data (), len);
/* Construct the indirection. */
arg_type = lookup_pointer_type (arg_type);
@@ -2682,7 +2682,7 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch,
mark_value_bytes_unavailable (result_value, 0,
TYPE_LENGTH (value_type (result_value)));
else
- memcpy (value_contents_raw (result_value), reg_buf, regsize);
+ memcpy (value_contents_raw (result_value).data (), reg_buf, regsize);
return result_value;
}