]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Update solib*.c to work with CHERI capabilities.
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 15 Feb 2017 18:52:29 +0000 (10:52 -0800)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 23:43:06 +0000 (16:43 -0700)
- 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.

gdb/solib-svr4.c
gdb/solib.c

index a4fcb121486fb406ea1b1104099c46892ab2e6f5..98c8522ffd5bacc5ec6d450687b490150f4260cd 100644 (file)
@@ -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;
index 8bcbfa22df1a2813b75371ea5fa4b7601be3e29e..adeb3a1a411e4658e48d7be789b495b3c9a8ee44 100644 (file)
@@ -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);