From 55de1de55d7e728770ea0aa885b4a5425b1d6167 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 15 Feb 2017 10:52:29 -0800 Subject: 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. --- gdb/solib-svr4.c | 2 +- gdb/solib.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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); -- cgit v1.2.1