This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] [AArch64] Use int64_t for address offset


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2ac09a5bbbff78d363ede2f038c31a9b1cb0887b

commit 2ac09a5bbbff78d363ede2f038c31a9b1cb0887b
Author: Yao Qi <yao.qi@linaro.org>
Date:   Tue Jun 28 17:24:25 2016 +0100

    [AArch64] Use int64_t for address offset
    
    In AArch64 displaced stepping and fast tracepoint, GDB/GDBserver needs
    to check whether the offset can fit in the range.  We are using int32_t
    for offset, it is sufficient to get an offset from an instruction, but
    it is not enough to get an offset from two addresses.  For example,
    we have a BL in shared lib which is at 0x0000002000040774, and the
    scratch pad for displaced stepping is at 0x400698.  The offset can't
    fit in 28 bit imm.  However, since we are using int32_t for offset, GDB
    thinks the offset can fit it, and generate the B instruction with wrong
    offset.
    
    It fixes the following fail,
    
    -FAIL: gdb.base/dso2dso.exp: next over call to sub2
    
    gdb:
    
    2016-06-28  Yao Qi  <yao.qi@linaro.org>
    
    	* aarch64-tdep.c (aarch64_displaced_step_b): Use int64_t for
    	variable new_offset.
    
    gdb/gdbserver:
    
    2016-06-28  Yao Qi  <yao.qi@linaro.org>
    
    	* linux-aarch64-low.c (aarch64_ftrace_insn_reloc_b): Use int64_t
    	for variable new_offset.
    	(aarch64_ftrace_insn_reloc_b_cond): Likewise.
    	(aarch64_ftrace_insn_reloc_cb): Likewise.
    	(aarch64_ftrace_insn_reloc_tb): Likewise.
    	(aarch64_install_fast_tracepoint_jump_pad): Likewise.  Use
    	PRIx64 instead of PRIx32.

Diff:
---
 gdb/ChangeLog                     |  5 +++++
 gdb/aarch64-tdep.c                |  2 +-
 gdb/gdbserver/ChangeLog           | 10 ++++++++++
 gdb/gdbserver/linux-aarch64-low.c | 14 +++++++-------
 4 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2fbbc6c..c99ed23 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-28  Yao Qi  <yao.qi@linaro.org>
+
+	* aarch64-tdep.c (aarch64_displaced_step_b): Use int64_t for
+	variable new_offset.
+
 2016-06-27  Manish Goregaokar  <manish@mozilla.com>
 
 	* rust-lang.c (rust_print_type, rust_decorations): Print unit
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 88fcf4b..e5ce13e 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -2322,7 +2322,7 @@ aarch64_displaced_step_b (const int is_bl, const int32_t offset,
 {
   struct aarch64_displaced_step_data *dsd
     = (struct aarch64_displaced_step_data *) data;
-  int32_t new_offset = data->insn_addr - dsd->new_addr + offset;
+  int64_t new_offset = data->insn_addr - dsd->new_addr + offset;
 
   if (can_encode_int32 (new_offset, 28))
     {
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index f6f0ad9..30d0498 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,15 @@
 2016-06-28  Yao Qi  <yao.qi@linaro.org>
 
+	* linux-aarch64-low.c (aarch64_ftrace_insn_reloc_b): Use int64_t
+	for variable new_offset.
+	(aarch64_ftrace_insn_reloc_b_cond): Likewise.
+	(aarch64_ftrace_insn_reloc_cb): Likewise.
+	(aarch64_ftrace_insn_reloc_tb): Likewise.
+	(aarch64_install_fast_tracepoint_jump_pad): Likewise.  Use
+	PRIx64 instead of PRIx32.
+
+2016-06-28  Yao Qi  <yao.qi@linaro.org>
+
 	* linux-arm-low.c (arm_get_syscall_trapinfo): New function.
 	(the_low_target): Install arm_get_syscall_trapinfo.
 
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 7ac68dd..6efa035 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -1575,7 +1575,7 @@ aarch64_ftrace_insn_reloc_b (const int is_bl, const int32_t offset,
 {
   struct aarch64_insn_relocation_data *insn_reloc
     = (struct aarch64_insn_relocation_data *) data;
-  int32_t new_offset
+  int64_t new_offset
     = insn_reloc->base.insn_addr - insn_reloc->new_addr + offset;
 
   if (can_encode_int32 (new_offset, 28))
@@ -1590,7 +1590,7 @@ aarch64_ftrace_insn_reloc_b_cond (const unsigned cond, const int32_t offset,
 {
   struct aarch64_insn_relocation_data *insn_reloc
     = (struct aarch64_insn_relocation_data *) data;
-  int32_t new_offset
+  int64_t new_offset
     = insn_reloc->base.insn_addr - insn_reloc->new_addr + offset;
 
   if (can_encode_int32 (new_offset, 21))
@@ -1627,7 +1627,7 @@ aarch64_ftrace_insn_reloc_cb (const int32_t offset, const int is_cbnz,
 {
   struct aarch64_insn_relocation_data *insn_reloc
     = (struct aarch64_insn_relocation_data *) data;
-  int32_t new_offset
+  int64_t new_offset
     = insn_reloc->base.insn_addr - insn_reloc->new_addr + offset;
 
   if (can_encode_int32 (new_offset, 21))
@@ -1664,7 +1664,7 @@ aarch64_ftrace_insn_reloc_tb (const int32_t offset, int is_tbnz,
 {
   struct aarch64_insn_relocation_data *insn_reloc
     = (struct aarch64_insn_relocation_data *) data;
-  int32_t new_offset
+  int64_t new_offset
     = insn_reloc->base.insn_addr - insn_reloc->new_addr + offset;
 
   if (can_encode_int32 (new_offset, 16))
@@ -1800,7 +1800,7 @@ aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
 {
   uint32_t buf[256];
   uint32_t *p = buf;
-  int32_t offset;
+  int64_t offset;
   int i;
   uint32_t insn;
   CORE_ADDR buildaddr = *jump_entry;
@@ -2137,7 +2137,7 @@ aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
     {
       sprintf (err,
 	       "E.Jump back from jump pad too far from tracepoint "
-	       "(offset 0x%" PRIx32 " cannot be encoded in 28 bits).",
+	       "(offset 0x%" PRIx64 " cannot be encoded in 28 bits).",
 	       offset);
       return 1;
     }
@@ -2151,7 +2151,7 @@ aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
     {
       sprintf (err,
 	       "E.Jump pad too far from tracepoint "
-	       "(offset 0x%" PRIx32 " cannot be encoded in 28 bits).",
+	       "(offset 0x%" PRIx64 " cannot be encoded in 28 bits).",
 	       offset);
       return 1;
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]