summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2017-02-15 10:52:29 -0800
committerJohn Baldwin <jhb@FreeBSD.org>2022-09-01 16:43:06 -0700
commit55de1de55d7e728770ea0aa885b4a5425b1d6167 (patch)
tree3a614672e9195a6ec8664cfe08dcf8d97f1bf14f
parent8f8b4d0ea5e26bb97a53dc2c496c639245d5a84c (diff)
downloadbinutils-gdb-55de1de55d7e728770ea0aa885b4a5425b1d6167.tar.gz
Update solib*.c to work with CHERI capabilities.
- Treat dyn_ptr members of .dynamic entries as addresses rather than pointers. - Don't truncate pointers in svr4_truncate_ptr() if the pointer size is larger than a CORE_ADDR as the truncation effectively sets them to zero in this case. This should perhaps be using gdbarch_integer_to_address() instead of it's own explicit truncation anyway.
-rw-r--r--gdb/solib-svr4.c2
-rw-r--r--gdb/solib.c11
2 files changed, 12 insertions, 1 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index a4fcb121486..98c8522ffd5 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -2973,7 +2973,7 @@ svr4_clear_solib (void)
static CORE_ADDR
svr4_truncate_ptr (CORE_ADDR addr)
{
- if (gdbarch_ptr_bit (target_gdbarch ()) == sizeof (CORE_ADDR) * 8)
+ if (gdbarch_ptr_bit (target_gdbarch ()) >= sizeof (CORE_ADDR) * 8)
/* We don't need to truncate anything, and the bit twiddling below
will fail due to overflow problems. */
return addr;
diff --git a/gdb/solib.c b/gdb/solib.c
index 8bcbfa22df1..adeb3a1a411 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1567,14 +1567,25 @@ gdb_bfd_scan_elf_dyntag (const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr,
entry. */
if (ptr)
{
+#if 0
struct type *ptr_type;
+#else
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+#endif
gdb_byte ptr_buf[8];
CORE_ADDR ptr_addr_1;
+#if 0
ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
+#endif
ptr_addr_1 = dyn_addr + (buf - bufstart) + arch_size / 8;
if (target_read_memory (ptr_addr_1, ptr_buf, arch_size / 8) == 0)
+#if 0
dyn_ptr = extract_typed_address (ptr_buf, ptr_type);
+#else
+ dyn_ptr = extract_unsigned_integer (ptr_buf, arch_size / 8,
+ byte_order);
+#endif
*ptr = dyn_ptr;
if (ptr_addr)
*ptr_addr = dyn_addr + (buf - bufstart);