This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


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

Re: PATCH octets vs bytes for objdump


So while algebraically they are equivalent, ISO C-ically they're not.  Good
point.

The condition should be:

    memaddr - info->buffer_vma + end_addr_offset > max_addr_offset

instead of:

    memaddr + end_addr_offset > info->buffer_vma + max_addr_offset


T.

Ian Lance Taylor wrote:

>    Date: Wed, 26 Jan 2000 07:28:57 -0500
>    From: Timothy Wall <twall@tiac.net>
>
>    *************** buffer_read_memory (memaddr, myaddr, len
>    *** 29,39 ****
>           int length;
>           struct disassemble_info *info;
>      {
>        if (memaddr < info->buffer_vma
>    !       || memaddr - info->buffer_vma + length > info->buffer_length)
>          /* Out of bounds.  Use EIO because GDB uses it.  */
>          return EIO;
>    !   memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
>        return 0;
>      }
>
>    --- 29,45 ----
>           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 + end_addr_offset > info->buffer_vma + max_addr_offset)
>          /* Out of bounds.  Use EIO because GDB uses it.  */
>          return EIO;
>    !   memcpy (myaddr, info->buffer + octets, length);
>    !
>        return 0;
>      }
>
> Note that the original version of the condition was careful to never
> form an address which extended past the end of the buffer.  The new
> condition does not preserve that property, because memaddr +
> end_addr_offset might be past the end of the buffer.  ISO C does not
> guarantee that you can form an address beyond the end of a buffer.  I
> admit that this is just a quibble.
>
> Ian


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