OSDN Git Service

octets vs bytes changes for binutils
authorTimothy Wall <twall@alum.mit.edu>
Thu, 3 Feb 2000 18:12:54 +0000 (18:12 +0000)
committerTimothy Wall <twall@alum.mit.edu>
Thu, 3 Feb 2000 18:12:54 +0000 (18:12 +0000)
include/ChangeLog
include/dis-asm.h
opcodes/ChangeLog
opcodes/dis-buf.c

index c526639..062d732 100644 (file)
@@ -1,3 +1,8 @@
+2000-02-03  Timothy Wall <twall@redhat.com>
+
+       * dis-asm.h (struct disassemble_info): Added octets_per_byte
+       field and initialize it to one (1).
+       
 2000-01-27  Nick Clifton  <nickc@redhat.com>
 
        * dis-asm.h: Add prototype for disassembler_usage().
index 98a7d17..8dc9b71 100644 (file)
@@ -121,6 +121,11 @@ typedef struct disassemble_info {
   int bytes_per_chunk;
   enum bfd_endian display_endian;
 
+  /* Number of octets per incremented target address 
+     Normally one, but some DSPs have byte sizes of 16 or 32 bits
+   */
+  int octets_per_byte;
+
   /* Results from instruction decoders.  Not all decoders yet support
      this information.  This info is set each time an instruction is
      decoded, and is only valid for the last such instruction.
@@ -229,6 +234,7 @@ extern int generic_symbol_at_address
   (INFO).arch = bfd_arch_unknown, \
   (INFO).mach = 0, \
   (INFO).endian = BFD_ENDIAN_UNKNOWN, \
+  (INFO).octets_per_byte = 1, \
   INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC)
 
 /* Call this macro to initialize only the internal variables for the
index cda0156..2b72067 100644 (file)
@@ -1,3 +1,9 @@
+2000-02-03  Timothy Wall  <twall@redhat.com>   
+       
+       * dis-buf.c (buffer_read_memory):  Use octets_per_byte field
+       to adjust target address bounds checking and calculate the
+       appropriate octet offset into data.
+       
 2000-01-27  Nick Clifton  <nickc@redhat.com>
 
        * arm-dis.c: (parse_disassembler_option): Rename to
index 523fe72..65b1edb 100644 (file)
@@ -29,11 +29,17 @@ buffer_read_memory (memaddr, myaddr, length, info)
      int length;
      struct disassemble_info *info;
 {
+  int opb = info->octets_per_byte;
+  int end_addr_offset = length / opb;
+  int max_addr_offset = info->buffer_length / opb; 
+  int octets = (memaddr - info->buffer_vma) * opb;
+
   if (memaddr < info->buffer_vma
-      || memaddr - info->buffer_vma + length > info->buffer_length)
+      || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset)
     /* Out of bounds.  Use EIO because GDB uses it.  */
     return EIO;
-  memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
+  memcpy (myaddr, info->buffer + octets, length);
+
   return 0;
 }